From d9a0cc7293bea40c5eea6da5eb416870f741c2f2 Mon Sep 17 00:00:00 2001 From: Robbie McKinstry Date: Wed, 21 Sep 2022 14:27:16 -0400 Subject: [PATCH 01/16] Split types/inputs.ts and types/outputs.ts This commit splits the Input and Output (IO) definitions into a collection of files instead of just two total files. Now, each mod gets its own directory under /types which exposes index.ts, output.ts, and input.ts files. By splitting up defintions, we reduce the amount of memory needed to lookup the type definition for a single type -- previously, we had to load every type in the package just to read a single type. --- ...js--split-type-definitions-for-nodejs.yaml | 4 + pkg/codegen/nodejs/gen.go | 237 +++++++++++++++--- pkg/codegen/nodejs/gen_test.go | 46 ++++ 3 files changed, 259 insertions(+), 28 deletions(-) create mode 100644 changelog/pending/20221006--sdkgen-nodejs--split-type-definitions-for-nodejs.yaml diff --git a/changelog/pending/20221006--sdkgen-nodejs--split-type-definitions-for-nodejs.yaml b/changelog/pending/20221006--sdkgen-nodejs--split-type-definitions-for-nodejs.yaml new file mode 100644 index 000000000000..72c4aafb0246 --- /dev/null +++ b/changelog/pending/20221006--sdkgen-nodejs--split-type-definitions-for-nodejs.yaml @@ -0,0 +1,4 @@ +changes: +- type: feat + scope: sdkgen/nodejs + description: Splits input and output definitions into multiple files. diff --git a/pkg/codegen/nodejs/gen.go b/pkg/codegen/nodejs/gen.go index 9aa8e95e4422..aad259aae843 100644 --- a/pkg/codegen/nodejs/gen.go +++ b/pkg/codegen/nodejs/gen.go @@ -1502,7 +1502,7 @@ func (mod *modContext) genConfig(w io.Writer, variables []*schema.Property) erro externalImports, imports := codegen.NewStringSet(), map[string]codegen.StringSet{} referencesNestedTypes := mod.getImports(variables, externalImports, imports) - mod.genHeader(w, mod.sdkImports(referencesNestedTypes, true), externalImports, imports) + mod.genHeader(w, mod.sdkImports(referencesNestedTypes, true, ""), externalImports, imports) fmt.Fprintf(w, "declare var exports: any;\n") @@ -1542,17 +1542,34 @@ func (mod *modContext) genConfig(w io.Writer, variables []*schema.Property) erro return nil } -func (mod *modContext) getRelativePath() string { - rel, err := filepath.Rel(mod.mod, "") +func (mod *modContext) getRelativePath(dirRoot string) string { + var currPath string + if dirRoot == "" { + currPath = mod.mod + } else { + currPath = dirRoot + } + rel, err := filepath.Rel(currPath, "") contract.Assert(err == nil) return path.Dir(filepath.ToSlash(rel)) } -func (mod *modContext) sdkImports(nested, utilities bool) []string { +func (mod *modContext) sdkImports(nested, utilities bool, dirRoot string) []string { imports := []string{"import * as pulumi from \"@pulumi/pulumi\";"} - relRoot := mod.getRelativePath() + // TODO: Skip writing sdkImports for types.inputs/types.outputs as special case. + relRoot := mod.getRelativePath(dirRoot) + // If this file is generating inputs in /types/, then it will be one level + // lower than otherwise. + // if typegen { + // relRoot = path.Join("..", relRoot) + // } + fmt.Printf("Mod: %s -- relRoot: %s\n", mod.mod, relRoot) if nested { + // TODO: If we're nested, we need to know HOW FAR we're nested! + // this is only for nested TYPE outputs/inputs. Those are + // potentially nested but ALSO nested wthin the types file, + // which makes matters worse since they could be nested even deeper. imports = append(imports, []string{ fmt.Sprintf(`import * as inputs from "%s/types/input";`, relRoot), fmt.Sprintf(`import * as outputs from "%s/types/output";`, relRoot), @@ -1575,12 +1592,13 @@ func (mod *modContext) sdkImports(nested, utilities bool) []string { } func (mod *modContext) utilitiesImport() string { - relRoot := mod.getRelativePath() + relRoot := mod.getRelativePath("") return fmt.Sprintf("import * as utilities from \"%s/utilities\";", relRoot) } -func (mod *modContext) genTypes() (string, string, error) { - externalImports, imports := codegen.NewStringSet(), map[string]codegen.StringSet{} +func (mod *modContext) buildImports() (codegen.StringSet, map[string]codegen.StringSet) { + var externalImports = codegen.NewStringSet() + var imports = map[string]codegen.StringSet{} var hasDefaultObjects bool for _, t := range mod.types { if t.IsOverlay { @@ -1596,23 +1614,40 @@ func (mod *modContext) genTypes() (string, string, error) { // Instantiating the default might require an environmental variable. This // uses utilities. if hasDefaultObjects { - externalImports.Add(fmt.Sprintf("import * as utilities from \"%s/utilities\";", mod.getRelativePath())) - } - - inputs, outputs := &bytes.Buffer{}, &bytes.Buffer{} - mod.genHeader(inputs, mod.sdkImports(true, false), externalImports, imports) - mod.genHeader(outputs, mod.sdkImports(true, false), externalImports, imports) + externalImports.Add(fmt.Sprintf("import * as utilities from \"%s/utilities\";", mod.getRelativePath(""))) + } + return externalImports, imports +} + +func (mod *modContext) genTypes() ([]*ioFile, error) { + var ( + inputFiles, outputFiles []*ioFile + err error + // Fetch the collection of imports needed by these modules. + externalImports, imports = mod.buildImports() + // Build a file tree out of the types, then emit them. + namespaces = mod.getNamespaces() + buildCtx = func(input bool) *ioContext { + return &ioContext{ + mod: mod, + input: input, + imports: imports, + externalImports: externalImports, + } + } - // Build a namespace tree out of the types, then emit them. - namespaces := mod.getNamespaces() - if err := mod.genNamespace(inputs, namespaces[""], true, 0); err != nil { - return "", "", err + inputCtx = buildCtx(true) + outputCtx = buildCtx(false) + ) + // Iterate through the namespaces, generating one per node in the tree. + if inputFiles, err = namespaces[""].intoIOFiles(inputCtx, "./types"); err != nil { + return nil, err } - if err := mod.genNamespace(outputs, namespaces[""], false, 0); err != nil { - return "", "", err + if outputFiles, err = namespaces[""].intoIOFiles(outputCtx, "./types"); err != nil { + return nil, err } - return inputs.String(), outputs.String(), nil + return append(inputFiles, outputFiles...), nil } type namespace struct { @@ -1622,6 +1657,151 @@ type namespace struct { children []*namespace } +// The Debug method returns a string representation of +// the namespace for the purposes of debugging. +func (ns namespace) Debug() string { + var children []string + for _, child := range ns.children { + children = append(children, child.name) + } + var childrenStr = strings.Join(children, "\t\n") + return fmt.Sprintf( + "Namespace %s:\n\tTypes: %d\n\tEnums: %d\n\tChildren:\n%s", + ns.name, + len(ns.types), + len(ns.enums), + childrenStr, + ) +} + +// ioContext defines a set of parameters used when generating input/output +// type definitions. These parameters are stable no matter which directory +// is getting generated. +type ioContext struct { + mod *modContext + input bool + imports map[string]codegen.StringSet + externalImports codegen.StringSet +} + +// intoIOFiles converts this namespace into one or more files. +// It recursively builds one file for each node in the tree. +// If input=true, then it builds input types. Otherwise, it +// builds output types. +// The parameters in ctx are stable regardless of the depth of recursion, +// but parent is expected to change with each recursive call. +func (ns *namespace) intoIOFiles(ctx *ioContext, parent string) ([]*ioFile, error) { + // We generate the input and output namespaces when there are enums, regardless of i + // they are empty. + if ns == nil { + panic("TODO: The caller needs to check if this is nil or not first.") + } + fmt.Println(ns.Debug()) + // Declare a new file to store the contents exposed at this directory level. + var dirRoot = path.Join(parent, ns.name) + var filename string + if ctx.input { + filename = path.Join(dirRoot, "input.ts") + } else { + filename = path.Join(dirRoot, "output.ts") + } + fmt.Printf("Generating namespace into IO file: %s\n", filename) + var file = newIOFile(filename) + // We start every file with the header information. + ctx.mod.genHeader(file.writer(), ctx.mod.sdkImports(true, false, dirRoot), ctx.externalImports, ctx.imports) + // We want to organize the items in the source file by alphabetical order. + sort.Slice(ns.types, func(i, j int) bool { + return tokenToName(ns.types[i].Token) < tokenToName(ns.types[j].Token) + }) + sort.Slice(ns.enums, func(i, j int) bool { + return tokenToName(ns.enums[i].Token) < tokenToName(ns.enums[j].Token) + }) + // Now, we write out the types declared at this directory + // level to the file. + var files = []*ioFile{file} + for i, t := range ns.types { + var isInputType = ctx.input && ctx.mod.details(t).inputType + var isOutputType = !ctx.input && ctx.mod.details(t).outputType + // Only write input and output types. + if isInputType || isOutputType { + if err := ctx.mod.genType(file.writer(), t, ctx.input, 0); err != nil { + return files, err + } + if i != len(ns.types)-1 { + fmt.Fprintf(file.writer(), "\n") + } + } + } + // We have successfully written all types at this level. + // Next, we recurse to generate the files at the next directory level. + sort.Slice(ns.children, func(i, j int) bool { + return ns.children[i].name < ns.children[j].name + }) + for i, child := range ns.children { + // At this level, we export any nested definitions from + // the next level. + var fullPath = path.Join(dirRoot, child.name) + fmt.Printf("-----> Exporting file %s with parent %s\n", fullPath, dirRoot) + //fmt.Fprintf(file.writer(), "export * as %s from \"%s\";\n", child.name, fullPath) + fmt.Fprintf(file.writer(), "export * as %s from \"./%s\";\n", child.name, child.name) + // fmt.Fprintf(file.writer(), "export type { %s };", child.name) + nestedFiles, err := child.intoIOFiles(ctx, dirRoot) + if err != nil { + return nil, err + } + if i != len(ns.children)-1 { + fmt.Fprintf(file.writer(), "\n") + } + // Collect these files to return. + files = append(files, nestedFiles...) + } + + // Lastly, we write the index file for this directory once. + // We don't want to generate the file twice, when this function is called + // with input=true and again when input=false, so we only generate it + // when input=true. + // As a special case, we skip the top-level directory /types/, since that + // is written elsewhere. + if parent != "./types" && ctx.input { + var indexPath = path.Join(dirRoot, "index.ts") + var file = newIOFile(indexPath) + ctx.mod.genHeader(file.writer(), nil, nil, nil) + fmt.Fprintf(file.writer(), "export * from \"./%s\";\n", "input") + fmt.Fprintf(file.writer(), "export * from \"./%s\";\n", "output") + files = append(files, file) + } + + return files, nil +} + +// An ioFile represents a file containing Input/Output type definitions. +type ioFile struct { + // Each file has a name relative to the top-level directory. + filename string + // This writer stores the contents of the file as we build it incrementally. + buffer *bytes.Buffer +} + +// newIOFile constructs a new ioFile +func newIOFile(name string) *ioFile { + return &ioFile{ + filename: name, + buffer: bytes.NewBuffer(nil), + } +} + +func (f *ioFile) name() string { + return f.filename +} + +func (f *ioFile) writer() io.Writer { + return f.buffer +} + +func (f *ioFile) contents() []byte { + return f.buffer.Bytes() +} + func (mod *modContext) getNamespaces() map[string]*namespace { namespaces := map[string]*namespace{} var getNamespace func(string) *namespace @@ -1844,7 +2024,7 @@ func (mod *modContext) gen(fs codegen.Fs) error { referencesNestedTypes := mod.getImportsForResource(r, externalImports, imports, r) buffer := &bytes.Buffer{} - mod.genHeader(buffer, mod.sdkImports(referencesNestedTypes, true), externalImports, imports) + mod.genHeader(buffer, mod.sdkImports(referencesNestedTypes, true, ""), externalImports, imports) rinfo, err := mod.genResource(buffer, r) if err != nil { @@ -1866,7 +2046,7 @@ func (mod *modContext) gen(fs codegen.Fs) error { referencesNestedTypes := mod.getImports(f, externalImports, imports) buffer := &bytes.Buffer{} - mod.genHeader(buffer, mod.sdkImports(referencesNestedTypes, true), externalImports, imports) + mod.genHeader(buffer, mod.sdkImports(referencesNestedTypes, true, ""), externalImports, imports) funInfo, err := mod.genFunction(buffer, f) if err != nil { @@ -1902,12 +2082,13 @@ func (mod *modContext) gen(fs codegen.Fs) error { // Nested types // Importing enums always imports inputs and outputs, so if we have enums we generate inputs and outputs if len(mod.types) > 0 || (mod.pkg.Language["nodejs"].(NodePackageInfo).ContainsEnums && mod.mod == "types") { - input, output, err := mod.genTypes() + files, err := mod.genTypes() if err != nil { return err } - fs.Add(path.Join(modDir, "input.ts"), []byte(input)) - fs.Add(path.Join(modDir, "output.ts"), []byte(output)) + for _, file := range files { + fs.Add(file.name(), []byte(file.contents())) + } } // Index @@ -1945,7 +2126,7 @@ func (mod *modContext) genIndex(exports []fileInfo) string { var imports []string // Include the SDK import if we'll be registering module resources. if len(mod.resources) != 0 { - imports = mod.sdkImports(false /*nested*/, true /*utilities*/) + imports = mod.sdkImports(false, true, "") } else if len(children) > 0 || len(mod.functions) > 0 { // Even if there are no resources, exports ref utilities. imports = append(imports, mod.utilitiesImport()) @@ -1983,7 +2164,7 @@ func (mod *modContext) genIndex(exports []fileInfo) string { } else if len(mod.enums) > 0 { fmt.Fprintf(w, "\n") fmt.Fprintf(w, "// Export enums:\n") - rel := mod.getRelativePath() + rel := mod.getRelativePath("") var filePath string if mod.mod == "" { filePath = "" diff --git a/pkg/codegen/nodejs/gen_test.go b/pkg/codegen/nodejs/gen_test.go index 1c6289de4032..0edbd1d69835 100644 --- a/pkg/codegen/nodejs/gen_test.go +++ b/pkg/codegen/nodejs/gen_test.go @@ -236,3 +236,49 @@ func Test_isStringType(t *testing.T) { }) } } + +// This test asserts that modContext.getRelativePath() +// returns the right relative path, regardless of whether +// the file is a resource definition or an Input/Output declaration +// from /types/ +func TestGetRelativePath(t *testing.T) { + t.Parallel() + type TestCase struct { + mod string + dirRoot string + expected string + } + var cases = []TestCase{ + { + mod: "foo", + dirRoot: "", + expected: "..", + }, { + mod: "foo/bar", + dirRoot: "", + expected: "../..", + }, { + mod: "types/accessanalyzer/input", + dirRoot: "", + expected: "../../..", + }, { + mod: "input", + dirRoot: "types/accessanalyzer", + expected: "../..", + }, + } + for _, tc := range cases { + var ctx = &modContext{mod: tc.mod} + var observed = ctx.getRelativePath(tc.dirRoot) + require.Equal( + t, + tc.expected, + observed, + "Case (%s, %s): Expected %s, Observed %s", + tc.mod, + tc.dirRoot, + tc.expected, + observed, + ) + } +} From e40a650db02ca71682a30ecb191cb8d395d3a130 Mon Sep 17 00:00:00 2001 From: Robbie McKinstry Date: Thu, 6 Oct 2022 11:32:08 -0400 Subject: [PATCH 02/16] Refactor getRelativePath, remove comments --- pkg/codegen/nodejs/gen.go | 158 ++++++++++-------- pkg/codegen/nodejs/gen_test.go | 46 ++--- .../nodejs/codegen-manifest.json | 3 + .../nodejs/tsconfig.json | 3 + .../nodejs/types/documentdb/index.ts | 5 + .../nodejs/types/documentdb/input.ts | 7 + .../nodejs/types/documentdb/output.ts | 35 ++++ .../nodejs/types/input.ts | 3 +- .../nodejs/types/output.ts | 31 +--- .../cyclic-types/nodejs/types/input.ts | 1 + .../cyclic-types/nodejs/types/output.ts | 1 + .../nodejs/types/input.ts | 1 - .../nodejs/types/output.ts | 1 - .../nodejs/types/input.ts | 1 + .../nodejs/types/output.ts | 1 + .../nodejs/types/input.ts | 1 + .../nodejs/types/output.ts | 1 + .../output-funcs/nodejs/types/input.ts | 1 + .../output-funcs/nodejs/types/output.ts | 1 + .../plain-and-default/nodejs/types/input.ts | 1 + .../plain-and-default/nodejs/types/output.ts | 1 + .../nodejs/codegen-manifest.json | 6 + .../nodejs/tsconfig.json | 6 + .../nodejs/types/input.ts | 39 +---- .../nodejs/types/mod1/index.ts | 5 + .../nodejs/types/mod1/input.ts | 23 +++ .../nodejs/types/mod1/output.ts | 8 + .../nodejs/types/mod2/index.ts | 5 + .../nodejs/types/mod2/input.ts | 25 +++ .../nodejs/types/mod2/output.ts | 8 + .../nodejs/types/output.ts | 7 +- .../nodejs/codegen-manifest.json | 6 + .../nodejs/tsconfig.json | 6 + .../nodejs/types/input.ts | 39 +---- .../nodejs/types/mod1/index.ts | 5 + .../nodejs/types/mod1/input.ts | 23 +++ .../nodejs/types/mod1/output.ts | 8 + .../nodejs/types/mod2/index.ts | 5 + .../nodejs/types/mod2/input.ts | 25 +++ .../nodejs/types/mod2/output.ts | 8 + .../nodejs/types/output.ts | 7 +- .../nodejs/codegen-manifest.json | 3 + .../nodejs/tsconfig.json | 3 + .../nodejs/types/config/index.ts | 5 + .../nodejs/types/config/input.ts | 9 + .../nodejs/types/config/output.ts | 14 ++ .../nodejs/types/input.ts | 4 +- .../nodejs/types/output.ts | 9 +- .../regress-8403/nodejs/types/input.ts | 1 + .../regress-8403/nodejs/types/output.ts | 1 + .../regress-node-8110/nodejs/types/input.ts | 1 + .../regress-node-8110/nodejs/types/output.ts | 1 + .../replace-on-change/nodejs/types/input.ts | 1 + .../replace-on-change/nodejs/types/output.ts | 1 + .../nodejs/codegen-manifest.json | 3 + .../nodejs/tsconfig.json | 3 + .../nodejs/types/input.ts | 12 +- .../nodejs/types/nested/index.ts | 5 + .../nodejs/types/nested/input.ts | 16 ++ .../nodejs/types/nested/output.ts | 7 + .../nodejs/types/output.ts | 3 +- .../simple-yaml-schema/nodejs/types/input.ts | 1 + .../simple-yaml-schema/nodejs/types/output.ts | 1 + 63 files changed, 443 insertions(+), 228 deletions(-) create mode 100644 pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/documentdb/index.ts create mode 100644 pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/documentdb/input.ts create mode 100644 pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/documentdb/output.ts create mode 100644 pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod1/index.ts create mode 100644 pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod1/input.ts create mode 100644 pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod1/output.ts create mode 100644 pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod2/index.ts create mode 100644 pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod2/input.ts create mode 100644 pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod2/output.ts create mode 100644 pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod1/index.ts create mode 100644 pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod1/input.ts create mode 100644 pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod1/output.ts create mode 100644 pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod2/index.ts create mode 100644 pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod2/input.ts create mode 100644 pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod2/output.ts create mode 100644 pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/config/index.ts create mode 100644 pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/config/input.ts create mode 100644 pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/config/output.ts create mode 100644 pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/nested/index.ts create mode 100644 pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/nested/input.ts create mode 100644 pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/nested/output.ts diff --git a/pkg/codegen/nodejs/gen.go b/pkg/codegen/nodejs/gen.go index aad259aae843..11c525d90790 100644 --- a/pkg/codegen/nodejs/gen.go +++ b/pkg/codegen/nodejs/gen.go @@ -1502,7 +1502,7 @@ func (mod *modContext) genConfig(w io.Writer, variables []*schema.Property) erro externalImports, imports := codegen.NewStringSet(), map[string]codegen.StringSet{} referencesNestedTypes := mod.getImports(variables, externalImports, imports) - mod.genHeader(w, mod.sdkImports(referencesNestedTypes, true, ""), externalImports, imports) + mod.genHeader(w, mod.sdkImports(referencesNestedTypes, true), externalImports, imports) fmt.Fprintf(w, "declare var exports: any;\n") @@ -1542,64 +1542,80 @@ func (mod *modContext) genConfig(w io.Writer, variables []*schema.Property) erro return nil } -func (mod *modContext) getRelativePath(dirRoot string) string { - var currPath string - if dirRoot == "" { - currPath = mod.mod - } else { - currPath = dirRoot - } - rel, err := filepath.Rel(currPath, "") +// getRelativePath returns a path to the top level of the package +// relative to directory passed in. You must pass in the name +// of a directory. If you provide a file name, like "index.ts", it's assumed +// to be a directory named "index.ts". +// It's a thin wrapper around the standard library's implementation. +func getRelativePath(dirname string) string { + var rel, err = filepath.Rel(dirname, "") contract.Assert(err == nil) return path.Dir(filepath.ToSlash(rel)) } -func (mod *modContext) sdkImports(nested, utilities bool, dirRoot string) []string { - imports := []string{"import * as pulumi from \"@pulumi/pulumi\";"} +// The parameter dirRoot is used as the relative path +func (mod *modContext) getRelativePath() string { + return getRelativePath(mod.mod) +} - // TODO: Skip writing sdkImports for types.inputs/types.outputs as special case. - relRoot := mod.getRelativePath(dirRoot) - // If this file is generating inputs in /types/, then it will be one level - // lower than otherwise. - // if typegen { - // relRoot = path.Join("..", relRoot) - // } - fmt.Printf("Mod: %s -- relRoot: %s\n", mod.mod, relRoot) - if nested { - // TODO: If we're nested, we need to know HOW FAR we're nested! - // this is only for nested TYPE outputs/inputs. Those are - // potentially nested but ALSO nested wthin the types file, - // which makes matters worse since they could be nested even deeper. - imports = append(imports, []string{ - fmt.Sprintf(`import * as inputs from "%s/types/input";`, relRoot), - fmt.Sprintf(`import * as outputs from "%s/types/output";`, relRoot), - }...) +// sdkImports generates the imports at the top of a source file. +// This function is only intended to be called from resource files and +// at the index. For files nested in the `/types` folder, call +// sdkImportsForTypes instead. +func (mod *modContext) sdkImports(nested, utilities bool) []string { + return mod.sdkImportsWithPath(nested, utilities, mod.mod) +} - if mod.pkg.Language["nodejs"].(NodePackageInfo).ContainsEnums { - code := `import * as enums from "%s/types/enums";` - if lookupNodePackageInfo(mod.pkg).UseTypeOnlyReferences { - code = `import type * as enums from "%s/types/enums";` - } - imports = append(imports, fmt.Sprintf(code, relRoot)) - } +// sdkImportsWithPath generates the import functions at the top of each file. +// If nested is true, then the file is assumed not to be at the top-level i.e. +// it's located in a subfolder of the root, perhaps deeply nested. +// If utilities is true, then utility functions are imported. +// dirpath injects the directory name of the input file relative to the root of the package. +func (mod *modContext) sdkImportsWithPath(nested, utilities bool, dirpath string) []string { + // All files need to import the SDK. + var imports = []string{"import * as pulumi from \"@pulumi/pulumi\";"} + var relRoot = getRelativePath(dirpath) + // Add nested imports if enabled. + if nested { + imports = append(imports, mod.genNestedImports(relRoot)...) } - + // Add utility imports if enabled. if utilities { - imports = append(imports, mod.utilitiesImport()) + imports = append(imports, mod.utilitiesImport(relRoot)) } return imports } -func (mod *modContext) utilitiesImport() string { - relRoot := mod.getRelativePath("") +func (mod *modContext) utilitiesImport(relRoot string) string { return fmt.Sprintf("import * as utilities from \"%s/utilities\";", relRoot) } +// relRoot is the path that ajoins this module or file with the top-level +// of the repo. For example, if this file was located in "./foo/index.ts", +// then relRoot would be "..", since that's the path to the top-level directory. +func (mod *modContext) genNestedImports(relRoot string) []string { + // Always import all input and output types. + var imports = []string{ + fmt.Sprintf(`import * as inputs from "%s/types/input";`, relRoot), + fmt.Sprintf(`import * as outputs from "%s/types/output";`, relRoot), + } + // Next, if there are enums, then we import them too. + if mod.pkg.Language["nodejs"].(NodePackageInfo).ContainsEnums { + code := `import * as enums from "%s/types/enums";` + if lookupNodePackageInfo(mod.pkg).UseTypeOnlyReferences { + code = `import type * as enums from "%s/types/enums";` + } + imports = append(imports, fmt.Sprintf(code, relRoot)) + } + return imports +} + +// the parameter defaultNs is expected to be the top-level namespace. +// If its nil, then we skip importing types files, since they will not exist. func (mod *modContext) buildImports() (codegen.StringSet, map[string]codegen.StringSet) { var externalImports = codegen.NewStringSet() var imports = map[string]codegen.StringSet{} - var hasDefaultObjects bool for _, t := range mod.types { if t.IsOverlay { // This type is generated by the provider, so no further action is required. @@ -1607,14 +1623,6 @@ func (mod *modContext) buildImports() (codegen.StringSet, map[string]codegen.Str } mod.getImports(t, externalImports, imports) - if codegen.IsProvideDefaultsFuncRequired(t) { - hasDefaultObjects = true - } - } - // Instantiating the default might require an environmental variable. This - // uses utilities. - if hasDefaultObjects { - externalImports.Add(fmt.Sprintf("import * as utilities from \"%s/utilities\";", mod.getRelativePath(""))) } return externalImports, imports } @@ -1623,11 +1631,11 @@ func (mod *modContext) genTypes() ([]*ioFile, error) { var ( inputFiles, outputFiles []*ioFile err error - // Fetch the collection of imports needed by these modules. - externalImports, imports = mod.buildImports() // Build a file tree out of the types, then emit them. namespaces = mod.getNamespaces() - buildCtx = func(input bool) *ioContext { + // Fetch the collection of imports needed by these modules. + externalImports, imports = mod.buildImports() + buildCtx = func(input bool) *ioContext { return &ioContext{ mod: mod, input: input, @@ -1639,6 +1647,11 @@ func (mod *modContext) genTypes() ([]*ioFile, error) { inputCtx = buildCtx(true) outputCtx = buildCtx(false) ) + // If there are no namespaces, then we generate empty + // input and output files. + if namespaces[""] == nil { + return nil, fmt.Errorf("Encountered a nil top-level namespace. The top-level namespace cannot be nil, even if it is empty.") + } // Iterate through the namespaces, generating one per node in the tree. if inputFiles, err = namespaces[""].intoIOFiles(inputCtx, "./types"); err != nil { return nil, err @@ -1691,12 +1704,12 @@ type ioContext struct { // The parameters in ctx are stable regardless of the depth of recursion, // but parent is expected to change with each recursive call. func (ns *namespace) intoIOFiles(ctx *ioContext, parent string) ([]*ioFile, error) { - // We generate the input and output namespaces when there are enums, regardless of i - // they are empty. + // We generate the input and output namespaces when there are enums, + // regardless of whether they are empty. if ns == nil { - panic("TODO: The caller needs to check if this is nil or not first.") + return nil, fmt.Errorf("Generating IO files for a nil namespace") } - fmt.Println(ns.Debug()) + // Declare a new file to store the contents exposed at this directory level. var dirRoot = path.Join(parent, ns.name) var filename string @@ -1705,10 +1718,14 @@ func (ns *namespace) intoIOFiles(ctx *ioContext, parent string) ([]*ioFile, erro } else { filename = path.Join(dirRoot, "output.ts") } - fmt.Printf("Generating namespace into IO file: %s\n", filename) var file = newIOFile(filename) // We start every file with the header information. - ctx.mod.genHeader(file.writer(), ctx.mod.sdkImports(true, false, dirRoot), ctx.externalImports, ctx.imports) + ctx.mod.genHeader( + file.writer(), + ctx.mod.sdkImportsWithPath(true, true, dirRoot), + ctx.externalImports, + ctx.imports, + ) // We want to organize the items in the source file by alphabetical order. sort.Slice(ns.types, func(i, j int) bool { return tokenToName(ns.types[i].Token) < tokenToName(ns.types[j].Token) @@ -1738,13 +1755,14 @@ func (ns *namespace) intoIOFiles(ctx *ioContext, parent string) ([]*ioFile, erro return ns.children[i].name < ns.children[j].name }) for i, child := range ns.children { + // Defensive coding: child should never be null, but + // child.intoIOFiles will break if it is. + if child == nil { + continue + } // At this level, we export any nested definitions from // the next level. - var fullPath = path.Join(dirRoot, child.name) - fmt.Printf("-----> Exporting file %s with parent %s\n", fullPath, dirRoot) - //fmt.Fprintf(file.writer(), "export * as %s from \"%s\";\n", child.name, fullPath) fmt.Fprintf(file.writer(), "export * as %s from \"./%s\";\n", child.name, child.name) - // fmt.Fprintf(file.writer(), "export type { %s };", child.name) nestedFiles, err := child.intoIOFiles(ctx, dirRoot) if err != nil { return nil, err @@ -1842,6 +1860,14 @@ func (mod *modContext) getNamespaces() map[string]*namespace { ns.types = append(ns.types, t) } + // We need to ensure the top-level namespace is always populated, even + // if there are no types to export. + if _, ok := namespaces[""]; !ok { + namespaces[""] = &namespace{ + name: "", + } + } + return namespaces } @@ -2024,7 +2050,7 @@ func (mod *modContext) gen(fs codegen.Fs) error { referencesNestedTypes := mod.getImportsForResource(r, externalImports, imports, r) buffer := &bytes.Buffer{} - mod.genHeader(buffer, mod.sdkImports(referencesNestedTypes, true, ""), externalImports, imports) + mod.genHeader(buffer, mod.sdkImports(referencesNestedTypes, true), externalImports, imports) rinfo, err := mod.genResource(buffer, r) if err != nil { @@ -2046,7 +2072,7 @@ func (mod *modContext) gen(fs codegen.Fs) error { referencesNestedTypes := mod.getImports(f, externalImports, imports) buffer := &bytes.Buffer{} - mod.genHeader(buffer, mod.sdkImports(referencesNestedTypes, true, ""), externalImports, imports) + mod.genHeader(buffer, mod.sdkImports(referencesNestedTypes, true), externalImports, imports) funInfo, err := mod.genFunction(buffer, f) if err != nil { @@ -2126,10 +2152,10 @@ func (mod *modContext) genIndex(exports []fileInfo) string { var imports []string // Include the SDK import if we'll be registering module resources. if len(mod.resources) != 0 { - imports = mod.sdkImports(false, true, "") + imports = mod.sdkImports(false, true) } else if len(children) > 0 || len(mod.functions) > 0 { // Even if there are no resources, exports ref utilities. - imports = append(imports, mod.utilitiesImport()) + imports = append(imports, mod.utilitiesImport(mod.getRelativePath())) } mod.genHeader(w, imports, nil, nil) @@ -2164,7 +2190,7 @@ func (mod *modContext) genIndex(exports []fileInfo) string { } else if len(mod.enums) > 0 { fmt.Fprintf(w, "\n") fmt.Fprintf(w, "// Export enums:\n") - rel := mod.getRelativePath("") + rel := mod.getRelativePath() var filePath string if mod.mod == "" { filePath = "" diff --git a/pkg/codegen/nodejs/gen_test.go b/pkg/codegen/nodejs/gen_test.go index 0edbd1d69835..35e6878acd87 100644 --- a/pkg/codegen/nodejs/gen_test.go +++ b/pkg/codegen/nodejs/gen_test.go @@ -237,48 +237,50 @@ func Test_isStringType(t *testing.T) { } } -// This test asserts that modContext.getRelativePath() -// returns the right relative path, regardless of whether -// the file is a resource definition or an Input/Output declaration -// from /types/ +// This test asserts that getRelativePath() +// returns the right relative path. This smoke test +// functions to pin the expected behavior to prevent regressions. func TestGetRelativePath(t *testing.T) { t.Parallel() type TestCase struct { - mod string - dirRoot string + filename string expected string } + // Recall that arguments are assumed to be directory names, + // even if they contain an extension. var cases = []TestCase{ { - mod: "foo", - dirRoot: "", + filename: "foo.ts", expected: "..", }, { - mod: "foo/bar", - dirRoot: "", + filename: "foo/bar", expected: "../..", }, { - mod: "types/accessanalyzer/input", - dirRoot: "", + filename: "types/accessanalyzer/input", expected: "../../..", }, { - mod: "input", - dirRoot: "types/accessanalyzer", + filename: "types/accessanalyzer/nested/input.ts", + expected: "../../../..", + }, { + filename: "types", + expected: "..", + }, { + filename: "./types/aws", expected: "../..", - }, - } + }, { + filename: "./types", + expected: "..", + }} for _, tc := range cases { - var ctx = &modContext{mod: tc.mod} - var observed = ctx.getRelativePath(tc.dirRoot) + var observed = getRelativePath(tc.filename) require.Equal( t, tc.expected, observed, - "Case (%s, %s): Expected %s, Observed %s", - tc.mod, - tc.dirRoot, + "Case (%s): Expected %s, Observed %s", + tc.filename, tc.expected, observed, ) } -} +} \ No newline at end of file diff --git a/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/codegen-manifest.json b/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/codegen-manifest.json index 6d9fbb678803..bb356f455c4b 100644 --- a/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/codegen-manifest.json +++ b/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/codegen-manifest.json @@ -8,6 +8,9 @@ "provider.ts", "scripts/install-pulumi-plugin.js", "tsconfig.json", + "types/documentdb/index.ts", + "types/documentdb/input.ts", + "types/documentdb/output.ts", "types/index.ts", "types/input.ts", "types/output.ts", diff --git a/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/tsconfig.json index db69a22a00ce..e21743ea2c3a 100644 --- a/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/tsconfig.json @@ -17,6 +17,9 @@ "documentdb/sqlResourceSqlContainer.ts", "index.ts", "provider.ts", + "types/documentdb/index.ts", + "types/documentdb/input.ts", + "types/documentdb/output.ts", "types/index.ts", "types/input.ts", "types/output.ts", diff --git a/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/documentdb/index.ts b/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/documentdb/index.ts new file mode 100644 index 000000000000..38514e5494d6 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/documentdb/index.ts @@ -0,0 +1,5 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +export * from "./input"; +export * from "./output"; diff --git a/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/documentdb/input.ts b/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/documentdb/input.ts new file mode 100644 index 000000000000..e8e567507ec0 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/documentdb/input.ts @@ -0,0 +1,7 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +import * as pulumi from "@pulumi/pulumi"; +import * as inputs from "../../types/input"; +import * as outputs from "../../types/output"; + diff --git a/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/documentdb/output.ts b/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/documentdb/output.ts new file mode 100644 index 000000000000..7f74aa6e3685 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/documentdb/output.ts @@ -0,0 +1,35 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +import * as pulumi from "@pulumi/pulumi"; +import * as inputs from "../../types/input"; +import * as outputs from "../../types/output"; + +export interface CompositePathResponse { + /** + * Sort order for composite paths. + */ + order?: string; + /** + * The path for which the indexing behavior applies to. Index paths typically start with root and end with wildcard (/path/*) + */ + path?: string; +} + +/** + * Cosmos DB indexing policy + */ +export interface IndexingPolicyResponse { + /** + * List of composite path list + */ + compositeIndexes?: outputs.documentdb.CompositePathResponse[][]; +} + +export interface SqlContainerGetPropertiesResponseResource { + /** + * The configuration of the indexing policy. By default, the indexing is automatic for all document paths within the container + */ + indexingPolicy?: outputs.documentdb.IndexingPolicyResponse; +} + diff --git a/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/input.ts index 311e0b376968..2f582458b852 100644 --- a/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/input.ts @@ -5,5 +5,4 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; -export namespace documentdb { -} +export * as documentdb from "./documentdb"; diff --git a/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/output.ts index a57a6887c16c..2f582458b852 100644 --- a/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/output.ts @@ -5,33 +5,4 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; -export namespace documentdb { - export interface CompositePathResponse { - /** - * Sort order for composite paths. - */ - order?: string; - /** - * The path for which the indexing behavior applies to. Index paths typically start with root and end with wildcard (/path/*) - */ - path?: string; - } - - /** - * Cosmos DB indexing policy - */ - export interface IndexingPolicyResponse { - /** - * List of composite path list - */ - compositeIndexes?: outputs.documentdb.CompositePathResponse[][]; - } - - export interface SqlContainerGetPropertiesResponseResource { - /** - * The configuration of the indexing policy. By default, the indexing is automatic for all document paths within the container - */ - indexingPolicy?: outputs.documentdb.IndexingPolicyResponse; - } - -} +export * as documentdb from "./documentdb"; diff --git a/pkg/codegen/testing/test/testdata/cyclic-types/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/cyclic-types/nodejs/types/input.ts index a277306fc819..efe5fda0c738 100644 --- a/pkg/codegen/testing/test/testdata/cyclic-types/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/cyclic-types/nodejs/types/input.ts @@ -4,4 +4,5 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; +import * as utilities from "../utilities"; diff --git a/pkg/codegen/testing/test/testdata/cyclic-types/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/cyclic-types/nodejs/types/output.ts index a277306fc819..efe5fda0c738 100644 --- a/pkg/codegen/testing/test/testdata/cyclic-types/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/cyclic-types/nodejs/types/output.ts @@ -4,4 +4,5 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; +import * as utilities from "../utilities"; diff --git a/pkg/codegen/testing/test/testdata/dashed-import-schema/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/dashed-import-schema/nodejs/types/input.ts index 5e35f2f8f160..fcefd058f114 100644 --- a/pkg/codegen/testing/test/testdata/dashed-import-schema/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/dashed-import-schema/nodejs/types/input.ts @@ -5,7 +5,6 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; import * as enums from "../types/enums"; - import * as utilities from "../utilities"; export interface ContainerArgs { diff --git a/pkg/codegen/testing/test/testdata/dashed-import-schema/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/dashed-import-schema/nodejs/types/output.ts index a1c27174dff9..2ed273ed9dc5 100644 --- a/pkg/codegen/testing/test/testdata/dashed-import-schema/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/dashed-import-schema/nodejs/types/output.ts @@ -5,7 +5,6 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; import * as enums from "../types/enums"; - import * as utilities from "../utilities"; export interface Container { diff --git a/pkg/codegen/testing/test/testdata/output-funcs-edgeorder/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/output-funcs-edgeorder/nodejs/types/input.ts index 2ffa9d559dff..bdcafac05b74 100644 --- a/pkg/codegen/testing/test/testdata/output-funcs-edgeorder/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/output-funcs-edgeorder/nodejs/types/input.ts @@ -5,6 +5,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; import * as enums from "../types/enums"; +import * as utilities from "../utilities"; /** * Configuration filters diff --git a/pkg/codegen/testing/test/testdata/output-funcs-edgeorder/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/output-funcs-edgeorder/nodejs/types/output.ts index 5cb5a6753c21..e9b2c5a7c92f 100644 --- a/pkg/codegen/testing/test/testdata/output-funcs-edgeorder/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/output-funcs-edgeorder/nodejs/types/output.ts @@ -5,6 +5,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; import * as enums from "../types/enums"; +import * as utilities from "../utilities"; /** * Availability information of a product system. diff --git a/pkg/codegen/testing/test/testdata/output-funcs-tfbridge20/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/output-funcs-tfbridge20/nodejs/types/input.ts index df48c5253e10..1c3b957d84ae 100644 --- a/pkg/codegen/testing/test/testdata/output-funcs-tfbridge20/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/output-funcs-tfbridge20/nodejs/types/input.ts @@ -4,6 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; +import * as utilities from "../utilities"; export interface GetAmiIdsFilter { name: string; diff --git a/pkg/codegen/testing/test/testdata/output-funcs-tfbridge20/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/output-funcs-tfbridge20/nodejs/types/output.ts index 4d2e3f38de57..ff7bb8563a2a 100644 --- a/pkg/codegen/testing/test/testdata/output-funcs-tfbridge20/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/output-funcs-tfbridge20/nodejs/types/output.ts @@ -4,6 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; +import * as utilities from "../utilities"; export interface GetAmiIdsFilter { name: string; diff --git a/pkg/codegen/testing/test/testdata/output-funcs/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/output-funcs/nodejs/types/input.ts index b7e782170aa2..d46e0bbb393d 100644 --- a/pkg/codegen/testing/test/testdata/output-funcs/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/output-funcs/nodejs/types/input.ts @@ -4,6 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; +import * as utilities from "../utilities"; /** * Bastion Shareable Link. diff --git a/pkg/codegen/testing/test/testdata/output-funcs/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/output-funcs/nodejs/types/output.ts index 37867af15a5f..bdd2962eebc3 100644 --- a/pkg/codegen/testing/test/testdata/output-funcs/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/output-funcs/nodejs/types/output.ts @@ -4,6 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; +import * as utilities from "../utilities"; /** * Ssis environment reference. diff --git a/pkg/codegen/testing/test/testdata/plain-and-default/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/plain-and-default/nodejs/types/input.ts index 176b5ce13afe..b9997a16405a 100644 --- a/pkg/codegen/testing/test/testdata/plain-and-default/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/plain-and-default/nodejs/types/input.ts @@ -5,4 +5,5 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; import * as enums from "../types/enums"; +import * as utilities from "../utilities"; diff --git a/pkg/codegen/testing/test/testdata/plain-and-default/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/plain-and-default/nodejs/types/output.ts index 176b5ce13afe..b9997a16405a 100644 --- a/pkg/codegen/testing/test/testdata/plain-and-default/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/plain-and-default/nodejs/types/output.ts @@ -5,4 +5,5 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; import * as enums from "../types/enums"; +import * as utilities from "../utilities"; diff --git a/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/codegen-manifest.json b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/codegen-manifest.json index b3e8bd48b335..dbddbd48ce95 100644 --- a/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/codegen-manifest.json +++ b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/codegen-manifest.json @@ -11,6 +11,12 @@ "tsconfig.json", "types/index.ts", "types/input.ts", + "types/mod1/index.ts", + "types/mod1/input.ts", + "types/mod1/output.ts", + "types/mod2/index.ts", + "types/mod2/input.ts", + "types/mod2/output.ts", "types/output.ts", "utilities.ts" ] diff --git a/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/tsconfig.json index 9ed19d14809e..59d7de2a223a 100644 --- a/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/tsconfig.json @@ -20,6 +20,12 @@ "provider.ts", "types/index.ts", "types/input.ts", + "types/mod1/index.ts", + "types/mod1/input.ts", + "types/mod1/output.ts", + "types/mod2/index.ts", + "types/mod2/input.ts", + "types/mod2/output.ts", "types/output.ts", "utilities.ts" ] diff --git a/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/input.ts index 289f4e94771d..b921cb21ffc8 100644 --- a/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/input.ts @@ -4,7 +4,6 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; - import * as utilities from "../utilities"; /** @@ -146,40 +145,6 @@ export function typArgsProvideDefaults(val: TypArgs): TypArgs { val: (val.val) ?? "mod main", }; } -export namespace mod1 { - /** - * A test for namespaces (mod 1) - */ - export interface TypArgs { - val?: pulumi.Input; - } - /** - * typArgsProvideDefaults sets the appropriate defaults for TypArgs - */ - export function typArgsProvideDefaults(val: TypArgs): TypArgs { - return { - ...val, - val: (val.val) ?? (utilities.getEnv("PULUMI_EXAMPLE_MOD1_DEFAULT") || "mod1"), - }; - } -} +export * as mod1 from "./mod1"; -export namespace mod2 { - /** - * A test for namespaces (mod 2) - */ - export interface TypArgs { - mod1?: pulumi.Input; - val?: pulumi.Input; - } - /** - * typArgsProvideDefaults sets the appropriate defaults for TypArgs - */ - export function typArgsProvideDefaults(val: TypArgs): TypArgs { - return { - ...val, - mod1: (val.mod1 ? pulumi.output(val.mod1).apply(inputs.mod1.typArgsProvideDefaults) : undefined), - val: (val.val) ?? "mod2", - }; - } -} +export * as mod2 from "./mod2"; diff --git a/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod1/index.ts b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod1/index.ts new file mode 100644 index 000000000000..38514e5494d6 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod1/index.ts @@ -0,0 +1,5 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +export * from "./input"; +export * from "./output"; diff --git a/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod1/input.ts b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod1/input.ts new file mode 100644 index 000000000000..de43fdfec91a --- /dev/null +++ b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod1/input.ts @@ -0,0 +1,23 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +import * as pulumi from "@pulumi/pulumi"; +import * as inputs from "../../types/input"; +import * as outputs from "../../types/output"; +import * as utilities from "../../utilities"; + +/** + * A test for namespaces (mod 1) + */ +export interface TypArgs { + val?: pulumi.Input; +} +/** + * typArgsProvideDefaults sets the appropriate defaults for TypArgs + */ +export function typArgsProvideDefaults(val: TypArgs): TypArgs { + return { + ...val, + val: (val.val) ?? (utilities.getEnv("PULUMI_EXAMPLE_MOD1_DEFAULT") || "mod1"), + }; +} diff --git a/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod1/output.ts b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod1/output.ts new file mode 100644 index 000000000000..e0c860f46c12 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod1/output.ts @@ -0,0 +1,8 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +import * as pulumi from "@pulumi/pulumi"; +import * as inputs from "../../types/input"; +import * as outputs from "../../types/output"; +import * as utilities from "../../utilities"; + diff --git a/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod2/index.ts b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod2/index.ts new file mode 100644 index 000000000000..38514e5494d6 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod2/index.ts @@ -0,0 +1,5 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +export * from "./input"; +export * from "./output"; diff --git a/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod2/input.ts b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod2/input.ts new file mode 100644 index 000000000000..0b64bcae655a --- /dev/null +++ b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod2/input.ts @@ -0,0 +1,25 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +import * as pulumi from "@pulumi/pulumi"; +import * as inputs from "../../types/input"; +import * as outputs from "../../types/output"; +import * as utilities from "../../utilities"; + +/** + * A test for namespaces (mod 2) + */ +export interface TypArgs { + mod1?: pulumi.Input; + val?: pulumi.Input; +} +/** + * typArgsProvideDefaults sets the appropriate defaults for TypArgs + */ +export function typArgsProvideDefaults(val: TypArgs): TypArgs { + return { + ...val, + mod1: (val.mod1 ? pulumi.output(val.mod1).apply(inputs.mod1.typArgsProvideDefaults) : undefined), + val: (val.val) ?? "mod2", + }; +} diff --git a/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod2/output.ts b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod2/output.ts new file mode 100644 index 000000000000..e0c860f46c12 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod2/output.ts @@ -0,0 +1,8 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +import * as pulumi from "@pulumi/pulumi"; +import * as inputs from "../../types/input"; +import * as outputs from "../../types/output"; +import * as utilities from "../../utilities"; + diff --git a/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/output.ts index dc79a613d6d5..d105f0cd511d 100644 --- a/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/output.ts @@ -4,7 +4,6 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; - import * as utilities from "../utilities"; /** @@ -33,8 +32,6 @@ export function kubeClientSettingsProvideDefaults(val: KubeClientSettings): Kube }; } -export namespace mod1 { -} +export * as mod1 from "./mod1"; -export namespace mod2 { -} +export * as mod2 from "./mod2"; diff --git a/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/codegen-manifest.json b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/codegen-manifest.json index b3e8bd48b335..dbddbd48ce95 100644 --- a/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/codegen-manifest.json +++ b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/codegen-manifest.json @@ -11,6 +11,12 @@ "tsconfig.json", "types/index.ts", "types/input.ts", + "types/mod1/index.ts", + "types/mod1/input.ts", + "types/mod1/output.ts", + "types/mod2/index.ts", + "types/mod2/input.ts", + "types/mod2/output.ts", "types/output.ts", "utilities.ts" ] diff --git a/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/tsconfig.json index 9ed19d14809e..59d7de2a223a 100644 --- a/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/tsconfig.json @@ -20,6 +20,12 @@ "provider.ts", "types/index.ts", "types/input.ts", + "types/mod1/index.ts", + "types/mod1/input.ts", + "types/mod1/output.ts", + "types/mod2/index.ts", + "types/mod2/input.ts", + "types/mod2/output.ts", "types/output.ts", "utilities.ts" ] diff --git a/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/input.ts index e127fd599940..b921cb21ffc8 100644 --- a/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/input.ts @@ -4,7 +4,6 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; - import * as utilities from "../utilities"; /** @@ -146,40 +145,6 @@ export function typArgsProvideDefaults(val: TypArgs): TypArgs { val: (val.val) ?? "mod main", }; } -export namespace mod1 { - /** - * A test for namespaces (mod 1) - */ - export interface TypArgs { - val?: pulumi.Input; - } - /** - * typArgsProvideDefaults sets the appropriate defaults for TypArgs - */ - export function typArgsProvideDefaults(val: TypArgs): TypArgs { - return { - ...val, - val: (val.val) ?? "mod1", - }; - } -} +export * as mod1 from "./mod1"; -export namespace mod2 { - /** - * A test for namespaces (mod 2) - */ - export interface TypArgs { - mod1?: pulumi.Input; - val?: pulumi.Input; - } - /** - * typArgsProvideDefaults sets the appropriate defaults for TypArgs - */ - export function typArgsProvideDefaults(val: TypArgs): TypArgs { - return { - ...val, - mod1: (val.mod1 ? pulumi.output(val.mod1).apply(inputs.mod1.typArgsProvideDefaults) : undefined), - val: (val.val) ?? "mod2", - }; - } -} +export * as mod2 from "./mod2"; diff --git a/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod1/index.ts b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod1/index.ts new file mode 100644 index 000000000000..38514e5494d6 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod1/index.ts @@ -0,0 +1,5 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +export * from "./input"; +export * from "./output"; diff --git a/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod1/input.ts b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod1/input.ts new file mode 100644 index 000000000000..effc6a0be847 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod1/input.ts @@ -0,0 +1,23 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +import * as pulumi from "@pulumi/pulumi"; +import * as inputs from "../../types/input"; +import * as outputs from "../../types/output"; +import * as utilities from "../../utilities"; + +/** + * A test for namespaces (mod 1) + */ +export interface TypArgs { + val?: pulumi.Input; +} +/** + * typArgsProvideDefaults sets the appropriate defaults for TypArgs + */ +export function typArgsProvideDefaults(val: TypArgs): TypArgs { + return { + ...val, + val: (val.val) ?? "mod1", + }; +} diff --git a/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod1/output.ts b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod1/output.ts new file mode 100644 index 000000000000..e0c860f46c12 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod1/output.ts @@ -0,0 +1,8 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +import * as pulumi from "@pulumi/pulumi"; +import * as inputs from "../../types/input"; +import * as outputs from "../../types/output"; +import * as utilities from "../../utilities"; + diff --git a/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod2/index.ts b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod2/index.ts new file mode 100644 index 000000000000..38514e5494d6 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod2/index.ts @@ -0,0 +1,5 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +export * from "./input"; +export * from "./output"; diff --git a/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod2/input.ts b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod2/input.ts new file mode 100644 index 000000000000..0b64bcae655a --- /dev/null +++ b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod2/input.ts @@ -0,0 +1,25 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +import * as pulumi from "@pulumi/pulumi"; +import * as inputs from "../../types/input"; +import * as outputs from "../../types/output"; +import * as utilities from "../../utilities"; + +/** + * A test for namespaces (mod 2) + */ +export interface TypArgs { + mod1?: pulumi.Input; + val?: pulumi.Input; +} +/** + * typArgsProvideDefaults sets the appropriate defaults for TypArgs + */ +export function typArgsProvideDefaults(val: TypArgs): TypArgs { + return { + ...val, + mod1: (val.mod1 ? pulumi.output(val.mod1).apply(inputs.mod1.typArgsProvideDefaults) : undefined), + val: (val.val) ?? "mod2", + }; +} diff --git a/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod2/output.ts b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod2/output.ts new file mode 100644 index 000000000000..e0c860f46c12 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod2/output.ts @@ -0,0 +1,8 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +import * as pulumi from "@pulumi/pulumi"; +import * as inputs from "../../types/input"; +import * as outputs from "../../types/output"; +import * as utilities from "../../utilities"; + diff --git a/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/output.ts index dc79a613d6d5..d105f0cd511d 100644 --- a/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/output.ts @@ -4,7 +4,6 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; - import * as utilities from "../utilities"; /** @@ -33,8 +32,6 @@ export function kubeClientSettingsProvideDefaults(val: KubeClientSettings): Kube }; } -export namespace mod1 { -} +export * as mod1 from "./mod1"; -export namespace mod2 { -} +export * as mod2 from "./mod2"; diff --git a/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/codegen-manifest.json b/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/codegen-manifest.json index ee4317032e08..d0d1a142860e 100644 --- a/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/codegen-manifest.json +++ b/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/codegen-manifest.json @@ -9,6 +9,9 @@ "provider.ts", "scripts/install-pulumi-plugin.js", "tsconfig.json", + "types/config/index.ts", + "types/config/input.ts", + "types/config/output.ts", "types/enums/index.ts", "types/index.ts", "types/input.ts", diff --git a/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/tsconfig.json index 016bd0182259..788808e643db 100644 --- a/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/tsconfig.json @@ -18,6 +18,9 @@ "funcWithAllOptionalInputs.ts", "index.ts", "provider.ts", + "types/config/index.ts", + "types/config/input.ts", + "types/config/output.ts", "types/enums/index.ts", "types/index.ts", "types/input.ts", diff --git a/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/config/index.ts b/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/config/index.ts new file mode 100644 index 000000000000..38514e5494d6 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/config/index.ts @@ -0,0 +1,5 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +export * from "./input"; +export * from "./output"; diff --git a/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/config/input.ts b/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/config/input.ts new file mode 100644 index 000000000000..3fd1c4e5dae1 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/config/input.ts @@ -0,0 +1,9 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +import * as pulumi from "@pulumi/pulumi"; +import * as inputs from "../../types/input"; +import * as outputs from "../../types/output"; +import * as enums from "../../types/enums"; +import * as utilities from "../../utilities"; + diff --git a/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/config/output.ts b/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/config/output.ts new file mode 100644 index 000000000000..69a6e8b1b030 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/config/output.ts @@ -0,0 +1,14 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +import * as pulumi from "@pulumi/pulumi"; +import * as inputs from "../../types/input"; +import * as outputs from "../../types/output"; +import * as enums from "../../types/enums"; +import * as utilities from "../../utilities"; + +export interface Sandwich { + bread?: string; + veggies?: string[]; +} + diff --git a/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/input.ts index a43cbaa66807..bcc09cf19d72 100644 --- a/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/input.ts @@ -5,6 +5,6 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; import * as enums from "../types/enums"; +import * as utilities from "../utilities"; -export namespace config { -} +export * as config from "./config"; diff --git a/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/output.ts index 80f20da1edf0..8f4da74f3123 100644 --- a/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/output.ts @@ -5,16 +5,11 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; import * as enums from "../types/enums"; +import * as utilities from "../utilities"; export interface Child { age?: number; name?: string; } -export namespace config { - export interface Sandwich { - bread?: string; - veggies?: string[]; - } - -} +export * as config from "./config"; diff --git a/pkg/codegen/testing/test/testdata/regress-8403/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/regress-8403/nodejs/types/input.ts index a277306fc819..efe5fda0c738 100644 --- a/pkg/codegen/testing/test/testdata/regress-8403/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/regress-8403/nodejs/types/input.ts @@ -4,4 +4,5 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; +import * as utilities from "../utilities"; diff --git a/pkg/codegen/testing/test/testdata/regress-8403/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/regress-8403/nodejs/types/output.ts index 7990bed12f46..7eac2cbfeb91 100644 --- a/pkg/codegen/testing/test/testdata/regress-8403/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/regress-8403/nodejs/types/output.ts @@ -4,6 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; +import * as utilities from "../utilities"; export interface GetCustomDbRolesResult { } diff --git a/pkg/codegen/testing/test/testdata/regress-node-8110/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/regress-node-8110/nodejs/types/input.ts index 176b5ce13afe..b9997a16405a 100644 --- a/pkg/codegen/testing/test/testdata/regress-node-8110/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/regress-node-8110/nodejs/types/input.ts @@ -5,4 +5,5 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; import * as enums from "../types/enums"; +import * as utilities from "../utilities"; diff --git a/pkg/codegen/testing/test/testdata/regress-node-8110/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/regress-node-8110/nodejs/types/output.ts index 176b5ce13afe..b9997a16405a 100644 --- a/pkg/codegen/testing/test/testdata/regress-node-8110/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/regress-node-8110/nodejs/types/output.ts @@ -5,4 +5,5 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; import * as enums from "../types/enums"; +import * as utilities from "../utilities"; diff --git a/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/types/input.ts index 2712424d1c1a..6966d245b39d 100644 --- a/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/types/input.ts @@ -4,6 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; +import * as utilities from "../utilities"; import {Cat, Dog} from ".."; diff --git a/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/types/output.ts index f77f44dd45f3..273422fbe3a2 100644 --- a/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/types/output.ts @@ -4,6 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; +import * as utilities from "../utilities"; import {Cat, Dog} from ".."; diff --git a/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/codegen-manifest.json b/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/codegen-manifest.json index 8551e38dfec7..55f5e9b24910 100644 --- a/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/codegen-manifest.json +++ b/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/codegen-manifest.json @@ -10,6 +10,9 @@ "tsconfig.json", "types/index.ts", "types/input.ts", + "types/nested/index.ts", + "types/nested/input.ts", + "types/nested/output.ts", "types/output.ts", "utilities.ts" ] diff --git a/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/tsconfig.json index 0ccbcc941419..92462c9bac74 100644 --- a/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/tsconfig.json @@ -19,6 +19,9 @@ "provider.ts", "types/index.ts", "types/input.ts", + "types/nested/index.ts", + "types/nested/input.ts", + "types/nested/output.ts", "types/output.ts", "utilities.ts" ] diff --git a/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/input.ts index 5b9eb68ed95b..ff187ea5a197 100644 --- a/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/input.ts @@ -5,14 +5,4 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; -export namespace nested { - export interface Baz { - hello?: string; - world?: string; - } - - export interface BazArgs { - hello?: pulumi.Input; - world?: pulumi.Input; - } -} +export * as nested from "./nested"; diff --git a/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/nested/index.ts b/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/nested/index.ts new file mode 100644 index 000000000000..38514e5494d6 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/nested/index.ts @@ -0,0 +1,5 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +export * from "./input"; +export * from "./output"; diff --git a/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/nested/input.ts b/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/nested/input.ts new file mode 100644 index 000000000000..5bf1070627fb --- /dev/null +++ b/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/nested/input.ts @@ -0,0 +1,16 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +import * as pulumi from "@pulumi/pulumi"; +import * as inputs from "../../types/input"; +import * as outputs from "../../types/output"; + +export interface Baz { + hello?: string; + world?: string; +} + +export interface BazArgs { + hello?: pulumi.Input; + world?: pulumi.Input; +} diff --git a/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/nested/output.ts b/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/nested/output.ts new file mode 100644 index 000000000000..e8e567507ec0 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/nested/output.ts @@ -0,0 +1,7 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +import * as pulumi from "@pulumi/pulumi"; +import * as inputs from "../../types/input"; +import * as outputs from "../../types/output"; + diff --git a/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/output.ts index c2c4ef2f51ae..ff187ea5a197 100644 --- a/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/output.ts @@ -5,5 +5,4 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; -export namespace nested { -} +export * as nested from "./nested"; diff --git a/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/types/input.ts index dec6c211cb5b..774b7916ca54 100644 --- a/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/types/input.ts @@ -5,6 +5,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; import * as enums from "../types/enums"; +import * as utilities from "../utilities"; import {Resource} from ".."; diff --git a/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/types/output.ts index 6a2c459d4f55..06d28a71e5cc 100644 --- a/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/types/output.ts @@ -5,6 +5,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; import * as enums from "../types/enums"; +import * as utilities from "../utilities"; import {Resource} from ".."; From 4c9735c67f832a8aefa0106c55793fc021323614 Mon Sep 17 00:00:00 2001 From: Robbie McKinstry Date: Fri, 14 Oct 2022 22:09:03 -0400 Subject: [PATCH 03/16] Prevent collision in type decl --- pkg/codegen/nodejs/gen.go | 9 ++++++--- .../testdata/plain-object-defaults/nodejs/types/input.ts | 2 -- .../plain-object-defaults/nodejs/types/mod1/index.ts | 4 ++-- .../plain-object-defaults/nodejs/types/mod2/index.ts | 4 ++-- .../plain-object-defaults/nodejs/types/output.ts | 2 -- .../plain-object-disable-defaults/nodejs/types/input.ts | 2 -- .../nodejs/types/mod1/index.ts | 4 ++-- .../nodejs/types/mod2/index.ts | 4 ++-- .../plain-object-disable-defaults/nodejs/types/output.ts | 2 -- .../provider-config-schema/nodejs/types/config/index.ts | 4 ++-- .../provider-config-schema/nodejs/types/input.ts | 1 - .../provider-config-schema/nodejs/types/output.ts | 1 - 12 files changed, 16 insertions(+), 23 deletions(-) diff --git a/pkg/codegen/nodejs/gen.go b/pkg/codegen/nodejs/gen.go index 11c525d90790..73a054cd89e2 100644 --- a/pkg/codegen/nodejs/gen.go +++ b/pkg/codegen/nodejs/gen.go @@ -1712,11 +1712,14 @@ func (ns *namespace) intoIOFiles(ctx *ioContext, parent string) ([]*ioFile, erro // Declare a new file to store the contents exposed at this directory level. var dirRoot = path.Join(parent, ns.name) + // var filename, fileType string var filename string if ctx.input { filename = path.Join(dirRoot, "input.ts") + // fileType = "input" } else { filename = path.Join(dirRoot, "output.ts") + // fileType = "output" } var file = newIOFile(filename) // We start every file with the header information. @@ -1762,7 +1765,7 @@ func (ns *namespace) intoIOFiles(ctx *ioContext, parent string) ([]*ioFile, erro } // At this level, we export any nested definitions from // the next level. - fmt.Fprintf(file.writer(), "export * as %s from \"./%s\";\n", child.name, child.name) + // fmt.Fprintf(file.writer(), "export * as %s from \"./%s/%s\";\n", child.name, child.name, fileType) nestedFiles, err := child.intoIOFiles(ctx, dirRoot) if err != nil { return nil, err @@ -1784,8 +1787,8 @@ func (ns *namespace) intoIOFiles(ctx *ioContext, parent string) ([]*ioFile, erro var indexPath = path.Join(dirRoot, "index.ts") var file = newIOFile(indexPath) ctx.mod.genHeader(file.writer(), nil, nil, nil) - fmt.Fprintf(file.writer(), "export * from \"./%s\";\n", "input") - fmt.Fprintf(file.writer(), "export * from \"./%s\";\n", "output") + fmt.Fprintf(file.writer(), "export * as inputs from \"./%s\";\n", "input") + fmt.Fprintf(file.writer(), "export * as outputs from \"./%s\";\n", "output") files = append(files, file) } diff --git a/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/input.ts index b921cb21ffc8..4d4bab916402 100644 --- a/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/input.ts @@ -145,6 +145,4 @@ export function typArgsProvideDefaults(val: TypArgs): TypArgs { val: (val.val) ?? "mod main", }; } -export * as mod1 from "./mod1"; -export * as mod2 from "./mod2"; diff --git a/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod1/index.ts b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod1/index.ts index 38514e5494d6..8e76b76a890d 100644 --- a/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod1/index.ts +++ b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod1/index.ts @@ -1,5 +1,5 @@ // *** WARNING: this file was generated by test. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** -export * from "./input"; -export * from "./output"; +export * as inputs from "./input"; +export * as outputs from "./output"; diff --git a/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod2/index.ts b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod2/index.ts index 38514e5494d6..8e76b76a890d 100644 --- a/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod2/index.ts +++ b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod2/index.ts @@ -1,5 +1,5 @@ // *** WARNING: this file was generated by test. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** -export * from "./input"; -export * from "./output"; +export * as inputs from "./input"; +export * as outputs from "./output"; diff --git a/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/output.ts index d105f0cd511d..542d4ca8ed1d 100644 --- a/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/output.ts @@ -32,6 +32,4 @@ export function kubeClientSettingsProvideDefaults(val: KubeClientSettings): Kube }; } -export * as mod1 from "./mod1"; -export * as mod2 from "./mod2"; diff --git a/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/input.ts index b921cb21ffc8..4d4bab916402 100644 --- a/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/input.ts @@ -145,6 +145,4 @@ export function typArgsProvideDefaults(val: TypArgs): TypArgs { val: (val.val) ?? "mod main", }; } -export * as mod1 from "./mod1"; -export * as mod2 from "./mod2"; diff --git a/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod1/index.ts b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod1/index.ts index 38514e5494d6..8e76b76a890d 100644 --- a/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod1/index.ts +++ b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod1/index.ts @@ -1,5 +1,5 @@ // *** WARNING: this file was generated by test. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** -export * from "./input"; -export * from "./output"; +export * as inputs from "./input"; +export * as outputs from "./output"; diff --git a/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod2/index.ts b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod2/index.ts index 38514e5494d6..8e76b76a890d 100644 --- a/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod2/index.ts +++ b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod2/index.ts @@ -1,5 +1,5 @@ // *** WARNING: this file was generated by test. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** -export * from "./input"; -export * from "./output"; +export * as inputs from "./input"; +export * as outputs from "./output"; diff --git a/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/output.ts index d105f0cd511d..542d4ca8ed1d 100644 --- a/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/output.ts @@ -32,6 +32,4 @@ export function kubeClientSettingsProvideDefaults(val: KubeClientSettings): Kube }; } -export * as mod1 from "./mod1"; -export * as mod2 from "./mod2"; diff --git a/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/config/index.ts b/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/config/index.ts index 38514e5494d6..8e76b76a890d 100644 --- a/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/config/index.ts +++ b/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/config/index.ts @@ -1,5 +1,5 @@ // *** WARNING: this file was generated by test. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** -export * from "./input"; -export * from "./output"; +export * as inputs from "./input"; +export * as outputs from "./output"; diff --git a/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/input.ts index bcc09cf19d72..b9997a16405a 100644 --- a/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/input.ts @@ -7,4 +7,3 @@ import * as outputs from "../types/output"; import * as enums from "../types/enums"; import * as utilities from "../utilities"; -export * as config from "./config"; diff --git a/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/output.ts index 8f4da74f3123..a182083e17ed 100644 --- a/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/output.ts @@ -12,4 +12,3 @@ export interface Child { name?: string; } -export * as config from "./config"; From dc082aa27381fe5d7f0e715175979b88a27f34d0 Mon Sep 17 00:00:00 2001 From: Robbie McKinstry Date: Mon, 17 Oct 2022 18:46:28 -0400 Subject: [PATCH 04/16] Fix namespace nesting. --- pkg/codegen/nodejs/gen.go | 150 +++++++++++++----- .../nodejs/types/input.ts | 3 +- .../nodejs/types/mod1/index.ts | 4 +- .../nodejs/types/mod2/index.ts | 4 +- .../nodejs/types/output.ts | 3 +- .../nodejs/types/input.ts | 3 +- .../nodejs/types/mod1/index.ts | 4 +- .../nodejs/types/mod2/index.ts | 4 +- .../nodejs/types/output.ts | 3 +- .../nodejs/types/config/index.ts | 4 +- .../nodejs/types/input.ts | 1 + .../nodejs/types/output.ts | 1 + 12 files changed, 127 insertions(+), 57 deletions(-) diff --git a/pkg/codegen/nodejs/gen.go b/pkg/codegen/nodejs/gen.go index 73a054cd89e2..45c219112d06 100644 --- a/pkg/codegen/nodejs/gen.go +++ b/pkg/codegen/nodejs/gen.go @@ -1697,6 +1697,21 @@ type ioContext struct { externalImports codegen.StringSet } +// filename returns the unique name of the input/output file +// given a directory root. +func (ctx *ioContext) filename(dirRoot string) string { + var fname = fmt.Sprintf("%s.ts", ctx.filetype()) + return path.Join(dirRoot, fname) +} + +func (ctx *ioContext) filetype() string { + if ctx.input { + return "input" + } else { + return "output" + } +} + // intoIOFiles converts this namespace into one or more files. // It recursively builds one file for each node in the tree. // If input=true, then it builds input types. Otherwise, it @@ -1710,18 +1725,60 @@ func (ns *namespace) intoIOFiles(ctx *ioContext, parent string) ([]*ioFile, erro return nil, fmt.Errorf("Generating IO files for a nil namespace") } + // We want to organize the items in the source file by alphabetical order. + // Before we go any further, sort the items so downstream calls don't have to. + ns.sortItems() + // Declare a new file to store the contents exposed at this directory level. var dirRoot = path.Join(parent, ns.name) - // var filename, fileType string - var filename string - if ctx.input { - filename = path.Join(dirRoot, "input.ts") - // fileType = "input" - } else { - filename = path.Join(dirRoot, "output.ts") - // fileType = "output" + var file, err = ns.genOwnedTypes(ctx, dirRoot) + if err != nil { + return nil, err + } + var files = []*ioFile{file} + + // We have successfully written all types at this level to + // input.ts/output.ts. + // Next, we want to recurse to the next directory level. + // We also need to write the index.file at this level (only once), + // and when we do, we need to re-export the items subdirectories. + children, err := ns.genNestedTypes(ctx, dirRoot) + if err != nil { + return files, err } - var file = newIOFile(filename) + files = append(files, children...) + // Lastly, we write the index file for this directory once. + // We don't want to generate the file twice, when this function is called + // with input=true and again when input=false, so we only generate it + // when input=true. + // As a special case, we skip the top-level directory /types/, since that + // is written elsewhere. + if parent != "./types" && ctx.input { + var indexFile = ns.genIndexFile(ctx, dirRoot) + files = append(files, indexFile) + } + return files, nil +} + +// sortItems will sort each of the internal slices of this object. +func (ns *namespace) sortItems() { + sort.Slice(ns.types, func(i, j int) bool { + return tokenToName(ns.types[i].Token) < tokenToName(ns.types[j].Token) + }) + sort.Slice(ns.enums, func(i, j int) bool { + return tokenToName(ns.enums[i].Token) < tokenToName(ns.enums[j].Token) + }) + sort.Slice(ns.children, func(i, j int) bool { + return ns.children[i].name < ns.children[j].name + }) +} + +// genOwnedTypes generates the types for the file in the current context. +// The file is unique to the ioContext (either input/output) and the current +// directory (dirRoot). It skips over types that are neither input nor output types. +func (ns *namespace) genOwnedTypes(ctx *ioContext, dirRoot string) (*ioFile, error) { + // file is either an input file or an output file. + var file = newIOFile(ctx.filename(dirRoot)) // We start every file with the header information. ctx.mod.genHeader( file.writer(), @@ -1729,35 +1786,40 @@ func (ns *namespace) intoIOFiles(ctx *ioContext, parent string) ([]*ioFile, erro ctx.externalImports, ctx.imports, ) - // We want to organize the items in the source file by alphabetical order. - sort.Slice(ns.types, func(i, j int) bool { - return tokenToName(ns.types[i].Token) < tokenToName(ns.types[j].Token) - }) - sort.Slice(ns.enums, func(i, j int) bool { - return tokenToName(ns.enums[i].Token) < tokenToName(ns.enums[j].Token) - }) + // Next, we recursively export the nested types at each subdirectory. + for _, child := range ns.children { + // Defensive coding: child should never be null, but + // child.intoIOFiles will break if it is. + if child == nil { + continue + } + fmt.Fprintf(file.writer(), "export * as %[1]s from \"./%[1]s/%[2]s\";\n", child.name, ctx.filetype()) + } + // Now, we write out the types declared at this directory // level to the file. - var files = []*ioFile{file} for i, t := range ns.types { var isInputType = ctx.input && ctx.mod.details(t).inputType var isOutputType = !ctx.input && ctx.mod.details(t).outputType // Only write input and output types. if isInputType || isOutputType { if err := ctx.mod.genType(file.writer(), t, ctx.input, 0); err != nil { - return files, err + return file, err } if i != len(ns.types)-1 { fmt.Fprintf(file.writer(), "\n") } } } - // We have successfully written all types at this level. - // Next, we recurse to generate the files at the next directory level. - sort.Slice(ns.children, func(i, j int) bool { - return ns.children[i].name < ns.children[j].name - }) - for i, child := range ns.children { + return file, nil +} + +// genNestedTypes will recurse to child namespaces and generate those files. +// It will also generate the index file for this namespace, re-exporting +// identifiers in child namespaces as they are created. +func (ns *namespace) genNestedTypes(ctx *ioContext, dirRoot string) ([]*ioFile, error) { + var files []*ioFile + for _, child := range ns.children { // Defensive coding: child should never be null, but // child.intoIOFiles will break if it is. if child == nil { @@ -1765,34 +1827,36 @@ func (ns *namespace) intoIOFiles(ctx *ioContext, parent string) ([]*ioFile, erro } // At this level, we export any nested definitions from // the next level. - // fmt.Fprintf(file.writer(), "export * as %s from \"./%s/%s\";\n", child.name, child.name, fileType) nestedFiles, err := child.intoIOFiles(ctx, dirRoot) if err != nil { return nil, err } - if i != len(ns.children)-1 { - fmt.Fprintf(file.writer(), "\n") - } // Collect these files to return. files = append(files, nestedFiles...) } + return files, nil +} - // Lastly, we write the index file for this directory once. - // We don't want to generate the file twice, when this function is called - // with input=true and again when input=false, so we only generate it - // when input=true. - // As a special case, we skip the top-level directory /types/, since that - // is written elsewhere. - if parent != "./types" && ctx.input { - var indexPath = path.Join(dirRoot, "index.ts") - var file = newIOFile(indexPath) - ctx.mod.genHeader(file.writer(), nil, nil, nil) - fmt.Fprintf(file.writer(), "export * as inputs from \"./%s\";\n", "input") - fmt.Fprintf(file.writer(), "export * as outputs from \"./%s\";\n", "output") - files = append(files, file) +// genIndexTypes generates an index.ts file for this directory. It must be called +// only once. It exports the files defined at this level in input.ts and output.ts, +// and it exposes the types in all submodules one level down. +func (ns *namespace) genIndexFile(ctx *ioContext, dirRoot string) *ioFile { + var indexPath = path.Join(dirRoot, "index.ts") + var file = newIOFile(indexPath) + ctx.mod.genHeader(file.writer(), nil, nil, nil) + // Export the types defined at the current level. + fmt.Fprintf(file.writer(), "export * from \"./input\";\n") + fmt.Fprintf(file.writer(), "export * from \"./output\";\n") + // Now, recursively export the items in each submodule. + for _, child := range ns.children { + // Defensive coding: child should never be null, but + // child.intoIOFiles will break if it is. + if child == nil { + continue + } + fmt.Fprintf(file.writer(), "export * as %[1]s from \"./%[1]s\";\n", child.name) } - - return files, nil + return file } // An ioFile represents a file containing Input/Output type definitions. diff --git a/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/input.ts index 4d4bab916402..71ffc546be27 100644 --- a/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/input.ts @@ -6,6 +6,8 @@ import * as inputs from "../types/input"; import * as outputs from "../types/output"; import * as utilities from "../utilities"; +export * as mod1 from "./mod1/input"; +export * as mod2 from "./mod2/input"; /** * BETA FEATURE - Options to configure the Helm Release resource. */ @@ -145,4 +147,3 @@ export function typArgsProvideDefaults(val: TypArgs): TypArgs { val: (val.val) ?? "mod main", }; } - diff --git a/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod1/index.ts b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod1/index.ts index 8e76b76a890d..38514e5494d6 100644 --- a/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod1/index.ts +++ b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod1/index.ts @@ -1,5 +1,5 @@ // *** WARNING: this file was generated by test. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** -export * as inputs from "./input"; -export * as outputs from "./output"; +export * from "./input"; +export * from "./output"; diff --git a/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod2/index.ts b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod2/index.ts index 8e76b76a890d..38514e5494d6 100644 --- a/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod2/index.ts +++ b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod2/index.ts @@ -1,5 +1,5 @@ // *** WARNING: this file was generated by test. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** -export * as inputs from "./input"; -export * as outputs from "./output"; +export * from "./input"; +export * from "./output"; diff --git a/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/output.ts index 542d4ca8ed1d..92e2a23376b2 100644 --- a/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/output.ts @@ -6,6 +6,8 @@ import * as inputs from "../types/input"; import * as outputs from "../types/output"; import * as utilities from "../utilities"; +export * as mod1 from "./mod1/output"; +export * as mod2 from "./mod2/output"; /** * Options for tuning the Kubernetes client used by a Provider. */ @@ -32,4 +34,3 @@ export function kubeClientSettingsProvideDefaults(val: KubeClientSettings): Kube }; } - diff --git a/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/input.ts index 4d4bab916402..71ffc546be27 100644 --- a/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/input.ts @@ -6,6 +6,8 @@ import * as inputs from "../types/input"; import * as outputs from "../types/output"; import * as utilities from "../utilities"; +export * as mod1 from "./mod1/input"; +export * as mod2 from "./mod2/input"; /** * BETA FEATURE - Options to configure the Helm Release resource. */ @@ -145,4 +147,3 @@ export function typArgsProvideDefaults(val: TypArgs): TypArgs { val: (val.val) ?? "mod main", }; } - diff --git a/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod1/index.ts b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod1/index.ts index 8e76b76a890d..38514e5494d6 100644 --- a/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod1/index.ts +++ b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod1/index.ts @@ -1,5 +1,5 @@ // *** WARNING: this file was generated by test. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** -export * as inputs from "./input"; -export * as outputs from "./output"; +export * from "./input"; +export * from "./output"; diff --git a/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod2/index.ts b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod2/index.ts index 8e76b76a890d..38514e5494d6 100644 --- a/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod2/index.ts +++ b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod2/index.ts @@ -1,5 +1,5 @@ // *** WARNING: this file was generated by test. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** -export * as inputs from "./input"; -export * as outputs from "./output"; +export * from "./input"; +export * from "./output"; diff --git a/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/output.ts index 542d4ca8ed1d..92e2a23376b2 100644 --- a/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/output.ts @@ -6,6 +6,8 @@ import * as inputs from "../types/input"; import * as outputs from "../types/output"; import * as utilities from "../utilities"; +export * as mod1 from "./mod1/output"; +export * as mod2 from "./mod2/output"; /** * Options for tuning the Kubernetes client used by a Provider. */ @@ -32,4 +34,3 @@ export function kubeClientSettingsProvideDefaults(val: KubeClientSettings): Kube }; } - diff --git a/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/config/index.ts b/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/config/index.ts index 8e76b76a890d..38514e5494d6 100644 --- a/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/config/index.ts +++ b/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/config/index.ts @@ -1,5 +1,5 @@ // *** WARNING: this file was generated by test. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** -export * as inputs from "./input"; -export * as outputs from "./output"; +export * from "./input"; +export * from "./output"; diff --git a/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/input.ts index b9997a16405a..6ff6d05d3e97 100644 --- a/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/input.ts @@ -7,3 +7,4 @@ import * as outputs from "../types/output"; import * as enums from "../types/enums"; import * as utilities from "../utilities"; +export * as config from "./config/input"; diff --git a/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/output.ts index a182083e17ed..23ef29cbdef0 100644 --- a/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/output.ts @@ -7,6 +7,7 @@ import * as outputs from "../types/output"; import * as enums from "../types/enums"; import * as utilities from "../utilities"; +export * as config from "./config/output"; export interface Child { age?: number; name?: string; From d3acb484ff98d8835e3dbfccaf111bbae2482a0f Mon Sep 17 00:00:00 2001 From: Robbie McKinstry Date: Mon, 17 Oct 2022 19:08:16 -0400 Subject: [PATCH 05/16] Split writes across files --- pkg/codegen/nodejs/gen.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/pkg/codegen/nodejs/gen.go b/pkg/codegen/nodejs/gen.go index 45c219112d06..4915b0623d24 100644 --- a/pkg/codegen/nodejs/gen.go +++ b/pkg/codegen/nodejs/gen.go @@ -1650,7 +1650,7 @@ func (mod *modContext) genTypes() ([]*ioFile, error) { // If there are no namespaces, then we generate empty // input and output files. if namespaces[""] == nil { - return nil, fmt.Errorf("Encountered a nil top-level namespace. The top-level namespace cannot be nil, even if it is empty.") + return nil, fmt.Errorf("encountered a nil top-level namespace, and namespaces can't be nil even if it is empty") } // Iterate through the namespaces, generating one per node in the tree. if inputFiles, err = namespaces[""].intoIOFiles(inputCtx, "./types"); err != nil { @@ -1707,9 +1707,8 @@ func (ctx *ioContext) filename(dirRoot string) string { func (ctx *ioContext) filetype() string { if ctx.input { return "input" - } else { - return "output" } + return "output" } // intoIOFiles converts this namespace into one or more files. @@ -1802,14 +1801,18 @@ func (ns *namespace) genOwnedTypes(ctx *ioContext, dirRoot string) (*ioFile, err var isInputType = ctx.input && ctx.mod.details(t).inputType var isOutputType = !ctx.input && ctx.mod.details(t).outputType // Only write input and output types. - if isInputType || isOutputType { + if isInputType { if err := ctx.mod.genType(file.writer(), t, ctx.input, 0); err != nil { return file, err } - if i != len(ns.types)-1 { - fmt.Fprintf(file.writer(), "\n") + } else if isOutputType { + if err := ctx.mod.genType(file.writer(), t, ctx.input, 0); err != nil { + return file, err } } + if i != len(ns.types)-1 && (isInputType || isOutputType) { + fmt.Fprintf(file.writer(), "\n") + } } return file, nil } @@ -2180,7 +2183,7 @@ func (mod *modContext) gen(fs codegen.Fs) error { return err } for _, file := range files { - fs.Add(file.name(), []byte(file.contents())) + fs.Add(file.name(), file.contents()) } } From 4de553d1168c756dfc3e9fa32b16f16457a8b6a1 Mon Sep 17 00:00:00 2001 From: Robbie McKinstry Date: Mon, 17 Oct 2022 19:24:31 -0400 Subject: [PATCH 06/16] Revert change about splitting type writing --- pkg/codegen/nodejs/gen.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/pkg/codegen/nodejs/gen.go b/pkg/codegen/nodejs/gen.go index 4915b0623d24..00b80a64368a 100644 --- a/pkg/codegen/nodejs/gen.go +++ b/pkg/codegen/nodejs/gen.go @@ -1801,18 +1801,14 @@ func (ns *namespace) genOwnedTypes(ctx *ioContext, dirRoot string) (*ioFile, err var isInputType = ctx.input && ctx.mod.details(t).inputType var isOutputType = !ctx.input && ctx.mod.details(t).outputType // Only write input and output types. - if isInputType { + if isInputType || isOutputType { if err := ctx.mod.genType(file.writer(), t, ctx.input, 0); err != nil { return file, err } - } else if isOutputType { - if err := ctx.mod.genType(file.writer(), t, ctx.input, 0); err != nil { - return file, err + if i != len(ns.types)-1 && (isInputType || isOutputType) { + fmt.Fprintf(file.writer(), "\n") } } - if i != len(ns.types)-1 && (isInputType || isOutputType) { - fmt.Fprintf(file.writer(), "\n") - } } return file, nil } From 4c9075c3f6f25f76aa12ef4a4f5f78fee7bb03e4 Mon Sep 17 00:00:00 2001 From: Robbie McKinstry Date: Mon, 17 Oct 2022 19:25:04 -0400 Subject: [PATCH 07/16] Remove unnecessary boolean guard --- pkg/codegen/nodejs/gen.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/codegen/nodejs/gen.go b/pkg/codegen/nodejs/gen.go index 00b80a64368a..9f547e82fa4b 100644 --- a/pkg/codegen/nodejs/gen.go +++ b/pkg/codegen/nodejs/gen.go @@ -1805,7 +1805,7 @@ func (ns *namespace) genOwnedTypes(ctx *ioContext, dirRoot string) (*ioFile, err if err := ctx.mod.genType(file.writer(), t, ctx.input, 0); err != nil { return file, err } - if i != len(ns.types)-1 && (isInputType || isOutputType) { + if i != len(ns.types)-1 { fmt.Fprintf(file.writer(), "\n") } } From 87b986a7f97c218bbee68984c3b81a466a79787c Mon Sep 17 00:00:00 2001 From: Robbie McKinstry Date: Mon, 17 Oct 2022 20:03:32 -0400 Subject: [PATCH 08/16] Update codegen tests --- pkg/codegen/nodejs/gen_test.go | 2 +- .../azure-native-nested-types/nodejs/types/documentdb/input.ts | 1 + .../nodejs/types/documentdb/output.ts | 1 + .../testdata/azure-native-nested-types/nodejs/types/input.ts | 3 ++- .../testdata/azure-native-nested-types/nodejs/types/output.ts | 3 ++- .../test/testdata/dash-named-schema/nodejs/types/input.ts | 1 + .../test/testdata/dash-named-schema/nodejs/types/output.ts | 1 + .../testing/test/testdata/different-enum/nodejs/types/input.ts | 1 - .../test/testdata/different-enum/nodejs/types/output.ts | 1 - .../testing/test/testdata/external-enum/nodejs/types/input.ts | 1 + .../testing/test/testdata/external-enum/nodejs/types/output.ts | 1 + .../testdata/external-resource-schema/nodejs/types/input.ts | 1 + .../testdata/external-resource-schema/nodejs/types/output.ts | 1 + .../test/testdata/naming-collisions/nodejs/types/input.ts | 1 + .../test/testdata/naming-collisions/nodejs/types/output.ts | 1 + .../test/testdata/plain-schema-gh6957/nodejs/types/input.ts | 1 + .../test/testdata/plain-schema-gh6957/nodejs/types/output.ts | 1 + .../nodejs/types/input.ts | 1 + .../nodejs/types/output.ts | 1 + .../test/testdata/resource-args-python/nodejs/types/input.ts | 1 + .../test/testdata/resource-args-python/nodejs/types/output.ts | 1 + .../testing/test/testdata/secrets/nodejs/types/input.ts | 1 + .../testing/test/testdata/secrets/nodejs/types/output.ts | 1 + .../test/testdata/simple-enum-schema/nodejs/types/input.ts | 1 - .../test/testdata/simple-enum-schema/nodejs/types/output.ts | 1 - .../test/testdata/simple-methods-schema/nodejs/types/input.ts | 3 ++- .../simple-methods-schema/nodejs/types/nested/input.ts | 1 + .../simple-methods-schema/nodejs/types/nested/output.ts | 1 + .../test/testdata/simple-methods-schema/nodejs/types/output.ts | 3 ++- .../nodejs/types/input.ts | 1 + .../nodejs/types/output.ts | 1 + .../test/testdata/simple-plain-schema/nodejs/types/input.ts | 1 + .../test/testdata/simple-plain-schema/nodejs/types/output.ts | 1 + .../nodejs/types/input.ts | 1 + .../nodejs/types/output.ts | 1 + .../test/testdata/simple-resource-schema/nodejs/types/input.ts | 1 + .../testdata/simple-resource-schema/nodejs/types/output.ts | 1 + 37 files changed, 37 insertions(+), 9 deletions(-) diff --git a/pkg/codegen/nodejs/gen_test.go b/pkg/codegen/nodejs/gen_test.go index 35e6878acd87..dc791289f197 100644 --- a/pkg/codegen/nodejs/gen_test.go +++ b/pkg/codegen/nodejs/gen_test.go @@ -283,4 +283,4 @@ func TestGetRelativePath(t *testing.T) { observed, ) } -} \ No newline at end of file +} diff --git a/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/documentdb/input.ts b/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/documentdb/input.ts index e8e567507ec0..e0c860f46c12 100644 --- a/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/documentdb/input.ts +++ b/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/documentdb/input.ts @@ -4,4 +4,5 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../../types/input"; import * as outputs from "../../types/output"; +import * as utilities from "../../utilities"; diff --git a/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/documentdb/output.ts b/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/documentdb/output.ts index 7f74aa6e3685..18446cfc0823 100644 --- a/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/documentdb/output.ts +++ b/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/documentdb/output.ts @@ -4,6 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../../types/input"; import * as outputs from "../../types/output"; +import * as utilities from "../../utilities"; export interface CompositePathResponse { /** diff --git a/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/input.ts index 2f582458b852..7958b126ac7d 100644 --- a/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/input.ts @@ -4,5 +4,6 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; +import * as utilities from "../utilities"; -export * as documentdb from "./documentdb"; +export * as documentdb from "./documentdb/input"; diff --git a/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/output.ts index 2f582458b852..e3a208c41184 100644 --- a/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/output.ts @@ -4,5 +4,6 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; +import * as utilities from "../utilities"; -export * as documentdb from "./documentdb"; +export * as documentdb from "./documentdb/output"; diff --git a/pkg/codegen/testing/test/testdata/dash-named-schema/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/dash-named-schema/nodejs/types/input.ts index 50af1ceddab5..f74a299b5e5f 100644 --- a/pkg/codegen/testing/test/testdata/dash-named-schema/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/dash-named-schema/nodejs/types/input.ts @@ -4,6 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; +import * as utilities from "../utilities"; export interface TopLevelArgs { buzz?: pulumi.Input; diff --git a/pkg/codegen/testing/test/testdata/dash-named-schema/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/dash-named-schema/nodejs/types/output.ts index 7f6f5354ebd6..6f67e6c37c70 100644 --- a/pkg/codegen/testing/test/testdata/dash-named-schema/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/dash-named-schema/nodejs/types/output.ts @@ -4,6 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; +import * as utilities from "../utilities"; export interface TopLevel { buzz?: string; diff --git a/pkg/codegen/testing/test/testdata/different-enum/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/different-enum/nodejs/types/input.ts index 5e35f2f8f160..fcefd058f114 100644 --- a/pkg/codegen/testing/test/testdata/different-enum/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/different-enum/nodejs/types/input.ts @@ -5,7 +5,6 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; import * as enums from "../types/enums"; - import * as utilities from "../utilities"; export interface ContainerArgs { diff --git a/pkg/codegen/testing/test/testdata/different-enum/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/different-enum/nodejs/types/output.ts index a1c27174dff9..2ed273ed9dc5 100644 --- a/pkg/codegen/testing/test/testdata/different-enum/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/different-enum/nodejs/types/output.ts @@ -5,7 +5,6 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; import * as enums from "../types/enums"; - import * as utilities from "../utilities"; export interface Container { diff --git a/pkg/codegen/testing/test/testdata/external-enum/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/external-enum/nodejs/types/input.ts index 176b5ce13afe..b9997a16405a 100644 --- a/pkg/codegen/testing/test/testdata/external-enum/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/external-enum/nodejs/types/input.ts @@ -5,4 +5,5 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; import * as enums from "../types/enums"; +import * as utilities from "../utilities"; diff --git a/pkg/codegen/testing/test/testdata/external-enum/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/external-enum/nodejs/types/output.ts index 176b5ce13afe..b9997a16405a 100644 --- a/pkg/codegen/testing/test/testdata/external-enum/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/external-enum/nodejs/types/output.ts @@ -5,4 +5,5 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; import * as enums from "../types/enums"; +import * as utilities from "../utilities"; diff --git a/pkg/codegen/testing/test/testdata/external-resource-schema/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/external-resource-schema/nodejs/types/input.ts index fccf3e175d96..71da4cf9ccfc 100644 --- a/pkg/codegen/testing/test/testdata/external-resource-schema/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/external-resource-schema/nodejs/types/input.ts @@ -4,6 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; +import * as utilities from "../utilities"; import * as pulumiRandom from "@pulumi/random"; diff --git a/pkg/codegen/testing/test/testdata/external-resource-schema/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/external-resource-schema/nodejs/types/output.ts index 714aa6b393e4..e026d7865101 100644 --- a/pkg/codegen/testing/test/testdata/external-resource-schema/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/external-resource-schema/nodejs/types/output.ts @@ -4,6 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; +import * as utilities from "../utilities"; import * as pulumiRandom from "@pulumi/random"; diff --git a/pkg/codegen/testing/test/testdata/naming-collisions/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/naming-collisions/nodejs/types/input.ts index 176b5ce13afe..b9997a16405a 100644 --- a/pkg/codegen/testing/test/testdata/naming-collisions/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/naming-collisions/nodejs/types/input.ts @@ -5,4 +5,5 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; import * as enums from "../types/enums"; +import * as utilities from "../utilities"; diff --git a/pkg/codegen/testing/test/testdata/naming-collisions/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/naming-collisions/nodejs/types/output.ts index 176b5ce13afe..b9997a16405a 100644 --- a/pkg/codegen/testing/test/testdata/naming-collisions/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/naming-collisions/nodejs/types/output.ts @@ -5,4 +5,5 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; import * as enums from "../types/enums"; +import * as utilities from "../utilities"; diff --git a/pkg/codegen/testing/test/testdata/plain-schema-gh6957/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/plain-schema-gh6957/nodejs/types/input.ts index e88c590f69c5..7aac455e2f8e 100644 --- a/pkg/codegen/testing/test/testdata/plain-schema-gh6957/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/plain-schema-gh6957/nodejs/types/input.ts @@ -4,6 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; +import * as utilities from "../utilities"; export interface FooArgs { a?: pulumi.Input; diff --git a/pkg/codegen/testing/test/testdata/plain-schema-gh6957/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/plain-schema-gh6957/nodejs/types/output.ts index a277306fc819..efe5fda0c738 100644 --- a/pkg/codegen/testing/test/testdata/plain-schema-gh6957/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/plain-schema-gh6957/nodejs/types/output.ts @@ -4,4 +4,5 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; +import * as utilities from "../utilities"; diff --git a/pkg/codegen/testing/test/testdata/resource-args-python-case-insensitive/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/resource-args-python-case-insensitive/nodejs/types/input.ts index 2fdb3ef7bc0a..40b500952cfd 100644 --- a/pkg/codegen/testing/test/testdata/resource-args-python-case-insensitive/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/resource-args-python-case-insensitive/nodejs/types/input.ts @@ -4,6 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; +import * as utilities from "../utilities"; export interface PetArgs { name?: pulumi.Input; diff --git a/pkg/codegen/testing/test/testdata/resource-args-python-case-insensitive/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/resource-args-python-case-insensitive/nodejs/types/output.ts index 64cd2c62ee0d..38a8f8959fb2 100644 --- a/pkg/codegen/testing/test/testdata/resource-args-python-case-insensitive/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/resource-args-python-case-insensitive/nodejs/types/output.ts @@ -4,6 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; +import * as utilities from "../utilities"; export interface Pet { name?: string; diff --git a/pkg/codegen/testing/test/testdata/resource-args-python/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/resource-args-python/nodejs/types/input.ts index 2fdb3ef7bc0a..40b500952cfd 100644 --- a/pkg/codegen/testing/test/testdata/resource-args-python/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/resource-args-python/nodejs/types/input.ts @@ -4,6 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; +import * as utilities from "../utilities"; export interface PetArgs { name?: pulumi.Input; diff --git a/pkg/codegen/testing/test/testdata/resource-args-python/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/resource-args-python/nodejs/types/output.ts index 64cd2c62ee0d..38a8f8959fb2 100644 --- a/pkg/codegen/testing/test/testdata/resource-args-python/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/resource-args-python/nodejs/types/output.ts @@ -4,6 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; +import * as utilities from "../utilities"; export interface Pet { name?: string; diff --git a/pkg/codegen/testing/test/testdata/secrets/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/secrets/nodejs/types/input.ts index 6583cdec830d..f1c57676cf40 100644 --- a/pkg/codegen/testing/test/testdata/secrets/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/secrets/nodejs/types/input.ts @@ -4,6 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; +import * as utilities from "../utilities"; export interface ConfigArgs { foo?: pulumi.Input; diff --git a/pkg/codegen/testing/test/testdata/secrets/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/secrets/nodejs/types/output.ts index a9eb4e5564c9..521c9e74c30a 100644 --- a/pkg/codegen/testing/test/testdata/secrets/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/secrets/nodejs/types/output.ts @@ -4,6 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; +import * as utilities from "../utilities"; export interface Config { foo?: string; diff --git a/pkg/codegen/testing/test/testdata/simple-enum-schema/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/simple-enum-schema/nodejs/types/input.ts index 5e35f2f8f160..fcefd058f114 100644 --- a/pkg/codegen/testing/test/testdata/simple-enum-schema/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/simple-enum-schema/nodejs/types/input.ts @@ -5,7 +5,6 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; import * as enums from "../types/enums"; - import * as utilities from "../utilities"; export interface ContainerArgs { diff --git a/pkg/codegen/testing/test/testdata/simple-enum-schema/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/simple-enum-schema/nodejs/types/output.ts index a1c27174dff9..2ed273ed9dc5 100644 --- a/pkg/codegen/testing/test/testdata/simple-enum-schema/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/simple-enum-schema/nodejs/types/output.ts @@ -5,7 +5,6 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; import * as enums from "../types/enums"; - import * as utilities from "../utilities"; export interface Container { diff --git a/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/input.ts index ff187ea5a197..5be103e5b302 100644 --- a/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/input.ts @@ -4,5 +4,6 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; +import * as utilities from "../utilities"; -export * as nested from "./nested"; +export * as nested from "./nested/input"; diff --git a/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/nested/input.ts b/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/nested/input.ts index 5bf1070627fb..fd6ed5813d91 100644 --- a/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/nested/input.ts +++ b/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/nested/input.ts @@ -4,6 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../../types/input"; import * as outputs from "../../types/output"; +import * as utilities from "../../utilities"; export interface Baz { hello?: string; diff --git a/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/nested/output.ts b/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/nested/output.ts index e8e567507ec0..e0c860f46c12 100644 --- a/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/nested/output.ts +++ b/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/nested/output.ts @@ -4,4 +4,5 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../../types/input"; import * as outputs from "../../types/output"; +import * as utilities from "../../utilities"; diff --git a/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/output.ts index ff187ea5a197..e81e70ff57d7 100644 --- a/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/output.ts @@ -4,5 +4,6 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; +import * as utilities from "../utilities"; -export * as nested from "./nested"; +export * as nested from "./nested/output"; diff --git a/pkg/codegen/testing/test/testdata/simple-plain-schema-with-root-package/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/simple-plain-schema-with-root-package/nodejs/types/input.ts index ec2d4029a3f7..2b2ecb88052e 100644 --- a/pkg/codegen/testing/test/testdata/simple-plain-schema-with-root-package/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/simple-plain-schema-with-root-package/nodejs/types/input.ts @@ -4,6 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; +import * as utilities from "../utilities"; export interface FooArgs { a: boolean; diff --git a/pkg/codegen/testing/test/testdata/simple-plain-schema-with-root-package/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/simple-plain-schema-with-root-package/nodejs/types/output.ts index 00978e1d5e30..9eb73bcc2404 100644 --- a/pkg/codegen/testing/test/testdata/simple-plain-schema-with-root-package/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/simple-plain-schema-with-root-package/nodejs/types/output.ts @@ -4,6 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; +import * as utilities from "../utilities"; export interface Foo { a: boolean; diff --git a/pkg/codegen/testing/test/testdata/simple-plain-schema/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/simple-plain-schema/nodejs/types/input.ts index 6e9b3c0bf494..567775464cc3 100644 --- a/pkg/codegen/testing/test/testdata/simple-plain-schema/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/simple-plain-schema/nodejs/types/input.ts @@ -4,6 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; +import * as utilities from "../utilities"; export interface Foo { a: boolean; diff --git a/pkg/codegen/testing/test/testdata/simple-plain-schema/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/simple-plain-schema/nodejs/types/output.ts index 00978e1d5e30..9eb73bcc2404 100644 --- a/pkg/codegen/testing/test/testdata/simple-plain-schema/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/simple-plain-schema/nodejs/types/output.ts @@ -4,6 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; +import * as utilities from "../utilities"; export interface Foo { a: boolean; diff --git a/pkg/codegen/testing/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/types/input.ts index b3fb243ef5b0..6615b1d2911f 100644 --- a/pkg/codegen/testing/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/types/input.ts @@ -4,6 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; +import * as utilities from "../utilities"; import {Resource} from ".."; diff --git a/pkg/codegen/testing/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/types/output.ts index b3fb243ef5b0..6615b1d2911f 100644 --- a/pkg/codegen/testing/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/types/output.ts @@ -4,6 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; +import * as utilities from "../utilities"; import {Resource} from ".."; diff --git a/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/types/input.ts index 3f46a1eb5259..ea24d93f683c 100644 --- a/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/types/input.ts @@ -4,6 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; +import * as utilities from "../utilities"; import {Resource} from ".."; diff --git a/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/types/output.ts index 841a179665ac..06a803f01d6e 100644 --- a/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/types/output.ts @@ -4,6 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; +import * as utilities from "../utilities"; import {Resource} from ".."; From 9235b9f33894bb1e6adb3ea7cf219e65be9a40f9 Mon Sep 17 00:00:00 2001 From: Robbie McKinstry Date: Mon, 17 Oct 2022 21:41:11 -0400 Subject: [PATCH 09/16] Remove re-exports from the index --- pkg/codegen/nodejs/gen.go | 4 ++-- .../nodejs/types/documentdb/index.ts | 2 -- .../testdata/plain-object-defaults/nodejs/types/mod1/index.ts | 2 -- .../testdata/plain-object-defaults/nodejs/types/mod2/index.ts | 2 -- .../plain-object-disable-defaults/nodejs/types/mod1/index.ts | 2 -- .../plain-object-disable-defaults/nodejs/types/mod2/index.ts | 2 -- .../provider-config-schema/nodejs/types/config/index.ts | 2 -- 7 files changed, 2 insertions(+), 14 deletions(-) diff --git a/pkg/codegen/nodejs/gen.go b/pkg/codegen/nodejs/gen.go index 9f547e82fa4b..67296c230684 100644 --- a/pkg/codegen/nodejs/gen.go +++ b/pkg/codegen/nodejs/gen.go @@ -1844,8 +1844,8 @@ func (ns *namespace) genIndexFile(ctx *ioContext, dirRoot string) *ioFile { var file = newIOFile(indexPath) ctx.mod.genHeader(file.writer(), nil, nil, nil) // Export the types defined at the current level. - fmt.Fprintf(file.writer(), "export * from \"./input\";\n") - fmt.Fprintf(file.writer(), "export * from \"./output\";\n") + // fmt.Fprintf(file.writer(), "export * from \"./input\";\n") + // fmt.Fprintf(file.writer(), "export * from \"./output\";\n") // Now, recursively export the items in each submodule. for _, child := range ns.children { // Defensive coding: child should never be null, but diff --git a/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/documentdb/index.ts b/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/documentdb/index.ts index 38514e5494d6..b7b2ea440d9f 100644 --- a/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/documentdb/index.ts +++ b/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/documentdb/index.ts @@ -1,5 +1,3 @@ // *** WARNING: this file was generated by test. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** -export * from "./input"; -export * from "./output"; diff --git a/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod1/index.ts b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod1/index.ts index 38514e5494d6..b7b2ea440d9f 100644 --- a/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod1/index.ts +++ b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod1/index.ts @@ -1,5 +1,3 @@ // *** WARNING: this file was generated by test. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** -export * from "./input"; -export * from "./output"; diff --git a/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod2/index.ts b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod2/index.ts index 38514e5494d6..b7b2ea440d9f 100644 --- a/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod2/index.ts +++ b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod2/index.ts @@ -1,5 +1,3 @@ // *** WARNING: this file was generated by test. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** -export * from "./input"; -export * from "./output"; diff --git a/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod1/index.ts b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod1/index.ts index 38514e5494d6..b7b2ea440d9f 100644 --- a/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod1/index.ts +++ b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod1/index.ts @@ -1,5 +1,3 @@ // *** WARNING: this file was generated by test. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** -export * from "./input"; -export * from "./output"; diff --git a/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod2/index.ts b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod2/index.ts index 38514e5494d6..b7b2ea440d9f 100644 --- a/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod2/index.ts +++ b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod2/index.ts @@ -1,5 +1,3 @@ // *** WARNING: this file was generated by test. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** -export * from "./input"; -export * from "./output"; diff --git a/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/config/index.ts b/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/config/index.ts index 38514e5494d6..b7b2ea440d9f 100644 --- a/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/config/index.ts +++ b/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/config/index.ts @@ -1,5 +1,3 @@ // *** WARNING: this file was generated by test. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** -export * from "./input"; -export * from "./output"; From 39ad793bd3221bb8ae531db02f9ef3825728bf37 Mon Sep 17 00:00:00 2001 From: Robbie McKinstry Date: Tue, 8 Nov 2022 20:58:21 -0500 Subject: [PATCH 10/16] Import only specific child file based on parent type. --- pkg/codegen/nodejs/gen.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/codegen/nodejs/gen.go b/pkg/codegen/nodejs/gen.go index 67296c230684..085333ca7edb 100644 --- a/pkg/codegen/nodejs/gen.go +++ b/pkg/codegen/nodejs/gen.go @@ -1853,7 +1853,8 @@ func (ns *namespace) genIndexFile(ctx *ioContext, dirRoot string) *ioFile { if child == nil { continue } - fmt.Fprintf(file.writer(), "export * as %[1]s from \"./%[1]s\";\n", child.name) + + fmt.Fprintf(file.writer(), "export * as %[1]s from \"./%[1]s/%[2]s\";\n", child.name, ctx.filetype()) } return file } From 9219fc03f1e490414a2ed8f275fd6fd3848f8ebf Mon Sep 17 00:00:00 2001 From: Robbie McKinstry Date: Tue, 8 Nov 2022 22:21:40 -0500 Subject: [PATCH 11/16] Regenerate codegen tests --- pkg/codegen/nodejs/gen.go | 22 +++++++++++++++++-- .../nodejs/types/nested/index.ts | 2 -- pkg/codegen/testing/test/testdata/types.json | 3 +++ 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/pkg/codegen/nodejs/gen.go b/pkg/codegen/nodejs/gen.go index 085333ca7edb..03183f596dd9 100644 --- a/pkg/codegen/nodejs/gen.go +++ b/pkg/codegen/nodejs/gen.go @@ -1468,14 +1468,14 @@ func (mod *modContext) genHeader(w io.Writer, imports []string, externalImports sort.Strings(modules) for _, module := range modules { - fmt.Fprintf(w, "import {") + fmt.Fprintf(w, "import { ") for i, name := range importedTypes[module].SortedValues() { if i > 0 { fmt.Fprint(w, ", ") } fmt.Fprint(w, name) } - fmt.Fprintf(w, "} from \"%s\";\n", module) + fmt.Fprintf(w, " } from \"%s\";\n", module) } fmt.Fprintf(w, "\n") } @@ -1549,6 +1549,9 @@ func (mod *modContext) genConfig(w io.Writer, variables []*schema.Property) erro // It's a thin wrapper around the standard library's implementation. func getRelativePath(dirname string) string { var rel, err = filepath.Rel(dirname, "") + if err != nil { + fmt.Println(err) + } contract.Assert(err == nil) return path.Dir(filepath.ToSlash(rel)) } @@ -1647,6 +1650,17 @@ func (mod *modContext) genTypes() ([]*ioFile, error) { inputCtx = buildCtx(true) outputCtx = buildCtx(false) ) + // Convert the imports into a path relative to the root. + + var modifiedImports = map[string]codegen.StringSet{} + for name, value := range imports { + var modifiedName = path.Base(name) + var relativePath = fmt.Sprintf("@/%s", modifiedName) + modifiedImports[relativePath] = value + } + inputCtx.imports = modifiedImports + outputCtx.imports = modifiedImports + // If there are no namespaces, then we generate empty // input and output files. if namespaces[""] == nil { @@ -2566,6 +2580,7 @@ func genTypeScriptProjectFile(info NodePackageInfo, files codegen.Fs) string { fmt.Fprintf(w, `{ "compilerOptions": { + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -2576,6 +2591,9 @@ func genTypeScriptProjectFile(info NodePackageInfo, files codegen.Fs) string { "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, + "paths": { + "@/*": ["*"] + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/nested/index.ts b/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/nested/index.ts index 38514e5494d6..b7b2ea440d9f 100644 --- a/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/nested/index.ts +++ b/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/nested/index.ts @@ -1,5 +1,3 @@ // *** WARNING: this file was generated by test. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** -export * from "./input"; -export * from "./output"; diff --git a/pkg/codegen/testing/test/testdata/types.json b/pkg/codegen/testing/test/testdata/types.json index 42f3fb153be9..1a0c511e73eb 100644 --- a/pkg/codegen/testing/test/testdata/types.json +++ b/pkg/codegen/testing/test/testdata/types.json @@ -4,6 +4,9 @@ "meta": { "moduleFormat": "(.*)" }, + "language": { + "nodejs": {} + }, "config": {}, "types": { "typetests::object": { From 1d7e9ae48f73254b3ae0733bd36abb460e7a4edb Mon Sep 17 00:00:00 2001 From: Robbie McKinstry Date: Wed, 9 Nov 2022 07:52:28 -0500 Subject: [PATCH 12/16] Add a special case for imports, reset codegen tests --- pkg/codegen/nodejs/gen.go | 20 +++++++++---------- .../nodejs/tsconfig.json | 4 ++++ .../cyclic-types/nodejs/tsconfig.json | 4 ++++ .../dash-named-schema/nodejs/tsconfig.json | 4 ++++ .../dashed-import-schema/nodejs/tsconfig.json | 4 ++++ .../different-enum/nodejs/tsconfig.json | 4 ++++ .../enum-reference/nodejs/tsconfig.json | 4 ++++ .../external-enum/nodejs/tsconfig.json | 4 ++++ .../nodejs/tsconfig.json | 4 ++++ .../nodejs/tsconfig.json | 4 ++++ .../functions-secrets/nodejs/tsconfig.json | 4 ++++ .../testdata/hyphen-url/nodejs/tsconfig.json | 4 ++++ .../naming-collisions/nodejs/tsconfig.json | 4 ++++ .../nodejs/tsconfig.json | 4 ++++ .../nested-module/nodejs/tsconfig.json | 4 ++++ .../nodejs/tsconfig.json | 4 ++++ .../nodejs/tsconfig.json | 4 ++++ .../output-funcs/nodejs/tsconfig.json | 4 ++++ .../plain-and-default/nodejs/tsconfig.json | 4 ++++ .../nodejs/tsconfig.json | 4 ++++ .../nodejs/tsconfig.json | 4 ++++ .../plain-schema-gh6957/nodejs/tsconfig.json | 4 ++++ .../nodejs/tsconfig.json | 4 ++++ .../regress-8403/nodejs/tsconfig.json | 4 ++++ .../regress-node-8110/nodejs/tsconfig.json | 4 ++++ .../testdata/replace-on-change/nodejs/cat.ts | 2 +- .../testdata/replace-on-change/nodejs/god.ts | 2 +- .../replace-on-change/nodejs/toyStore.ts | 2 +- .../replace-on-change/nodejs/tsconfig.json | 4 ++++ .../replace-on-change/nodejs/types/input.ts | 2 +- .../replace-on-change/nodejs/types/output.ts | 2 +- .../nodejs/tsconfig.json | 4 ++++ .../resource-args-python/nodejs/tsconfig.json | 4 ++++ .../resource-property-overlap/nodejs/rec.ts | 2 +- .../nodejs/tsconfig.json | 4 ++++ .../testdata/secrets/nodejs/tsconfig.json | 4 ++++ .../simple-enum-schema/nodejs/tsconfig.json | 4 ++++ .../nodejs/tsconfig.json | 4 ++++ .../nodejs/tsconfig.json | 4 ++++ .../nodejs/tsconfig.json | 4 ++++ .../simple-plain-schema/nodejs/tsconfig.json | 4 ++++ .../nodejs/argFunction.ts | 2 +- .../nodejs/otherResource.ts | 2 +- .../nodejs/tsconfig.json | 4 ++++ .../nodejs/types/input.ts | 2 +- .../nodejs/types/output.ts | 2 +- .../nodejs/argFunction.ts | 2 +- .../nodejs/barResource.ts | 2 +- .../nodejs/fooResource.ts | 2 +- .../nodejs/otherResource.ts | 2 +- .../nodejs/tsconfig.json | 4 ++++ .../simple-resource-schema/nodejs/typeUses.ts | 2 +- .../nodejs/types/input.ts | 2 +- .../nodejs/types/output.ts | 2 +- .../simple-yaml-schema/nodejs/argFunction.ts | 2 +- .../nodejs/otherResource.ts | 2 +- .../simple-yaml-schema/nodejs/tsconfig.json | 4 ++++ .../simple-yaml-schema/nodejs/typeUses.ts | 2 +- .../simple-yaml-schema/nodejs/types/input.ts | 2 +- .../simple-yaml-schema/nodejs/types/output.ts | 2 +- 60 files changed, 180 insertions(+), 32 deletions(-) diff --git a/pkg/codegen/nodejs/gen.go b/pkg/codegen/nodejs/gen.go index 03183f596dd9..51ebeec72beb 100644 --- a/pkg/codegen/nodejs/gen.go +++ b/pkg/codegen/nodejs/gen.go @@ -1468,14 +1468,14 @@ func (mod *modContext) genHeader(w io.Writer, imports []string, externalImports sort.Strings(modules) for _, module := range modules { - fmt.Fprintf(w, "import { ") + fmt.Fprintf(w, "import {") for i, name := range importedTypes[module].SortedValues() { if i > 0 { fmt.Fprint(w, ", ") } fmt.Fprint(w, name) } - fmt.Fprintf(w, " } from \"%s\";\n", module) + fmt.Fprintf(w, "} from \"%s\";\n", module) } fmt.Fprintf(w, "\n") } @@ -1549,9 +1549,6 @@ func (mod *modContext) genConfig(w io.Writer, variables []*schema.Property) erro // It's a thin wrapper around the standard library's implementation. func getRelativePath(dirname string) string { var rel, err = filepath.Rel(dirname, "") - if err != nil { - fmt.Println(err) - } contract.Assert(err == nil) return path.Dir(filepath.ToSlash(rel)) } @@ -1655,6 +1652,11 @@ func (mod *modContext) genTypes() ([]*ioFile, error) { var modifiedImports = map[string]codegen.StringSet{} for name, value := range imports { var modifiedName = path.Base(name) + // Special case: If we're importing the top-level of the module, leave as is. + if name == ".." { + modifiedImports[name] = value + continue + } var relativePath = fmt.Sprintf("@/%s", modifiedName) modifiedImports[relativePath] = value } @@ -1776,7 +1778,7 @@ func (ns *namespace) intoIOFiles(ctx *ioContext, parent string) ([]*ioFile, erro // sortItems will sort each of the internal slices of this object. func (ns *namespace) sortItems() { sort.Slice(ns.types, func(i, j int) bool { - return tokenToName(ns.types[i].Token) < tokenToName(ns.types[j].Token) + return objectTypeLessThan(ns.types[i], ns.types[j]) }) sort.Slice(ns.enums, func(i, j int) bool { return tokenToName(ns.enums[i].Token) < tokenToName(ns.enums[j].Token) @@ -1858,8 +1860,6 @@ func (ns *namespace) genIndexFile(ctx *ioContext, dirRoot string) *ioFile { var file = newIOFile(indexPath) ctx.mod.genHeader(file.writer(), nil, nil, nil) // Export the types defined at the current level. - // fmt.Fprintf(file.writer(), "export * from \"./input\";\n") - // fmt.Fprintf(file.writer(), "export * from \"./output\";\n") // Now, recursively export the items in each submodule. for _, child := range ns.children { // Defensive coding: child should never be null, but @@ -2580,7 +2580,7 @@ func genTypeScriptProjectFile(info NodePackageInfo, files codegen.Fs) string { fmt.Fprintf(w, `{ "compilerOptions": { - "baseUrl": ".", + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -2592,7 +2592,7 @@ func genTypeScriptProjectFile(info NodePackageInfo, files codegen.Fs) string { "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, "paths": { - "@/*": ["*"] + "@/*": ["*"] }, "strict": true }, diff --git a/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/tsconfig.json index e21743ea2c3a..b8dd0dac03f5 100644 --- a/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -10,6 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, + "paths": { + "@/*": ["*"] + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/cyclic-types/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/cyclic-types/nodejs/tsconfig.json index 6bb3117a6aef..a53d9380d528 100644 --- a/pkg/codegen/testing/test/testdata/cyclic-types/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/cyclic-types/nodejs/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -10,6 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, + "paths": { + "@/*": ["*"] + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/dash-named-schema/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/dash-named-schema/nodejs/tsconfig.json index 63b822f490aa..9f9d4cec0195 100644 --- a/pkg/codegen/testing/test/testdata/dash-named-schema/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/dash-named-schema/nodejs/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -10,6 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, + "paths": { + "@/*": ["*"] + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/dashed-import-schema/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/dashed-import-schema/nodejs/tsconfig.json index a363ab1f9b2e..b681965746dc 100644 --- a/pkg/codegen/testing/test/testdata/dashed-import-schema/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/dashed-import-schema/nodejs/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -10,6 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, + "paths": { + "@/*": ["*"] + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/different-enum/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/different-enum/nodejs/tsconfig.json index a363ab1f9b2e..b681965746dc 100644 --- a/pkg/codegen/testing/test/testdata/different-enum/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/different-enum/nodejs/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -10,6 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, + "paths": { + "@/*": ["*"] + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/enum-reference/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/enum-reference/nodejs/tsconfig.json index 253ff9b94ac2..8f64dfc219b5 100644 --- a/pkg/codegen/testing/test/testdata/enum-reference/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/enum-reference/nodejs/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -10,6 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, + "paths": { + "@/*": ["*"] + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/external-enum/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/external-enum/nodejs/tsconfig.json index ae729c26ccf1..46db2f43bb50 100644 --- a/pkg/codegen/testing/test/testdata/external-enum/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/external-enum/nodejs/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -10,6 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, + "paths": { + "@/*": ["*"] + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/external-node-compatibility/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/external-node-compatibility/nodejs/tsconfig.json index 2b896e90f6fe..20a4de65f339 100644 --- a/pkg/codegen/testing/test/testdata/external-node-compatibility/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/external-node-compatibility/nodejs/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -10,6 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, + "paths": { + "@/*": ["*"] + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/external-resource-schema/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/external-resource-schema/nodejs/tsconfig.json index b490e322b179..8db58d8eee3c 100644 --- a/pkg/codegen/testing/test/testdata/external-resource-schema/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/external-resource-schema/nodejs/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -10,6 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, + "paths": { + "@/*": ["*"] + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/functions-secrets/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/functions-secrets/nodejs/tsconfig.json index effb4ad7b246..cbaf3f89dfa7 100644 --- a/pkg/codegen/testing/test/testdata/functions-secrets/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/functions-secrets/nodejs/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -10,6 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, + "paths": { + "@/*": ["*"] + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/hyphen-url/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/hyphen-url/nodejs/tsconfig.json index af7953c23573..b4f107a75623 100644 --- a/pkg/codegen/testing/test/testdata/hyphen-url/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/hyphen-url/nodejs/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -10,6 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, + "paths": { + "@/*": ["*"] + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/naming-collisions/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/naming-collisions/nodejs/tsconfig.json index 580c6b03ddba..cb361b45bb5b 100644 --- a/pkg/codegen/testing/test/testdata/naming-collisions/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/naming-collisions/nodejs/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -10,6 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, + "paths": { + "@/*": ["*"] + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/nested-module-thirdparty/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/nested-module-thirdparty/nodejs/tsconfig.json index c947b95045f8..a0bfbf5217f0 100644 --- a/pkg/codegen/testing/test/testdata/nested-module-thirdparty/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/nested-module-thirdparty/nodejs/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -10,6 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, + "paths": { + "@/*": ["*"] + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/nested-module/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/nested-module/nodejs/tsconfig.json index d4e72d54ecae..697ce99eacc3 100644 --- a/pkg/codegen/testing/test/testdata/nested-module/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/nested-module/nodejs/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -10,6 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, + "paths": { + "@/*": ["*"] + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/output-funcs-edgeorder/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/output-funcs-edgeorder/nodejs/tsconfig.json index 7e575cc7a849..8bf81dc7b1dc 100644 --- a/pkg/codegen/testing/test/testdata/output-funcs-edgeorder/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/output-funcs-edgeorder/nodejs/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -10,6 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, + "paths": { + "@/*": ["*"] + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/output-funcs-tfbridge20/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/output-funcs-tfbridge20/nodejs/tsconfig.json index cc64437a5595..05d664175b54 100644 --- a/pkg/codegen/testing/test/testdata/output-funcs-tfbridge20/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/output-funcs-tfbridge20/nodejs/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -10,6 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, + "paths": { + "@/*": ["*"] + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/output-funcs/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/output-funcs/nodejs/tsconfig.json index 5ea3ffc6d732..af3ea571240f 100644 --- a/pkg/codegen/testing/test/testdata/output-funcs/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/output-funcs/nodejs/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -10,6 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, + "paths": { + "@/*": ["*"] + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/plain-and-default/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/plain-and-default/nodejs/tsconfig.json index 42e418910eeb..ba58ae2b242f 100644 --- a/pkg/codegen/testing/test/testdata/plain-and-default/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/plain-and-default/nodejs/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -10,6 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, + "paths": { + "@/*": ["*"] + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/tsconfig.json index 59d7de2a223a..66e4b188bf71 100644 --- a/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -10,6 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, + "paths": { + "@/*": ["*"] + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/tsconfig.json index 59d7de2a223a..66e4b188bf71 100644 --- a/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -10,6 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, + "paths": { + "@/*": ["*"] + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/plain-schema-gh6957/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/plain-schema-gh6957/nodejs/tsconfig.json index 99579b972141..8983ea1b68e7 100644 --- a/pkg/codegen/testing/test/testdata/plain-schema-gh6957/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/plain-schema-gh6957/nodejs/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -10,6 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, + "paths": { + "@/*": ["*"] + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/tsconfig.json index 788808e643db..08991804950a 100644 --- a/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -10,6 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, + "paths": { + "@/*": ["*"] + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/regress-8403/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/regress-8403/nodejs/tsconfig.json index 45ff3f07a77c..eceecdc9c256 100644 --- a/pkg/codegen/testing/test/testdata/regress-8403/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/regress-8403/nodejs/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -10,6 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, + "paths": { + "@/*": ["*"] + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/regress-node-8110/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/regress-node-8110/nodejs/tsconfig.json index a9470134b2ac..71926d03295d 100644 --- a/pkg/codegen/testing/test/testdata/regress-node-8110/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/regress-node-8110/nodejs/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -10,6 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, + "paths": { + "@/*": ["*"] + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/cat.ts b/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/cat.ts index 2de39537fafb..79590ba71f09 100644 --- a/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/cat.ts +++ b/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/cat.ts @@ -6,7 +6,7 @@ import * as inputs from "./types/input"; import * as outputs from "./types/output"; import * as utilities from "./utilities"; -import {God} from "./index"; +import { God } from "./index"; export class Cat extends pulumi.CustomResource { /** diff --git a/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/god.ts b/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/god.ts index 344344d9a08c..e4bee1e7a0f3 100644 --- a/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/god.ts +++ b/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/god.ts @@ -4,7 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as utilities from "./utilities"; -import {Dog} from "./index"; +import { Dog } from "./index"; export class God extends pulumi.CustomResource { /** diff --git a/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/toyStore.ts b/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/toyStore.ts index 41b03e4ced19..6e81cb1de208 100644 --- a/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/toyStore.ts +++ b/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/toyStore.ts @@ -6,7 +6,7 @@ import * as inputs from "./types/input"; import * as outputs from "./types/output"; import * as utilities from "./utilities"; -import {Cat, Dog} from "./index"; +import { Cat, Dog } from "./index"; export class ToyStore extends pulumi.CustomResource { /** diff --git a/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/tsconfig.json index 74d2b01d605a..cd4266b27f39 100644 --- a/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -10,6 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, + "paths": { + "@/*": ["*"] + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/types/input.ts index 6966d245b39d..76d7b802db6f 100644 --- a/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/types/input.ts @@ -6,5 +6,5 @@ import * as inputs from "../types/input"; import * as outputs from "../types/output"; import * as utilities from "../utilities"; -import {Cat, Dog} from ".."; +import { Cat, Dog } from ".."; diff --git a/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/types/output.ts index 273422fbe3a2..f2a5b8419dc9 100644 --- a/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/types/output.ts @@ -6,7 +6,7 @@ import * as inputs from "../types/input"; import * as outputs from "../types/output"; import * as utilities from "../utilities"; -import {Cat, Dog} from ".."; +import { Cat, Dog } from ".."; /** * A toy for a dog diff --git a/pkg/codegen/testing/test/testdata/resource-args-python-case-insensitive/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/resource-args-python-case-insensitive/nodejs/tsconfig.json index 6c3db385d156..21a1de173a11 100644 --- a/pkg/codegen/testing/test/testdata/resource-args-python-case-insensitive/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/resource-args-python-case-insensitive/nodejs/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -10,6 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, + "paths": { + "@/*": ["*"] + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/resource-args-python/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/resource-args-python/nodejs/tsconfig.json index 6c3db385d156..21a1de173a11 100644 --- a/pkg/codegen/testing/test/testdata/resource-args-python/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/resource-args-python/nodejs/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -10,6 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, + "paths": { + "@/*": ["*"] + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/resource-property-overlap/nodejs/rec.ts b/pkg/codegen/testing/test/testdata/resource-property-overlap/nodejs/rec.ts index b6e2a8fcc134..ace6cba1ed29 100644 --- a/pkg/codegen/testing/test/testdata/resource-property-overlap/nodejs/rec.ts +++ b/pkg/codegen/testing/test/testdata/resource-property-overlap/nodejs/rec.ts @@ -4,7 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as utilities from "./utilities"; -import {Rec} from "./index"; +import { Rec } from "./index"; export class Rec extends pulumi.CustomResource { /** diff --git a/pkg/codegen/testing/test/testdata/resource-property-overlap/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/resource-property-overlap/nodejs/tsconfig.json index e2e0424ca402..77a81b7dc902 100644 --- a/pkg/codegen/testing/test/testdata/resource-property-overlap/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/resource-property-overlap/nodejs/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -10,6 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, + "paths": { + "@/*": ["*"] + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/secrets/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/secrets/nodejs/tsconfig.json index 01fe76ddb354..1015caac19ee 100644 --- a/pkg/codegen/testing/test/testdata/secrets/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/secrets/nodejs/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -10,6 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, + "paths": { + "@/*": ["*"] + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/simple-enum-schema/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/simple-enum-schema/nodejs/tsconfig.json index a363ab1f9b2e..b681965746dc 100644 --- a/pkg/codegen/testing/test/testdata/simple-enum-schema/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/simple-enum-schema/nodejs/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -10,6 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, + "paths": { + "@/*": ["*"] + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/simple-methods-schema-single-value-returns/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/simple-methods-schema-single-value-returns/nodejs/tsconfig.json index 2b896e90f6fe..20a4de65f339 100644 --- a/pkg/codegen/testing/test/testdata/simple-methods-schema-single-value-returns/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/simple-methods-schema-single-value-returns/nodejs/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -10,6 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, + "paths": { + "@/*": ["*"] + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/tsconfig.json index 92462c9bac74..19ce99b6536a 100644 --- a/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -10,6 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, + "paths": { + "@/*": ["*"] + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/simple-plain-schema-with-root-package/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/simple-plain-schema-with-root-package/nodejs/tsconfig.json index fa2ff8647b39..eec55a0bd4b7 100644 --- a/pkg/codegen/testing/test/testdata/simple-plain-schema-with-root-package/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/simple-plain-schema-with-root-package/nodejs/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -10,6 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, + "paths": { + "@/*": ["*"] + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/simple-plain-schema/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/simple-plain-schema/nodejs/tsconfig.json index 874122098657..d053a0093b81 100644 --- a/pkg/codegen/testing/test/testdata/simple-plain-schema/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/simple-plain-schema/nodejs/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -10,6 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, + "paths": { + "@/*": ["*"] + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/argFunction.ts b/pkg/codegen/testing/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/argFunction.ts index 9ee7378b83a4..571906cf70c1 100644 --- a/pkg/codegen/testing/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/argFunction.ts +++ b/pkg/codegen/testing/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/argFunction.ts @@ -4,7 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as utilities from "./utilities"; -import {Resource} from "./index"; +import { Resource } from "./index"; export function argFunction(args?: ArgFunctionArgs, opts?: pulumi.InvokeOptions): Promise { args = args || {}; diff --git a/pkg/codegen/testing/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/otherResource.ts b/pkg/codegen/testing/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/otherResource.ts index 6ad577a6338b..6a7dc3eb336c 100644 --- a/pkg/codegen/testing/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/otherResource.ts +++ b/pkg/codegen/testing/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/otherResource.ts @@ -4,7 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as utilities from "./utilities"; -import {Resource} from "./index"; +import { Resource } from "./index"; export class OtherResource extends pulumi.ComponentResource { /** @internal */ diff --git a/pkg/codegen/testing/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/tsconfig.json index b0d249aeace5..c2206251144e 100644 --- a/pkg/codegen/testing/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -10,6 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, + "paths": { + "@/*": ["*"] + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/types/input.ts index 6615b1d2911f..d4a1642f95af 100644 --- a/pkg/codegen/testing/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/types/input.ts @@ -6,5 +6,5 @@ import * as inputs from "../types/input"; import * as outputs from "../types/output"; import * as utilities from "../utilities"; -import {Resource} from ".."; +import { Resource } from ".."; diff --git a/pkg/codegen/testing/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/types/output.ts index 6615b1d2911f..d4a1642f95af 100644 --- a/pkg/codegen/testing/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/types/output.ts @@ -6,5 +6,5 @@ import * as inputs from "../types/input"; import * as outputs from "../types/output"; import * as utilities from "../utilities"; -import {Resource} from ".."; +import { Resource } from ".."; diff --git a/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/argFunction.ts b/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/argFunction.ts index 9ee7378b83a4..571906cf70c1 100644 --- a/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/argFunction.ts +++ b/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/argFunction.ts @@ -4,7 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as utilities from "./utilities"; -import {Resource} from "./index"; +import { Resource } from "./index"; export function argFunction(args?: ArgFunctionArgs, opts?: pulumi.InvokeOptions): Promise { args = args || {}; diff --git a/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/barResource.ts b/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/barResource.ts index 51e9d4366cd2..a8cd6de6bcdb 100644 --- a/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/barResource.ts +++ b/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/barResource.ts @@ -4,7 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as utilities from "./utilities"; -import {Resource} from "./index"; +import { Resource } from "./index"; export class BarResource extends pulumi.ComponentResource { /** @internal */ diff --git a/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/fooResource.ts b/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/fooResource.ts index 5ffb358d782b..a644eeb2cef5 100644 --- a/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/fooResource.ts +++ b/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/fooResource.ts @@ -4,7 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as utilities from "./utilities"; -import {Resource} from "./index"; +import { Resource } from "./index"; export class FooResource extends pulumi.ComponentResource { /** @internal */ diff --git a/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/otherResource.ts b/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/otherResource.ts index 6ad577a6338b..6a7dc3eb336c 100644 --- a/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/otherResource.ts +++ b/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/otherResource.ts @@ -4,7 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as utilities from "./utilities"; -import {Resource} from "./index"; +import { Resource } from "./index"; export class OtherResource extends pulumi.ComponentResource { /** @internal */ diff --git a/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/tsconfig.json index 9e7bc6288035..3245e24e830f 100644 --- a/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -10,6 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, + "paths": { + "@/*": ["*"] + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/typeUses.ts b/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/typeUses.ts index 136e79e01786..21478d3daed2 100644 --- a/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/typeUses.ts +++ b/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/typeUses.ts @@ -6,7 +6,7 @@ import * as inputs from "./types/input"; import * as outputs from "./types/output"; import * as utilities from "./utilities"; -import {Resource} from "./index"; +import { Resource } from "./index"; export class TypeUses extends pulumi.CustomResource { /** diff --git a/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/types/input.ts index ea24d93f683c..134e4311a531 100644 --- a/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/types/input.ts @@ -6,7 +6,7 @@ import * as inputs from "../types/input"; import * as outputs from "../types/output"; import * as utilities from "../utilities"; -import {Resource} from ".."; +import { Resource } from ".."; export interface ConfigMapArgs { config?: pulumi.Input; diff --git a/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/types/output.ts index 06a803f01d6e..bd1b8c9165c3 100644 --- a/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/types/output.ts @@ -6,7 +6,7 @@ import * as inputs from "../types/input"; import * as outputs from "../types/output"; import * as utilities from "../utilities"; -import {Resource} from ".."; +import { Resource } from ".."; export interface ConfigMap { config?: string; diff --git a/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/argFunction.ts b/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/argFunction.ts index 9ee7378b83a4..571906cf70c1 100644 --- a/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/argFunction.ts +++ b/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/argFunction.ts @@ -4,7 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as utilities from "./utilities"; -import {Resource} from "./index"; +import { Resource } from "./index"; export function argFunction(args?: ArgFunctionArgs, opts?: pulumi.InvokeOptions): Promise { args = args || {}; diff --git a/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/otherResource.ts b/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/otherResource.ts index 016b4792ce14..6a10bce2066e 100644 --- a/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/otherResource.ts +++ b/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/otherResource.ts @@ -4,7 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as utilities from "./utilities"; -import {Resource} from "./index"; +import { Resource } from "./index"; export class OtherResource extends pulumi.ComponentResource { /** @internal */ diff --git a/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/tsconfig.json index 1fc1716a1a2a..ca382b1654a9 100644 --- a/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -10,6 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, + "paths": { + "@/*": ["*"] + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/typeUses.ts b/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/typeUses.ts index 3a42862b0a7e..d9c08cf332ed 100644 --- a/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/typeUses.ts +++ b/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/typeUses.ts @@ -7,7 +7,7 @@ import * as outputs from "./types/output"; import * as enums from "./types/enums"; import * as utilities from "./utilities"; -import {Resource} from "./index"; +import { Resource } from "./index"; export class TypeUses extends pulumi.CustomResource { /** diff --git a/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/types/input.ts index 774b7916ca54..865bfdfd54bd 100644 --- a/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/types/input.ts @@ -7,7 +7,7 @@ import * as outputs from "../types/output"; import * as enums from "../types/enums"; import * as utilities from "../utilities"; -import {Resource} from ".."; +import { Resource } from ".."; export interface ConfigMapArgs { config?: pulumi.Input; diff --git a/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/types/output.ts index 06d28a71e5cc..6edc0e87f7c1 100644 --- a/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/types/output.ts @@ -7,7 +7,7 @@ import * as outputs from "../types/output"; import * as enums from "../types/enums"; import * as utilities from "../utilities"; -import {Resource} from ".."; +import { Resource } from ".."; export interface ConfigMap { config?: string; From f0b3513dc7a3c3c4a96ec591deba5827a9b04004 Mon Sep 17 00:00:00 2001 From: Robbie McKinstry Date: Wed, 9 Nov 2022 17:23:15 -0500 Subject: [PATCH 13/16] Update pkg/codegen/nodejs/gen.go Co-authored-by: Kyle Pitzen --- pkg/codegen/nodejs/gen.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/codegen/nodejs/gen.go b/pkg/codegen/nodejs/gen.go index 51ebeec72beb..b0dfa70edefb 100644 --- a/pkg/codegen/nodejs/gen.go +++ b/pkg/codegen/nodejs/gen.go @@ -1729,7 +1729,7 @@ func (ctx *ioContext) filetype() string { // intoIOFiles converts this namespace into one or more files. // It recursively builds one file for each node in the tree. -// If input=true, then it builds input types. Otherwise, it +// If ctx.input=true, then it builds input types. Otherwise, it // builds output types. // The parameters in ctx are stable regardless of the depth of recursion, // but parent is expected to change with each recursive call. From 59e583b611490f293440507191eb1d9b99f0c02f Mon Sep 17 00:00:00 2001 From: Robbie McKinstry Date: Wed, 9 Nov 2022 18:10:27 -0500 Subject: [PATCH 14/16] Convert mod.utilities from a method to a function. --- pkg/codegen/nodejs/gen.go | 6 +++--- .../testdata/azure-native-nested-types/nodejs/tsconfig.json | 4 ++-- .../testing/test/testdata/cyclic-types/nodejs/tsconfig.json | 4 ++-- .../test/testdata/dash-named-schema/nodejs/tsconfig.json | 4 ++-- .../test/testdata/dashed-import-schema/nodejs/tsconfig.json | 4 ++-- .../test/testdata/different-enum/nodejs/tsconfig.json | 4 ++-- .../test/testdata/enum-reference/nodejs/tsconfig.json | 4 ++-- .../test/testdata/external-enum/nodejs/tsconfig.json | 4 ++-- .../external-node-compatibility/nodejs/tsconfig.json | 4 ++-- .../testdata/external-resource-schema/nodejs/tsconfig.json | 4 ++-- .../test/testdata/functions-secrets/nodejs/tsconfig.json | 4 ++-- .../testing/test/testdata/hyphen-url/nodejs/tsconfig.json | 4 ++-- .../test/testdata/naming-collisions/nodejs/tsconfig.json | 4 ++-- .../testdata/nested-module-thirdparty/nodejs/tsconfig.json | 4 ++-- .../test/testdata/nested-module/nodejs/tsconfig.json | 4 ++-- .../testdata/output-funcs-edgeorder/nodejs/tsconfig.json | 4 ++-- .../testdata/output-funcs-tfbridge20/nodejs/tsconfig.json | 4 ++-- .../testing/test/testdata/output-funcs/nodejs/tsconfig.json | 4 ++-- .../test/testdata/plain-and-default/nodejs/tsconfig.json | 4 ++-- .../testdata/plain-object-defaults/nodejs/tsconfig.json | 4 ++-- .../plain-object-disable-defaults/nodejs/tsconfig.json | 4 ++-- .../test/testdata/plain-schema-gh6957/nodejs/tsconfig.json | 4 ++-- .../testdata/provider-config-schema/nodejs/tsconfig.json | 4 ++-- .../testing/test/testdata/regress-8403/nodejs/tsconfig.json | 4 ++-- .../test/testdata/regress-node-8110/nodejs/tsconfig.json | 4 ++-- .../testing/test/testdata/replace-on-change/nodejs/cat.ts | 2 +- .../testing/test/testdata/replace-on-change/nodejs/god.ts | 2 +- .../test/testdata/replace-on-change/nodejs/toyStore.ts | 2 +- .../test/testdata/replace-on-change/nodejs/tsconfig.json | 4 ++-- .../test/testdata/replace-on-change/nodejs/types/input.ts | 2 +- .../test/testdata/replace-on-change/nodejs/types/output.ts | 2 +- .../nodejs/tsconfig.json | 4 ++-- .../test/testdata/resource-args-python/nodejs/tsconfig.json | 4 ++-- .../test/testdata/resource-property-overlap/nodejs/rec.ts | 2 +- .../testdata/resource-property-overlap/nodejs/tsconfig.json | 4 ++-- .../testing/test/testdata/secrets/nodejs/tsconfig.json | 4 ++-- .../test/testdata/simple-enum-schema/nodejs/tsconfig.json | 4 ++-- .../nodejs/tsconfig.json | 4 ++-- .../testdata/simple-methods-schema/nodejs/tsconfig.json | 4 ++-- .../nodejs/tsconfig.json | 4 ++-- .../test/testdata/simple-plain-schema/nodejs/tsconfig.json | 4 ++-- .../nodejs/argFunction.ts | 2 +- .../nodejs/otherResource.ts | 2 +- .../nodejs/tsconfig.json | 4 ++-- .../nodejs/types/input.ts | 2 +- .../nodejs/types/output.ts | 2 +- .../testdata/simple-resource-schema/nodejs/argFunction.ts | 2 +- .../testdata/simple-resource-schema/nodejs/barResource.ts | 2 +- .../testdata/simple-resource-schema/nodejs/fooResource.ts | 2 +- .../testdata/simple-resource-schema/nodejs/otherResource.ts | 2 +- .../testdata/simple-resource-schema/nodejs/tsconfig.json | 4 ++-- .../test/testdata/simple-resource-schema/nodejs/typeUses.ts | 2 +- .../testdata/simple-resource-schema/nodejs/types/input.ts | 2 +- .../testdata/simple-resource-schema/nodejs/types/output.ts | 2 +- .../test/testdata/simple-yaml-schema/nodejs/argFunction.ts | 2 +- .../testdata/simple-yaml-schema/nodejs/otherResource.ts | 2 +- .../test/testdata/simple-yaml-schema/nodejs/tsconfig.json | 4 ++-- .../test/testdata/simple-yaml-schema/nodejs/typeUses.ts | 2 +- .../test/testdata/simple-yaml-schema/nodejs/types/input.ts | 2 +- .../test/testdata/simple-yaml-schema/nodejs/types/output.ts | 2 +- 60 files changed, 99 insertions(+), 99 deletions(-) diff --git a/pkg/codegen/nodejs/gen.go b/pkg/codegen/nodejs/gen.go index b0dfa70edefb..be726aca09c7 100644 --- a/pkg/codegen/nodejs/gen.go +++ b/pkg/codegen/nodejs/gen.go @@ -1581,13 +1581,13 @@ func (mod *modContext) sdkImportsWithPath(nested, utilities bool, dirpath string } // Add utility imports if enabled. if utilities { - imports = append(imports, mod.utilitiesImport(relRoot)) + imports = append(imports, utilitiesImport(relRoot)) } return imports } -func (mod *modContext) utilitiesImport(relRoot string) string { +func utilitiesImport(relRoot string) string { return fmt.Sprintf("import * as utilities from \"%s/utilities\";", relRoot) } @@ -2236,7 +2236,7 @@ func (mod *modContext) genIndex(exports []fileInfo) string { imports = mod.sdkImports(false, true) } else if len(children) > 0 || len(mod.functions) > 0 { // Even if there are no resources, exports ref utilities. - imports = append(imports, mod.utilitiesImport(mod.getRelativePath())) + imports = append(imports, utilitiesImport(mod.getRelativePath())) } mod.genHeader(w, imports, nil, nil) diff --git a/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/tsconfig.json index b8dd0dac03f5..7c2e3887ca86 100644 --- a/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "baseUrl": ".", + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -12,7 +12,7 @@ "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, "paths": { - "@/*": ["*"] + "@/*": ["*"] }, "strict": true }, diff --git a/pkg/codegen/testing/test/testdata/cyclic-types/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/cyclic-types/nodejs/tsconfig.json index a53d9380d528..916a5dea0051 100644 --- a/pkg/codegen/testing/test/testdata/cyclic-types/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/cyclic-types/nodejs/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "baseUrl": ".", + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -12,7 +12,7 @@ "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, "paths": { - "@/*": ["*"] + "@/*": ["*"] }, "strict": true }, diff --git a/pkg/codegen/testing/test/testdata/dash-named-schema/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/dash-named-schema/nodejs/tsconfig.json index 9f9d4cec0195..4a9e24a7beae 100644 --- a/pkg/codegen/testing/test/testdata/dash-named-schema/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/dash-named-schema/nodejs/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "baseUrl": ".", + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -12,7 +12,7 @@ "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, "paths": { - "@/*": ["*"] + "@/*": ["*"] }, "strict": true }, diff --git a/pkg/codegen/testing/test/testdata/dashed-import-schema/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/dashed-import-schema/nodejs/tsconfig.json index b681965746dc..844c4046f0fc 100644 --- a/pkg/codegen/testing/test/testdata/dashed-import-schema/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/dashed-import-schema/nodejs/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "baseUrl": ".", + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -12,7 +12,7 @@ "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, "paths": { - "@/*": ["*"] + "@/*": ["*"] }, "strict": true }, diff --git a/pkg/codegen/testing/test/testdata/different-enum/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/different-enum/nodejs/tsconfig.json index b681965746dc..844c4046f0fc 100644 --- a/pkg/codegen/testing/test/testdata/different-enum/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/different-enum/nodejs/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "baseUrl": ".", + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -12,7 +12,7 @@ "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, "paths": { - "@/*": ["*"] + "@/*": ["*"] }, "strict": true }, diff --git a/pkg/codegen/testing/test/testdata/enum-reference/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/enum-reference/nodejs/tsconfig.json index 8f64dfc219b5..fbafb01f54af 100644 --- a/pkg/codegen/testing/test/testdata/enum-reference/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/enum-reference/nodejs/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "baseUrl": ".", + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -12,7 +12,7 @@ "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, "paths": { - "@/*": ["*"] + "@/*": ["*"] }, "strict": true }, diff --git a/pkg/codegen/testing/test/testdata/external-enum/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/external-enum/nodejs/tsconfig.json index 46db2f43bb50..91ddbb95be38 100644 --- a/pkg/codegen/testing/test/testdata/external-enum/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/external-enum/nodejs/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "baseUrl": ".", + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -12,7 +12,7 @@ "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, "paths": { - "@/*": ["*"] + "@/*": ["*"] }, "strict": true }, diff --git a/pkg/codegen/testing/test/testdata/external-node-compatibility/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/external-node-compatibility/nodejs/tsconfig.json index 20a4de65f339..3a608d2f5234 100644 --- a/pkg/codegen/testing/test/testdata/external-node-compatibility/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/external-node-compatibility/nodejs/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "baseUrl": ".", + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -12,7 +12,7 @@ "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, "paths": { - "@/*": ["*"] + "@/*": ["*"] }, "strict": true }, diff --git a/pkg/codegen/testing/test/testdata/external-resource-schema/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/external-resource-schema/nodejs/tsconfig.json index 8db58d8eee3c..fd55cfdb470b 100644 --- a/pkg/codegen/testing/test/testdata/external-resource-schema/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/external-resource-schema/nodejs/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "baseUrl": ".", + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -12,7 +12,7 @@ "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, "paths": { - "@/*": ["*"] + "@/*": ["*"] }, "strict": true }, diff --git a/pkg/codegen/testing/test/testdata/functions-secrets/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/functions-secrets/nodejs/tsconfig.json index cbaf3f89dfa7..3719726840e7 100644 --- a/pkg/codegen/testing/test/testdata/functions-secrets/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/functions-secrets/nodejs/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "baseUrl": ".", + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -12,7 +12,7 @@ "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, "paths": { - "@/*": ["*"] + "@/*": ["*"] }, "strict": true }, diff --git a/pkg/codegen/testing/test/testdata/hyphen-url/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/hyphen-url/nodejs/tsconfig.json index b4f107a75623..575795869a69 100644 --- a/pkg/codegen/testing/test/testdata/hyphen-url/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/hyphen-url/nodejs/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "baseUrl": ".", + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -12,7 +12,7 @@ "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, "paths": { - "@/*": ["*"] + "@/*": ["*"] }, "strict": true }, diff --git a/pkg/codegen/testing/test/testdata/naming-collisions/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/naming-collisions/nodejs/tsconfig.json index cb361b45bb5b..7b40b0d07c6f 100644 --- a/pkg/codegen/testing/test/testdata/naming-collisions/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/naming-collisions/nodejs/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "baseUrl": ".", + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -12,7 +12,7 @@ "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, "paths": { - "@/*": ["*"] + "@/*": ["*"] }, "strict": true }, diff --git a/pkg/codegen/testing/test/testdata/nested-module-thirdparty/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/nested-module-thirdparty/nodejs/tsconfig.json index a0bfbf5217f0..520ef06c6d89 100644 --- a/pkg/codegen/testing/test/testdata/nested-module-thirdparty/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/nested-module-thirdparty/nodejs/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "baseUrl": ".", + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -12,7 +12,7 @@ "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, "paths": { - "@/*": ["*"] + "@/*": ["*"] }, "strict": true }, diff --git a/pkg/codegen/testing/test/testdata/nested-module/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/nested-module/nodejs/tsconfig.json index 697ce99eacc3..2f057593d072 100644 --- a/pkg/codegen/testing/test/testdata/nested-module/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/nested-module/nodejs/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "baseUrl": ".", + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -12,7 +12,7 @@ "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, "paths": { - "@/*": ["*"] + "@/*": ["*"] }, "strict": true }, diff --git a/pkg/codegen/testing/test/testdata/output-funcs-edgeorder/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/output-funcs-edgeorder/nodejs/tsconfig.json index 8bf81dc7b1dc..5b4bd1d83362 100644 --- a/pkg/codegen/testing/test/testdata/output-funcs-edgeorder/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/output-funcs-edgeorder/nodejs/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "baseUrl": ".", + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -12,7 +12,7 @@ "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, "paths": { - "@/*": ["*"] + "@/*": ["*"] }, "strict": true }, diff --git a/pkg/codegen/testing/test/testdata/output-funcs-tfbridge20/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/output-funcs-tfbridge20/nodejs/tsconfig.json index 05d664175b54..b86311be344b 100644 --- a/pkg/codegen/testing/test/testdata/output-funcs-tfbridge20/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/output-funcs-tfbridge20/nodejs/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "baseUrl": ".", + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -12,7 +12,7 @@ "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, "paths": { - "@/*": ["*"] + "@/*": ["*"] }, "strict": true }, diff --git a/pkg/codegen/testing/test/testdata/output-funcs/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/output-funcs/nodejs/tsconfig.json index af3ea571240f..3d0077d89067 100644 --- a/pkg/codegen/testing/test/testdata/output-funcs/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/output-funcs/nodejs/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "baseUrl": ".", + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -12,7 +12,7 @@ "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, "paths": { - "@/*": ["*"] + "@/*": ["*"] }, "strict": true }, diff --git a/pkg/codegen/testing/test/testdata/plain-and-default/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/plain-and-default/nodejs/tsconfig.json index ba58ae2b242f..316628b2fc57 100644 --- a/pkg/codegen/testing/test/testdata/plain-and-default/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/plain-and-default/nodejs/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "baseUrl": ".", + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -12,7 +12,7 @@ "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, "paths": { - "@/*": ["*"] + "@/*": ["*"] }, "strict": true }, diff --git a/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/tsconfig.json index 66e4b188bf71..31dbab748a01 100644 --- a/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "baseUrl": ".", + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -12,7 +12,7 @@ "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, "paths": { - "@/*": ["*"] + "@/*": ["*"] }, "strict": true }, diff --git a/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/tsconfig.json index 66e4b188bf71..31dbab748a01 100644 --- a/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "baseUrl": ".", + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -12,7 +12,7 @@ "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, "paths": { - "@/*": ["*"] + "@/*": ["*"] }, "strict": true }, diff --git a/pkg/codegen/testing/test/testdata/plain-schema-gh6957/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/plain-schema-gh6957/nodejs/tsconfig.json index 8983ea1b68e7..6f7dd24d3766 100644 --- a/pkg/codegen/testing/test/testdata/plain-schema-gh6957/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/plain-schema-gh6957/nodejs/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "baseUrl": ".", + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -12,7 +12,7 @@ "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, "paths": { - "@/*": ["*"] + "@/*": ["*"] }, "strict": true }, diff --git a/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/tsconfig.json index 08991804950a..226e7be8555b 100644 --- a/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "baseUrl": ".", + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -12,7 +12,7 @@ "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, "paths": { - "@/*": ["*"] + "@/*": ["*"] }, "strict": true }, diff --git a/pkg/codegen/testing/test/testdata/regress-8403/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/regress-8403/nodejs/tsconfig.json index eceecdc9c256..d0facddb507d 100644 --- a/pkg/codegen/testing/test/testdata/regress-8403/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/regress-8403/nodejs/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "baseUrl": ".", + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -12,7 +12,7 @@ "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, "paths": { - "@/*": ["*"] + "@/*": ["*"] }, "strict": true }, diff --git a/pkg/codegen/testing/test/testdata/regress-node-8110/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/regress-node-8110/nodejs/tsconfig.json index 71926d03295d..837fd83b0078 100644 --- a/pkg/codegen/testing/test/testdata/regress-node-8110/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/regress-node-8110/nodejs/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "baseUrl": ".", + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -12,7 +12,7 @@ "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, "paths": { - "@/*": ["*"] + "@/*": ["*"] }, "strict": true }, diff --git a/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/cat.ts b/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/cat.ts index 79590ba71f09..2de39537fafb 100644 --- a/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/cat.ts +++ b/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/cat.ts @@ -6,7 +6,7 @@ import * as inputs from "./types/input"; import * as outputs from "./types/output"; import * as utilities from "./utilities"; -import { God } from "./index"; +import {God} from "./index"; export class Cat extends pulumi.CustomResource { /** diff --git a/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/god.ts b/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/god.ts index e4bee1e7a0f3..344344d9a08c 100644 --- a/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/god.ts +++ b/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/god.ts @@ -4,7 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as utilities from "./utilities"; -import { Dog } from "./index"; +import {Dog} from "./index"; export class God extends pulumi.CustomResource { /** diff --git a/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/toyStore.ts b/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/toyStore.ts index 6e81cb1de208..41b03e4ced19 100644 --- a/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/toyStore.ts +++ b/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/toyStore.ts @@ -6,7 +6,7 @@ import * as inputs from "./types/input"; import * as outputs from "./types/output"; import * as utilities from "./utilities"; -import { Cat, Dog } from "./index"; +import {Cat, Dog} from "./index"; export class ToyStore extends pulumi.CustomResource { /** diff --git a/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/tsconfig.json index cd4266b27f39..487a59f88046 100644 --- a/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "baseUrl": ".", + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -12,7 +12,7 @@ "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, "paths": { - "@/*": ["*"] + "@/*": ["*"] }, "strict": true }, diff --git a/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/types/input.ts index 76d7b802db6f..6966d245b39d 100644 --- a/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/types/input.ts @@ -6,5 +6,5 @@ import * as inputs from "../types/input"; import * as outputs from "../types/output"; import * as utilities from "../utilities"; -import { Cat, Dog } from ".."; +import {Cat, Dog} from ".."; diff --git a/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/types/output.ts index f2a5b8419dc9..273422fbe3a2 100644 --- a/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/types/output.ts @@ -6,7 +6,7 @@ import * as inputs from "../types/input"; import * as outputs from "../types/output"; import * as utilities from "../utilities"; -import { Cat, Dog } from ".."; +import {Cat, Dog} from ".."; /** * A toy for a dog diff --git a/pkg/codegen/testing/test/testdata/resource-args-python-case-insensitive/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/resource-args-python-case-insensitive/nodejs/tsconfig.json index 21a1de173a11..3e8040359228 100644 --- a/pkg/codegen/testing/test/testdata/resource-args-python-case-insensitive/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/resource-args-python-case-insensitive/nodejs/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "baseUrl": ".", + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -12,7 +12,7 @@ "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, "paths": { - "@/*": ["*"] + "@/*": ["*"] }, "strict": true }, diff --git a/pkg/codegen/testing/test/testdata/resource-args-python/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/resource-args-python/nodejs/tsconfig.json index 21a1de173a11..3e8040359228 100644 --- a/pkg/codegen/testing/test/testdata/resource-args-python/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/resource-args-python/nodejs/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "baseUrl": ".", + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -12,7 +12,7 @@ "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, "paths": { - "@/*": ["*"] + "@/*": ["*"] }, "strict": true }, diff --git a/pkg/codegen/testing/test/testdata/resource-property-overlap/nodejs/rec.ts b/pkg/codegen/testing/test/testdata/resource-property-overlap/nodejs/rec.ts index ace6cba1ed29..b6e2a8fcc134 100644 --- a/pkg/codegen/testing/test/testdata/resource-property-overlap/nodejs/rec.ts +++ b/pkg/codegen/testing/test/testdata/resource-property-overlap/nodejs/rec.ts @@ -4,7 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as utilities from "./utilities"; -import { Rec } from "./index"; +import {Rec} from "./index"; export class Rec extends pulumi.CustomResource { /** diff --git a/pkg/codegen/testing/test/testdata/resource-property-overlap/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/resource-property-overlap/nodejs/tsconfig.json index 77a81b7dc902..0e1595d0a29f 100644 --- a/pkg/codegen/testing/test/testdata/resource-property-overlap/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/resource-property-overlap/nodejs/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "baseUrl": ".", + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -12,7 +12,7 @@ "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, "paths": { - "@/*": ["*"] + "@/*": ["*"] }, "strict": true }, diff --git a/pkg/codegen/testing/test/testdata/secrets/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/secrets/nodejs/tsconfig.json index 1015caac19ee..86bf7a701a05 100644 --- a/pkg/codegen/testing/test/testdata/secrets/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/secrets/nodejs/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "baseUrl": ".", + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -12,7 +12,7 @@ "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, "paths": { - "@/*": ["*"] + "@/*": ["*"] }, "strict": true }, diff --git a/pkg/codegen/testing/test/testdata/simple-enum-schema/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/simple-enum-schema/nodejs/tsconfig.json index b681965746dc..844c4046f0fc 100644 --- a/pkg/codegen/testing/test/testdata/simple-enum-schema/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/simple-enum-schema/nodejs/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "baseUrl": ".", + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -12,7 +12,7 @@ "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, "paths": { - "@/*": ["*"] + "@/*": ["*"] }, "strict": true }, diff --git a/pkg/codegen/testing/test/testdata/simple-methods-schema-single-value-returns/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/simple-methods-schema-single-value-returns/nodejs/tsconfig.json index 20a4de65f339..3a608d2f5234 100644 --- a/pkg/codegen/testing/test/testdata/simple-methods-schema-single-value-returns/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/simple-methods-schema-single-value-returns/nodejs/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "baseUrl": ".", + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -12,7 +12,7 @@ "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, "paths": { - "@/*": ["*"] + "@/*": ["*"] }, "strict": true }, diff --git a/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/tsconfig.json index 19ce99b6536a..93e9c3ad2402 100644 --- a/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "baseUrl": ".", + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -12,7 +12,7 @@ "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, "paths": { - "@/*": ["*"] + "@/*": ["*"] }, "strict": true }, diff --git a/pkg/codegen/testing/test/testdata/simple-plain-schema-with-root-package/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/simple-plain-schema-with-root-package/nodejs/tsconfig.json index eec55a0bd4b7..940a0df17369 100644 --- a/pkg/codegen/testing/test/testdata/simple-plain-schema-with-root-package/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/simple-plain-schema-with-root-package/nodejs/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "baseUrl": ".", + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -12,7 +12,7 @@ "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, "paths": { - "@/*": ["*"] + "@/*": ["*"] }, "strict": true }, diff --git a/pkg/codegen/testing/test/testdata/simple-plain-schema/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/simple-plain-schema/nodejs/tsconfig.json index d053a0093b81..b268cc2f2df6 100644 --- a/pkg/codegen/testing/test/testdata/simple-plain-schema/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/simple-plain-schema/nodejs/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "baseUrl": ".", + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -12,7 +12,7 @@ "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, "paths": { - "@/*": ["*"] + "@/*": ["*"] }, "strict": true }, diff --git a/pkg/codegen/testing/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/argFunction.ts b/pkg/codegen/testing/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/argFunction.ts index 571906cf70c1..9ee7378b83a4 100644 --- a/pkg/codegen/testing/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/argFunction.ts +++ b/pkg/codegen/testing/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/argFunction.ts @@ -4,7 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as utilities from "./utilities"; -import { Resource } from "./index"; +import {Resource} from "./index"; export function argFunction(args?: ArgFunctionArgs, opts?: pulumi.InvokeOptions): Promise { args = args || {}; diff --git a/pkg/codegen/testing/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/otherResource.ts b/pkg/codegen/testing/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/otherResource.ts index 6a7dc3eb336c..6ad577a6338b 100644 --- a/pkg/codegen/testing/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/otherResource.ts +++ b/pkg/codegen/testing/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/otherResource.ts @@ -4,7 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as utilities from "./utilities"; -import { Resource } from "./index"; +import {Resource} from "./index"; export class OtherResource extends pulumi.ComponentResource { /** @internal */ diff --git a/pkg/codegen/testing/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/tsconfig.json index c2206251144e..d13962bbd52f 100644 --- a/pkg/codegen/testing/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "baseUrl": ".", + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -12,7 +12,7 @@ "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, "paths": { - "@/*": ["*"] + "@/*": ["*"] }, "strict": true }, diff --git a/pkg/codegen/testing/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/types/input.ts index d4a1642f95af..6615b1d2911f 100644 --- a/pkg/codegen/testing/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/types/input.ts @@ -6,5 +6,5 @@ import * as inputs from "../types/input"; import * as outputs from "../types/output"; import * as utilities from "../utilities"; -import { Resource } from ".."; +import {Resource} from ".."; diff --git a/pkg/codegen/testing/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/types/output.ts index d4a1642f95af..6615b1d2911f 100644 --- a/pkg/codegen/testing/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/types/output.ts @@ -6,5 +6,5 @@ import * as inputs from "../types/input"; import * as outputs from "../types/output"; import * as utilities from "../utilities"; -import { Resource } from ".."; +import {Resource} from ".."; diff --git a/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/argFunction.ts b/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/argFunction.ts index 571906cf70c1..9ee7378b83a4 100644 --- a/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/argFunction.ts +++ b/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/argFunction.ts @@ -4,7 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as utilities from "./utilities"; -import { Resource } from "./index"; +import {Resource} from "./index"; export function argFunction(args?: ArgFunctionArgs, opts?: pulumi.InvokeOptions): Promise { args = args || {}; diff --git a/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/barResource.ts b/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/barResource.ts index a8cd6de6bcdb..51e9d4366cd2 100644 --- a/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/barResource.ts +++ b/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/barResource.ts @@ -4,7 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as utilities from "./utilities"; -import { Resource } from "./index"; +import {Resource} from "./index"; export class BarResource extends pulumi.ComponentResource { /** @internal */ diff --git a/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/fooResource.ts b/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/fooResource.ts index a644eeb2cef5..5ffb358d782b 100644 --- a/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/fooResource.ts +++ b/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/fooResource.ts @@ -4,7 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as utilities from "./utilities"; -import { Resource } from "./index"; +import {Resource} from "./index"; export class FooResource extends pulumi.ComponentResource { /** @internal */ diff --git a/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/otherResource.ts b/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/otherResource.ts index 6a7dc3eb336c..6ad577a6338b 100644 --- a/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/otherResource.ts +++ b/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/otherResource.ts @@ -4,7 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as utilities from "./utilities"; -import { Resource } from "./index"; +import {Resource} from "./index"; export class OtherResource extends pulumi.ComponentResource { /** @internal */ diff --git a/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/tsconfig.json index 3245e24e830f..b51118145c0b 100644 --- a/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "baseUrl": ".", + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -12,7 +12,7 @@ "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, "paths": { - "@/*": ["*"] + "@/*": ["*"] }, "strict": true }, diff --git a/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/typeUses.ts b/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/typeUses.ts index 21478d3daed2..136e79e01786 100644 --- a/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/typeUses.ts +++ b/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/typeUses.ts @@ -6,7 +6,7 @@ import * as inputs from "./types/input"; import * as outputs from "./types/output"; import * as utilities from "./utilities"; -import { Resource } from "./index"; +import {Resource} from "./index"; export class TypeUses extends pulumi.CustomResource { /** diff --git a/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/types/input.ts index 134e4311a531..ea24d93f683c 100644 --- a/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/types/input.ts @@ -6,7 +6,7 @@ import * as inputs from "../types/input"; import * as outputs from "../types/output"; import * as utilities from "../utilities"; -import { Resource } from ".."; +import {Resource} from ".."; export interface ConfigMapArgs { config?: pulumi.Input; diff --git a/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/types/output.ts index bd1b8c9165c3..06a803f01d6e 100644 --- a/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/types/output.ts @@ -6,7 +6,7 @@ import * as inputs from "../types/input"; import * as outputs from "../types/output"; import * as utilities from "../utilities"; -import { Resource } from ".."; +import {Resource} from ".."; export interface ConfigMap { config?: string; diff --git a/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/argFunction.ts b/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/argFunction.ts index 571906cf70c1..9ee7378b83a4 100644 --- a/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/argFunction.ts +++ b/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/argFunction.ts @@ -4,7 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as utilities from "./utilities"; -import { Resource } from "./index"; +import {Resource} from "./index"; export function argFunction(args?: ArgFunctionArgs, opts?: pulumi.InvokeOptions): Promise { args = args || {}; diff --git a/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/otherResource.ts b/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/otherResource.ts index 6a10bce2066e..016b4792ce14 100644 --- a/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/otherResource.ts +++ b/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/otherResource.ts @@ -4,7 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as utilities from "./utilities"; -import { Resource } from "./index"; +import {Resource} from "./index"; export class OtherResource extends pulumi.ComponentResource { /** @internal */ diff --git a/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/tsconfig.json index ca382b1654a9..67f0228a80e9 100644 --- a/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "baseUrl": ".", + "baseUrl": ".", "outDir": "bin", "target": "es2016", "module": "commonjs", @@ -12,7 +12,7 @@ "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, "paths": { - "@/*": ["*"] + "@/*": ["*"] }, "strict": true }, diff --git a/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/typeUses.ts b/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/typeUses.ts index d9c08cf332ed..3a42862b0a7e 100644 --- a/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/typeUses.ts +++ b/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/typeUses.ts @@ -7,7 +7,7 @@ import * as outputs from "./types/output"; import * as enums from "./types/enums"; import * as utilities from "./utilities"; -import { Resource } from "./index"; +import {Resource} from "./index"; export class TypeUses extends pulumi.CustomResource { /** diff --git a/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/types/input.ts index 865bfdfd54bd..774b7916ca54 100644 --- a/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/types/input.ts @@ -7,7 +7,7 @@ import * as outputs from "../types/output"; import * as enums from "../types/enums"; import * as utilities from "../utilities"; -import { Resource } from ".."; +import {Resource} from ".."; export interface ConfigMapArgs { config?: pulumi.Input; diff --git a/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/types/output.ts index 6edc0e87f7c1..06d28a71e5cc 100644 --- a/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/types/output.ts @@ -7,7 +7,7 @@ import * as outputs from "../types/output"; import * as enums from "../types/enums"; import * as utilities from "../utilities"; -import { Resource } from ".."; +import {Resource} from ".."; export interface ConfigMap { config?: string; From 9fb2da3d81e5be12e42c3ab0e3ebb0dae8248fdb Mon Sep 17 00:00:00 2001 From: Robbie McKinstry Date: Thu, 10 Nov 2022 21:19:38 -0500 Subject: [PATCH 15/16] Add new acceptance test for nodejs tsconfig path aliasing --- pkg/codegen/nodejs/gen.go | 4 +- pkg/codegen/testing/test/sdk_driver.go | 6 ++ .../type-references-resource/nodejs/README.md | 0 .../nodejs/codegen-manifest.json | 19 ++++++ .../type-references-resource/nodejs/index.ts | 30 +++++++++ .../nodejs/my_mod/index.ts | 25 +++++++ .../nodejs/my_mod/triceratops.ts | 63 ++++++++++++++++++ .../nodejs/package.json | 18 +++++ .../nodejs/provider.ts | 44 +++++++++++++ .../nodejs/scripts/install-pulumi-plugin.js | 26 ++++++++ .../nodejs/tsconfig.json | 32 +++++++++ .../nodejs/types/index.ts | 13 ++++ .../nodejs/types/input.ts | 11 ++++ .../nodejs/types/my_mod/index.ts | 3 + .../nodejs/types/my_mod/input.ts | 10 +++ .../nodejs/types/my_mod/output.ts | 10 +++ .../nodejs/types/output.ts | 11 ++++ .../nodejs/utilities.ts | 66 +++++++++++++++++++ .../type-references-resource/schema.json | 47 +++++++++++++ 19 files changed, 436 insertions(+), 2 deletions(-) create mode 100644 pkg/codegen/testing/test/testdata/type-references-resource/nodejs/README.md create mode 100644 pkg/codegen/testing/test/testdata/type-references-resource/nodejs/codegen-manifest.json create mode 100644 pkg/codegen/testing/test/testdata/type-references-resource/nodejs/index.ts create mode 100644 pkg/codegen/testing/test/testdata/type-references-resource/nodejs/my_mod/index.ts create mode 100644 pkg/codegen/testing/test/testdata/type-references-resource/nodejs/my_mod/triceratops.ts create mode 100644 pkg/codegen/testing/test/testdata/type-references-resource/nodejs/package.json create mode 100644 pkg/codegen/testing/test/testdata/type-references-resource/nodejs/provider.ts create mode 100644 pkg/codegen/testing/test/testdata/type-references-resource/nodejs/scripts/install-pulumi-plugin.js create mode 100644 pkg/codegen/testing/test/testdata/type-references-resource/nodejs/tsconfig.json create mode 100644 pkg/codegen/testing/test/testdata/type-references-resource/nodejs/types/index.ts create mode 100644 pkg/codegen/testing/test/testdata/type-references-resource/nodejs/types/input.ts create mode 100644 pkg/codegen/testing/test/testdata/type-references-resource/nodejs/types/my_mod/index.ts create mode 100644 pkg/codegen/testing/test/testdata/type-references-resource/nodejs/types/my_mod/input.ts create mode 100644 pkg/codegen/testing/test/testdata/type-references-resource/nodejs/types/my_mod/output.ts create mode 100644 pkg/codegen/testing/test/testdata/type-references-resource/nodejs/types/output.ts create mode 100644 pkg/codegen/testing/test/testdata/type-references-resource/nodejs/utilities.ts create mode 100644 pkg/codegen/testing/test/testdata/type-references-resource/schema.json diff --git a/pkg/codegen/nodejs/gen.go b/pkg/codegen/nodejs/gen.go index be726aca09c7..5f434c3ba491 100644 --- a/pkg/codegen/nodejs/gen.go +++ b/pkg/codegen/nodejs/gen.go @@ -2591,9 +2591,9 @@ func genTypeScriptProjectFile(info NodePackageInfo, files codegen.Fs) string { "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, - "paths": { + "paths": { "@/*": ["*"] - }, + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/sdk_driver.go b/pkg/codegen/testing/test/sdk_driver.go index a105126bb887..259cd3e4d5b9 100644 --- a/pkg/codegen/testing/test/sdk_driver.go +++ b/pkg/codegen/testing/test/sdk_driver.go @@ -164,6 +164,12 @@ var PulumiPulumiSDKTests = []*SDKTest{ Description: "A resource with the same name as its property", SkipCompileCheck: codegen.NewStringSet(dotnet, nodejs), }, + { + Directory: "type-references-resource", + Description: "An instance where a type references a resource", + Skip: allLanguages.Except("nodejs/any"), + // SkipCompileCheck: codegen.NewStringSet(dotnet, golang, python), + }, { Directory: "hyphen-url", Description: "A resource url with a hyphen in its path", diff --git a/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/README.md b/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/README.md new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/codegen-manifest.json b/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/codegen-manifest.json new file mode 100644 index 000000000000..b4e5513101a2 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/codegen-manifest.json @@ -0,0 +1,19 @@ +{ + "emittedFiles": [ + "README.md", + "index.ts", + "my_mod/index.ts", + "my_mod/triceratops.ts", + "package.json", + "provider.ts", + "scripts/install-pulumi-plugin.js", + "tsconfig.json", + "types/index.ts", + "types/input.ts", + "types/my_mod/index.ts", + "types/my_mod/input.ts", + "types/my_mod/output.ts", + "types/output.ts", + "utilities.ts" + ] +} diff --git a/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/index.ts b/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/index.ts new file mode 100644 index 000000000000..49de88cb48a9 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/index.ts @@ -0,0 +1,30 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +import * as pulumi from "@pulumi/pulumi"; +import * as utilities from "./utilities"; + +// Export members: +export { ProviderArgs } from "./provider"; +export type Provider = import("./provider").Provider; +export const Provider: typeof import("./provider").Provider = null as any; +utilities.lazyLoad(exports, ["Provider"], () => require("./provider")); + + +// Export sub-modules: +import * as my_mod from "./my_mod"; +import * as types from "./types"; + +export { + my_mod, + types, +}; +pulumi.runtime.registerResourcePackage("dinosaurs", { + version: utilities.getVersion(), + constructProvider: (name: string, type: string, urn: string): pulumi.ProviderResource => { + if (type !== "pulumi:providers:dinosaurs") { + throw new Error(`unknown provider type ${type}`); + } + return new Provider(name, undefined, { urn }); + }, +}); diff --git a/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/my_mod/index.ts b/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/my_mod/index.ts new file mode 100644 index 000000000000..1af01116c275 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/my_mod/index.ts @@ -0,0 +1,25 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +import * as pulumi from "@pulumi/pulumi"; +import * as utilities from "../utilities"; + +// Export members: +export { TriceratopsArgs } from "./triceratops"; +export type Triceratops = import("./triceratops").Triceratops; +export const Triceratops: typeof import("./triceratops").Triceratops = null as any; +utilities.lazyLoad(exports, ["Triceratops"], () => require("./triceratops")); + + +const _module = { + version: utilities.getVersion(), + construct: (name: string, type: string, urn: string): pulumi.Resource => { + switch (type) { + case "dinosaurs:my_mod:Triceratops": + return new Triceratops(name, undefined, { urn }) + default: + throw new Error(`unknown resource type ${type}`); + } + }, +}; +pulumi.runtime.registerResourceModule("dinosaurs", "my_mod", _module) diff --git a/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/my_mod/triceratops.ts b/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/my_mod/triceratops.ts new file mode 100644 index 000000000000..2f889b43dfb0 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/my_mod/triceratops.ts @@ -0,0 +1,63 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +import * as pulumi from "@pulumi/pulumi"; +import * as utilities from "../utilities"; + +/** + * My favorite dino + */ +export class Triceratops extends pulumi.CustomResource { + /** + * Get an existing Triceratops resource's state with the given name, ID, and optional extra + * properties used to qualify the lookup. + * + * @param name The _unique_ name of the resulting resource. + * @param id The _unique_ provider ID of the resource to lookup. + * @param opts Optional settings to control the behavior of the CustomResource. + */ + public static get(name: string, id: pulumi.Input, opts?: pulumi.CustomResourceOptions): Triceratops { + return new Triceratops(name, undefined as any, { ...opts, id: id }); + } + + /** @internal */ + public static readonly __pulumiType = 'dinosaurs:my_mod:Triceratops'; + + /** + * Returns true if the given object is an instance of Triceratops. This is designed to work even + * when multiple copies of the Pulumi SDK have been loaded into the same process. + */ + public static isInstance(obj: any): obj is Triceratops { + if (obj === undefined || obj === null) { + return false; + } + return obj['__pulumiType'] === Triceratops.__pulumiType; + } + + public /*out*/ readonly size!: pulumi.Output; + + /** + * Create a Triceratops resource with the given unique name, arguments, and options. + * + * @param name The _unique_ name of the resource. + * @param args The arguments to use to populate this resource's properties. + * @param opts A bag of options that control this resource's behavior. + */ + constructor(name: string, args?: TriceratopsArgs, opts?: pulumi.CustomResourceOptions) { + let resourceInputs: pulumi.Inputs = {}; + opts = opts || {}; + if (!opts.id) { + resourceInputs["size"] = undefined /*out*/; + } else { + resourceInputs["size"] = undefined /*out*/; + } + opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); + super(Triceratops.__pulumiType, name, resourceInputs, opts); + } +} + +/** + * The set of arguments for constructing a Triceratops resource. + */ +export interface TriceratopsArgs { +} diff --git a/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/package.json b/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/package.json new file mode 100644 index 000000000000..80cb461cb338 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/package.json @@ -0,0 +1,18 @@ +{ + "name": "@pulumi/dinosaurs", + "version": "${VERSION}", + "scripts": { + "build": "tsc", + "install": "node scripts/install-pulumi-plugin.js resource dinosaurs ${VERSION}" + }, + "dependencies": { + "@pulumi/pulumi": "^3.12" + }, + "devDependencies": { + "typescript": "^3.7.0" + }, + "pulumi": { + "resource": true, + "name": "dinosaurs" + } +} diff --git a/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/provider.ts b/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/provider.ts new file mode 100644 index 000000000000..8ec4b88027a6 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/provider.ts @@ -0,0 +1,44 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +import * as pulumi from "@pulumi/pulumi"; +import * as utilities from "./utilities"; + +export class Provider extends pulumi.ProviderResource { + /** @internal */ + public static readonly __pulumiType = 'dinosaurs'; + + /** + * Returns true if the given object is an instance of Provider. This is designed to work even + * when multiple copies of the Pulumi SDK have been loaded into the same process. + */ + public static isInstance(obj: any): obj is Provider { + if (obj === undefined || obj === null) { + return false; + } + return obj['__pulumiType'] === Provider.__pulumiType; + } + + + /** + * Create a Provider resource with the given unique name, arguments, and options. + * + * @param name The _unique_ name of the resource. + * @param args The arguments to use to populate this resource's properties. + * @param opts A bag of options that control this resource's behavior. + */ + constructor(name: string, args?: ProviderArgs, opts?: pulumi.ResourceOptions) { + let resourceInputs: pulumi.Inputs = {}; + opts = opts || {}; + { + } + opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); + super(Provider.__pulumiType, name, resourceInputs, opts); + } +} + +/** + * The set of arguments for constructing a Provider resource. + */ +export interface ProviderArgs { +} diff --git a/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/scripts/install-pulumi-plugin.js b/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/scripts/install-pulumi-plugin.js new file mode 100644 index 000000000000..fefc6e0eb097 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/scripts/install-pulumi-plugin.js @@ -0,0 +1,26 @@ +"use strict"; +var childProcess = require("child_process"); + +var args = process.argv.slice(2); + +if (args.indexOf("${VERSION}") !== -1) { + process.exit(0); +} + +var res = childProcess.spawnSync("pulumi", ["plugin", "install"].concat(args), { + stdio: ["ignore", "inherit", "inherit"] +}); + +if (res.error && res.error.code === "ENOENT") { + console.error("\nThere was an error installing the resource provider plugin. " + + "It looks like `pulumi` is not installed on your system. " + + "Please visit https://pulumi.com/ to install the Pulumi CLI.\n" + + "You may try manually installing the plugin by running " + + "`pulumi plugin install " + args.join(" ") + "`"); +} else if (res.error || res.status !== 0) { + console.error("\nThere was an error installing the resource provider plugin. " + + "You may try to manually installing the plugin by running " + + "`pulumi plugin install " + args.join(" ") + "`"); +} + +process.exit(0); diff --git a/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/tsconfig.json new file mode 100644 index 000000000000..ee2af7b52fa8 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/tsconfig.json @@ -0,0 +1,32 @@ +{ + "compilerOptions": { + "baseUrl": ".", + "outDir": "bin", + "target": "es2016", + "module": "commonjs", + "moduleResolution": "node", + "declaration": true, + "sourceMap": true, + "stripInternal": true, + "experimentalDecorators": true, + "noFallthroughCasesInSwitch": true, + "forceConsistentCasingInFileNames": true, + "paths": { + "@/*": ["*"] + }, + "strict": true + }, + "files": [ + "index.ts", + "my_mod/index.ts", + "my_mod/triceratops.ts", + "provider.ts", + "types/index.ts", + "types/input.ts", + "types/my_mod/index.ts", + "types/my_mod/input.ts", + "types/my_mod/output.ts", + "types/output.ts", + "utilities.ts" + ] +} diff --git a/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/types/index.ts b/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/types/index.ts new file mode 100644 index 000000000000..d1f303f60379 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/types/index.ts @@ -0,0 +1,13 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +import * as utilities from "../utilities"; + +// Export sub-modules: +import * as input from "./input"; +import * as output from "./output"; + +export { + input, + output, +}; diff --git a/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/types/input.ts new file mode 100644 index 000000000000..48d0c42e5692 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/types/input.ts @@ -0,0 +1,11 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +import * as pulumi from "@pulumi/pulumi"; +import * as inputs from "../types/input"; +import * as outputs from "../types/output"; +import * as utilities from "../utilities"; + +import {Triceratops} from "@/my_mod"; + +export * as my_mod from "./my_mod/input"; diff --git a/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/types/my_mod/index.ts b/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/types/my_mod/index.ts new file mode 100644 index 000000000000..b7b2ea440d9f --- /dev/null +++ b/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/types/my_mod/index.ts @@ -0,0 +1,3 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + diff --git a/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/types/my_mod/input.ts b/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/types/my_mod/input.ts new file mode 100644 index 000000000000..79d8d682639c --- /dev/null +++ b/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/types/my_mod/input.ts @@ -0,0 +1,10 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +import * as pulumi from "@pulumi/pulumi"; +import * as inputs from "../../types/input"; +import * as outputs from "../../types/output"; +import * as utilities from "../../utilities"; + +import {Triceratops} from "@/my_mod"; + diff --git a/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/types/my_mod/output.ts b/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/types/my_mod/output.ts new file mode 100644 index 000000000000..79d8d682639c --- /dev/null +++ b/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/types/my_mod/output.ts @@ -0,0 +1,10 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +import * as pulumi from "@pulumi/pulumi"; +import * as inputs from "../../types/input"; +import * as outputs from "../../types/output"; +import * as utilities from "../../utilities"; + +import {Triceratops} from "@/my_mod"; + diff --git a/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/types/output.ts new file mode 100644 index 000000000000..e1a0a5d08f58 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/types/output.ts @@ -0,0 +1,11 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +import * as pulumi from "@pulumi/pulumi"; +import * as inputs from "../types/input"; +import * as outputs from "../types/output"; +import * as utilities from "../utilities"; + +import {Triceratops} from "@/my_mod"; + +export * as my_mod from "./my_mod/output"; diff --git a/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/utilities.ts b/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/utilities.ts new file mode 100644 index 000000000000..fae1054b6bab --- /dev/null +++ b/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/utilities.ts @@ -0,0 +1,66 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + + +export function getEnv(...vars: string[]): string | undefined { + for (const v of vars) { + const value = process.env[v]; + if (value) { + return value; + } + } + return undefined; +} + +export function getEnvBoolean(...vars: string[]): boolean | undefined { + const s = getEnv(...vars); + if (s !== undefined) { + // NOTE: these values are taken from https://golang.org/src/strconv/atob.go?s=351:391#L1, which is what + // Terraform uses internally when parsing boolean values. + if (["1", "t", "T", "true", "TRUE", "True"].find(v => v === s) !== undefined) { + return true; + } + if (["0", "f", "F", "false", "FALSE", "False"].find(v => v === s) !== undefined) { + return false; + } + } + return undefined; +} + +export function getEnvNumber(...vars: string[]): number | undefined { + const s = getEnv(...vars); + if (s !== undefined) { + const f = parseFloat(s); + if (!isNaN(f)) { + return f; + } + } + return undefined; +} + +export function getVersion(): string { + let version = require('./package.json').version; + // Node allows for the version to be prefixed by a "v", while semver doesn't. + // If there is a v, strip it off. + if (version.indexOf('v') === 0) { + version = version.slice(1); + } + return version; +} + +/** @internal */ +export function resourceOptsDefaults(): any { + return { version: getVersion() }; +} + +/** @internal */ +export function lazyLoad(exports: any, props: string[], loadModule: any) { + for (let property of props) { + Object.defineProperty(exports, property, { + enumerable: true, + get: function() { + return loadModule()[property]; + }, + }); + } +} diff --git a/pkg/codegen/testing/test/testdata/type-references-resource/schema.json b/pkg/codegen/testing/test/testdata/type-references-resource/schema.json new file mode 100644 index 000000000000..546954669410 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/type-references-resource/schema.json @@ -0,0 +1,47 @@ +{ + "version": "0.0.1", + "name": "dinosaurs", + "types": { + "dinosaurs:my_mod:BigDino": { + "description": "A big dinosaur", + "properties": { + "kind": { + "$ref": "#/types/dinosaurs:my_mod:Triceratops" + } + }, + "type": "object" + } + }, + "resources": { + "dinosaurs:my_mod:Triceratops": { + "description": "My favorite dino", + "properties": { + "size": { + "type": "integer" + } + }, + "type": "object" + } + }, + "functions": {}, + "language": { + "csharp": { + "projectReferences": [ + "..\\..\\..\\..\\..\\..\\..\\sdk\\dotnet\\Pulumi\\Pulumi.csproj" + ] + }, + "go": { + "importBasePath": "github.com/pulumi/pulumi/pkg/v3/codegen/testing/test/testdata/type-references-resource/go/example", + "generateExtraInputTypes": true + }, + "nodejs": { + "dependencies": { + "@pulumi/pulumi": "^3.12" + }, + "devDependencies": { + "typescript": "^3.7.0" + } + }, + "python": {} + } +} From a07a250cc1dc3c2f05b6ac875a4216ce4db1661d Mon Sep 17 00:00:00 2001 From: Robbie McKinstry Date: Thu, 10 Nov 2022 21:40:33 -0500 Subject: [PATCH 16/16] Regen code with consistent spacing in tsconfig --- .../testdata/azure-native-nested-types/nodejs/tsconfig.json | 4 ++-- .../testing/test/testdata/cyclic-types/nodejs/tsconfig.json | 4 ++-- .../test/testdata/dash-named-schema/nodejs/tsconfig.json | 4 ++-- .../test/testdata/dashed-import-schema/nodejs/tsconfig.json | 4 ++-- .../testing/test/testdata/different-enum/nodejs/tsconfig.json | 4 ++-- .../testing/test/testdata/enum-reference/nodejs/tsconfig.json | 4 ++-- .../testing/test/testdata/external-enum/nodejs/tsconfig.json | 4 ++-- .../testdata/external-node-compatibility/nodejs/tsconfig.json | 4 ++-- .../testdata/external-resource-schema/nodejs/tsconfig.json | 4 ++-- .../test/testdata/functions-secrets/nodejs/tsconfig.json | 4 ++-- .../testing/test/testdata/hyphen-url/nodejs/tsconfig.json | 4 ++-- .../test/testdata/naming-collisions/nodejs/tsconfig.json | 4 ++-- .../testdata/nested-module-thirdparty/nodejs/tsconfig.json | 4 ++-- .../testing/test/testdata/nested-module/nodejs/tsconfig.json | 4 ++-- .../test/testdata/output-funcs-edgeorder/nodejs/tsconfig.json | 4 ++-- .../testdata/output-funcs-tfbridge20/nodejs/tsconfig.json | 4 ++-- .../testing/test/testdata/output-funcs/nodejs/tsconfig.json | 4 ++-- .../test/testdata/plain-and-default/nodejs/tsconfig.json | 4 ++-- .../test/testdata/plain-object-defaults/nodejs/tsconfig.json | 4 ++-- .../plain-object-disable-defaults/nodejs/tsconfig.json | 4 ++-- .../test/testdata/plain-schema-gh6957/nodejs/tsconfig.json | 4 ++-- .../test/testdata/provider-config-schema/nodejs/tsconfig.json | 4 ++-- .../testing/test/testdata/regress-8403/nodejs/tsconfig.json | 4 ++-- .../test/testdata/regress-node-8110/nodejs/tsconfig.json | 4 ++-- .../test/testdata/replace-on-change/nodejs/tsconfig.json | 4 ++-- .../nodejs/tsconfig.json | 4 ++-- .../test/testdata/resource-args-python/nodejs/tsconfig.json | 4 ++-- .../testdata/resource-property-overlap/nodejs/tsconfig.json | 4 ++-- .../testing/test/testdata/secrets/nodejs/tsconfig.json | 4 ++-- .../test/testdata/simple-enum-schema/nodejs/tsconfig.json | 4 ++-- .../nodejs/tsconfig.json | 4 ++-- .../test/testdata/simple-methods-schema/nodejs/tsconfig.json | 4 ++-- .../nodejs/tsconfig.json | 4 ++-- .../test/testdata/simple-plain-schema/nodejs/tsconfig.json | 4 ++-- .../nodejs/tsconfig.json | 4 ++-- .../test/testdata/simple-resource-schema/nodejs/tsconfig.json | 4 ++-- .../test/testdata/simple-yaml-schema/nodejs/tsconfig.json | 4 ++-- .../testdata/type-references-resource/nodejs/package.json | 1 + .../testdata/type-references-resource/nodejs/tsconfig.json | 4 ++-- 39 files changed, 77 insertions(+), 76 deletions(-) diff --git a/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/tsconfig.json index 7c2e3887ca86..d95d956a1532 100644 --- a/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/tsconfig.json @@ -11,9 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, - "paths": { + "paths": { "@/*": ["*"] - }, + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/cyclic-types/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/cyclic-types/nodejs/tsconfig.json index 916a5dea0051..86410fd0afff 100644 --- a/pkg/codegen/testing/test/testdata/cyclic-types/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/cyclic-types/nodejs/tsconfig.json @@ -11,9 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, - "paths": { + "paths": { "@/*": ["*"] - }, + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/dash-named-schema/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/dash-named-schema/nodejs/tsconfig.json index 4a9e24a7beae..e2d149792e4b 100644 --- a/pkg/codegen/testing/test/testdata/dash-named-schema/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/dash-named-schema/nodejs/tsconfig.json @@ -11,9 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, - "paths": { + "paths": { "@/*": ["*"] - }, + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/dashed-import-schema/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/dashed-import-schema/nodejs/tsconfig.json index 844c4046f0fc..6b7fd81ee898 100644 --- a/pkg/codegen/testing/test/testdata/dashed-import-schema/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/dashed-import-schema/nodejs/tsconfig.json @@ -11,9 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, - "paths": { + "paths": { "@/*": ["*"] - }, + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/different-enum/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/different-enum/nodejs/tsconfig.json index 844c4046f0fc..6b7fd81ee898 100644 --- a/pkg/codegen/testing/test/testdata/different-enum/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/different-enum/nodejs/tsconfig.json @@ -11,9 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, - "paths": { + "paths": { "@/*": ["*"] - }, + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/enum-reference/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/enum-reference/nodejs/tsconfig.json index fbafb01f54af..55e6eff32591 100644 --- a/pkg/codegen/testing/test/testdata/enum-reference/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/enum-reference/nodejs/tsconfig.json @@ -11,9 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, - "paths": { + "paths": { "@/*": ["*"] - }, + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/external-enum/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/external-enum/nodejs/tsconfig.json index 91ddbb95be38..5da69d738206 100644 --- a/pkg/codegen/testing/test/testdata/external-enum/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/external-enum/nodejs/tsconfig.json @@ -11,9 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, - "paths": { + "paths": { "@/*": ["*"] - }, + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/external-node-compatibility/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/external-node-compatibility/nodejs/tsconfig.json index 3a608d2f5234..7161a2622dd2 100644 --- a/pkg/codegen/testing/test/testdata/external-node-compatibility/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/external-node-compatibility/nodejs/tsconfig.json @@ -11,9 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, - "paths": { + "paths": { "@/*": ["*"] - }, + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/external-resource-schema/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/external-resource-schema/nodejs/tsconfig.json index fd55cfdb470b..6dc424dca798 100644 --- a/pkg/codegen/testing/test/testdata/external-resource-schema/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/external-resource-schema/nodejs/tsconfig.json @@ -11,9 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, - "paths": { + "paths": { "@/*": ["*"] - }, + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/functions-secrets/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/functions-secrets/nodejs/tsconfig.json index 3719726840e7..dded1c7c6c64 100644 --- a/pkg/codegen/testing/test/testdata/functions-secrets/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/functions-secrets/nodejs/tsconfig.json @@ -11,9 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, - "paths": { + "paths": { "@/*": ["*"] - }, + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/hyphen-url/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/hyphen-url/nodejs/tsconfig.json index 575795869a69..4dd5b4972106 100644 --- a/pkg/codegen/testing/test/testdata/hyphen-url/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/hyphen-url/nodejs/tsconfig.json @@ -11,9 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, - "paths": { + "paths": { "@/*": ["*"] - }, + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/naming-collisions/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/naming-collisions/nodejs/tsconfig.json index 7b40b0d07c6f..982b2533a963 100644 --- a/pkg/codegen/testing/test/testdata/naming-collisions/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/naming-collisions/nodejs/tsconfig.json @@ -11,9 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, - "paths": { + "paths": { "@/*": ["*"] - }, + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/nested-module-thirdparty/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/nested-module-thirdparty/nodejs/tsconfig.json index 520ef06c6d89..422f5aa58e17 100644 --- a/pkg/codegen/testing/test/testdata/nested-module-thirdparty/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/nested-module-thirdparty/nodejs/tsconfig.json @@ -11,9 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, - "paths": { + "paths": { "@/*": ["*"] - }, + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/nested-module/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/nested-module/nodejs/tsconfig.json index 2f057593d072..15f15b7345fb 100644 --- a/pkg/codegen/testing/test/testdata/nested-module/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/nested-module/nodejs/tsconfig.json @@ -11,9 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, - "paths": { + "paths": { "@/*": ["*"] - }, + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/output-funcs-edgeorder/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/output-funcs-edgeorder/nodejs/tsconfig.json index 5b4bd1d83362..2dc5e6e81625 100644 --- a/pkg/codegen/testing/test/testdata/output-funcs-edgeorder/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/output-funcs-edgeorder/nodejs/tsconfig.json @@ -11,9 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, - "paths": { + "paths": { "@/*": ["*"] - }, + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/output-funcs-tfbridge20/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/output-funcs-tfbridge20/nodejs/tsconfig.json index b86311be344b..b25ec71a3f49 100644 --- a/pkg/codegen/testing/test/testdata/output-funcs-tfbridge20/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/output-funcs-tfbridge20/nodejs/tsconfig.json @@ -11,9 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, - "paths": { + "paths": { "@/*": ["*"] - }, + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/output-funcs/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/output-funcs/nodejs/tsconfig.json index 3d0077d89067..45bcb384737a 100644 --- a/pkg/codegen/testing/test/testdata/output-funcs/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/output-funcs/nodejs/tsconfig.json @@ -11,9 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, - "paths": { + "paths": { "@/*": ["*"] - }, + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/plain-and-default/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/plain-and-default/nodejs/tsconfig.json index 316628b2fc57..3da835f281fc 100644 --- a/pkg/codegen/testing/test/testdata/plain-and-default/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/plain-and-default/nodejs/tsconfig.json @@ -11,9 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, - "paths": { + "paths": { "@/*": ["*"] - }, + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/tsconfig.json index 31dbab748a01..a7c273fa3b97 100644 --- a/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/tsconfig.json @@ -11,9 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, - "paths": { + "paths": { "@/*": ["*"] - }, + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/tsconfig.json index 31dbab748a01..a7c273fa3b97 100644 --- a/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/tsconfig.json @@ -11,9 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, - "paths": { + "paths": { "@/*": ["*"] - }, + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/plain-schema-gh6957/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/plain-schema-gh6957/nodejs/tsconfig.json index 6f7dd24d3766..bd3a1d1fc00a 100644 --- a/pkg/codegen/testing/test/testdata/plain-schema-gh6957/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/plain-schema-gh6957/nodejs/tsconfig.json @@ -11,9 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, - "paths": { + "paths": { "@/*": ["*"] - }, + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/tsconfig.json index 226e7be8555b..37e41c201314 100644 --- a/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/tsconfig.json @@ -11,9 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, - "paths": { + "paths": { "@/*": ["*"] - }, + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/regress-8403/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/regress-8403/nodejs/tsconfig.json index d0facddb507d..8209dedaf392 100644 --- a/pkg/codegen/testing/test/testdata/regress-8403/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/regress-8403/nodejs/tsconfig.json @@ -11,9 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, - "paths": { + "paths": { "@/*": ["*"] - }, + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/regress-node-8110/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/regress-node-8110/nodejs/tsconfig.json index 837fd83b0078..3f293b469740 100644 --- a/pkg/codegen/testing/test/testdata/regress-node-8110/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/regress-node-8110/nodejs/tsconfig.json @@ -11,9 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, - "paths": { + "paths": { "@/*": ["*"] - }, + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/tsconfig.json index 487a59f88046..9eb841aad40d 100644 --- a/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/tsconfig.json @@ -11,9 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, - "paths": { + "paths": { "@/*": ["*"] - }, + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/resource-args-python-case-insensitive/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/resource-args-python-case-insensitive/nodejs/tsconfig.json index 3e8040359228..dc46369ac6d8 100644 --- a/pkg/codegen/testing/test/testdata/resource-args-python-case-insensitive/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/resource-args-python-case-insensitive/nodejs/tsconfig.json @@ -11,9 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, - "paths": { + "paths": { "@/*": ["*"] - }, + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/resource-args-python/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/resource-args-python/nodejs/tsconfig.json index 3e8040359228..dc46369ac6d8 100644 --- a/pkg/codegen/testing/test/testdata/resource-args-python/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/resource-args-python/nodejs/tsconfig.json @@ -11,9 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, - "paths": { + "paths": { "@/*": ["*"] - }, + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/resource-property-overlap/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/resource-property-overlap/nodejs/tsconfig.json index 0e1595d0a29f..74f4e16716e5 100644 --- a/pkg/codegen/testing/test/testdata/resource-property-overlap/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/resource-property-overlap/nodejs/tsconfig.json @@ -11,9 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, - "paths": { + "paths": { "@/*": ["*"] - }, + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/secrets/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/secrets/nodejs/tsconfig.json index 86bf7a701a05..ba610b1c0872 100644 --- a/pkg/codegen/testing/test/testdata/secrets/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/secrets/nodejs/tsconfig.json @@ -11,9 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, - "paths": { + "paths": { "@/*": ["*"] - }, + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/simple-enum-schema/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/simple-enum-schema/nodejs/tsconfig.json index 844c4046f0fc..6b7fd81ee898 100644 --- a/pkg/codegen/testing/test/testdata/simple-enum-schema/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/simple-enum-schema/nodejs/tsconfig.json @@ -11,9 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, - "paths": { + "paths": { "@/*": ["*"] - }, + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/simple-methods-schema-single-value-returns/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/simple-methods-schema-single-value-returns/nodejs/tsconfig.json index 3a608d2f5234..7161a2622dd2 100644 --- a/pkg/codegen/testing/test/testdata/simple-methods-schema-single-value-returns/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/simple-methods-schema-single-value-returns/nodejs/tsconfig.json @@ -11,9 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, - "paths": { + "paths": { "@/*": ["*"] - }, + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/tsconfig.json index 93e9c3ad2402..fa17bab2f597 100644 --- a/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/tsconfig.json @@ -11,9 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, - "paths": { + "paths": { "@/*": ["*"] - }, + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/simple-plain-schema-with-root-package/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/simple-plain-schema-with-root-package/nodejs/tsconfig.json index 940a0df17369..0d739c3d4a5d 100644 --- a/pkg/codegen/testing/test/testdata/simple-plain-schema-with-root-package/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/simple-plain-schema-with-root-package/nodejs/tsconfig.json @@ -11,9 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, - "paths": { + "paths": { "@/*": ["*"] - }, + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/simple-plain-schema/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/simple-plain-schema/nodejs/tsconfig.json index b268cc2f2df6..0fdb09e8befd 100644 --- a/pkg/codegen/testing/test/testdata/simple-plain-schema/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/simple-plain-schema/nodejs/tsconfig.json @@ -11,9 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, - "paths": { + "paths": { "@/*": ["*"] - }, + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/tsconfig.json index d13962bbd52f..8f640b5bdb1c 100644 --- a/pkg/codegen/testing/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/tsconfig.json @@ -11,9 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, - "paths": { + "paths": { "@/*": ["*"] - }, + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/tsconfig.json index b51118145c0b..549ecdb5e127 100644 --- a/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/simple-resource-schema/nodejs/tsconfig.json @@ -11,9 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, - "paths": { + "paths": { "@/*": ["*"] - }, + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/tsconfig.json index 67f0228a80e9..d842c6677980 100644 --- a/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/tsconfig.json @@ -11,9 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, - "paths": { + "paths": { "@/*": ["*"] - }, + }, "strict": true }, "files": [ diff --git a/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/package.json b/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/package.json index 80cb461cb338..bba5d27b4d17 100644 --- a/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/package.json +++ b/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/package.json @@ -9,6 +9,7 @@ "@pulumi/pulumi": "^3.12" }, "devDependencies": { + "@types/node": "^14", "typescript": "^3.7.0" }, "pulumi": { diff --git a/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/tsconfig.json index ee2af7b52fa8..817c4a343ce9 100644 --- a/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/type-references-resource/nodejs/tsconfig.json @@ -11,9 +11,9 @@ "experimentalDecorators": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true, - "paths": { + "paths": { "@/*": ["*"] - }, + }, "strict": true }, "files": [