diff --git a/src/cli.ts b/src/cli.ts index 75179253..388303b9 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -13,6 +13,8 @@ async function main() { .option('java-package', { desc: 'the java package (namespace) to use for all generated types', type: 'string' }) .option('csharp-outdir', { desc: 'C# output directory (requires --csharp-namespace)', type: 'string' }) .option('csharp-namespace', { desc: 'the C# namespace to use for all generated types', type: 'string' }) + .option('golang-outdir', { desc: 'golang output directory (requires --golang-module)', type: 'string' }) + .option('golang-module', { desc: 'the golang module to use for all generated types', type: 'string' }) .showHelpOnFail(true) .help(); @@ -33,6 +35,7 @@ async function main() { ...parsePythonOptions(), ...parseJavaOptions(), ...parseCSharpOptions(), + ...parseGoLangOptions(), }); function parseJsiiOptions() { @@ -87,6 +90,21 @@ async function main() { }; } + function parseGoLangOptions() { + const outdir = argv['golang-outdir']; + const module = argv['golang-module']; + if (!outdir && !module) { return undefined; } + if (!outdir) { throw new Error('--golang-outdir is required'); } + if (!module) { throw new Error('--golang-module is required'); } + return { + // moduleKey: module, + golang: { + outdir: outdir, + moduleName: module, + }, + }; + } + function parseDepOption() { if (argv.dep?.length === 0) { return undefined; } return { diff --git a/src/compile.ts b/src/compile.ts index 92f99fa9..adf1f594 100644 --- a/src/compile.ts +++ b/src/compile.ts @@ -91,6 +91,12 @@ export async function compile(workdir: string, options: Options) { }; } + if (options.golang) { + targets.go = { + moduleName: options.golang.moduleName, + }; + } + await fs.writeFile(path.join(workdir, 'package.json'), JSON.stringify(pkg, undefined, 2)); await exec(compilerModule, args, { diff --git a/src/options.ts b/src/options.ts index 7b8a3d0e..e786b43b 100644 --- a/src/options.ts +++ b/src/options.ts @@ -46,6 +46,13 @@ export interface Options { * @default - C# is not generated */ csharp?: CSharpOutputOptions; + + /** + * Produces Golang code. + * + * @default - go is not generated + */ + golang?: GoLangOutputOptions; } export interface JsiiOutputOptions { @@ -99,3 +106,18 @@ export interface CSharpOutputOptions { */ namespace: string; } + +export interface GoLangOutputOptions { + /** + * Base root directory. + */ + outdir: string; + + /** + * The go module name + * + * This must follow standard Go module name conventions. + * For example, it cannot include an underscore ('_') or be camelCased + */ + moduleName: string; +} diff --git a/src/srcmak.ts b/src/srcmak.ts index ad521166..2b5f4b9b 100644 --- a/src/srcmak.ts +++ b/src/srcmak.ts @@ -51,5 +51,12 @@ export async function srcmak(srcdir: string, options: Options = { }) { const target = path.join(options.csharp.outdir, reldir); await fs.move(source, target, { overwrite: true }); } + + if (options.golang) { + const reldir = options.golang.moduleName.replace(/_/g, ''); + const source = path.resolve(path.join(workdir, 'dist/go/', reldir)); + const target = path.join(options.golang.outdir, reldir); + await fs.move(source, target, { overwrite: true }); + } }); } diff --git a/src/util.ts b/src/util.ts index 07fd4da4..d7afe8fc 100644 --- a/src/util.ts +++ b/src/util.ts @@ -75,4 +75,8 @@ export function validateOptions(options: Options) { if (options.csharp?.namespace.includes('-')) { throw new Error(`C# namespace [${options.csharp.namespace}] may not contain "-"`); } + + if (options.golang?.moduleName.includes('_')) { + throw new Error(`Go module name [${options.golang.moduleName}] may not contain "_"`); + } } diff --git a/test/__snapshots__/cli.test.ts.snap b/test/__snapshots__/cli.test.ts.snap index 397d604f..098ad099 100644 --- a/test/__snapshots__/cli.test.ts.snap +++ b/test/__snapshots__/cli.test.ts.snap @@ -191,6 +191,280 @@ namespace MyPackage } `; +exports[`golang output 1`] = ` +Object { + "helloworld/go.mod": "module helloworld/helloworld + +go 1.15 + +require ( + github.com/aws/jsii-runtime-go v1.17.1 +) +", + "helloworld/helloworld.go": "// helloworld +package helloworld + +import ( + _jsii_ \\"github.com/aws/jsii-runtime-go\\" + _init_ \\"helloworld/helloworld/jsii\\" + \\"reflect\\" +) + +// Class interface +type CalculatorIface interface { + Add(ops OperandsIface) float64 + Mul(ops OperandsIface) float64 + Sub(ops OperandsIface) float64 +} + +// A sophisticaed multi-language calculator. +// Struct proxy +type Calculator struct { +} + +func NewCalculator() CalculatorIface { + _init_.Initialize() + self := Calculator{} + _jsii_.Create( + \\"helloworld.Calculator\\", + []interface{}{}, + []_jsii_.FQN{}, + []_jsii_.Override{}, + &self, + ) + return &self +} + +func (c *Calculator) Add(ops OperandsIface) float64 { + var returns float64 + _jsii_.Invoke( + c, + \\"add\\", + []interface{}{ops}, + true, + &returns, + map[reflect.Type]reflect.Type{}, + ) + return returns +} + +func (c *Calculator) Mul(ops OperandsIface) float64 { + var returns float64 + _jsii_.Invoke( + c, + \\"mul\\", + []interface{}{ops}, + true, + &returns, + map[reflect.Type]reflect.Type{}, + ) + return returns +} + +func (c *Calculator) Sub(ops OperandsIface) float64 { + var returns float64 + _jsii_.Invoke( + c, + \\"sub\\", + []interface{}{ops}, + true, + &returns, + map[reflect.Type]reflect.Type{}, + ) + return returns +} + +// OperandsIface is the public interface for the custom type Operands +type OperandsIface interface { + GetLhs() float64 + GetRhs() float64 +} + +// Math operands. +// Struct proxy +type Operands struct { + // Left-hand side operand. + Lhs float64 \`json:\\"lhs\\"\` + // Right-hand side operand. + Rhs float64 \`json:\\"rhs\\"\` +} + +func (o *Operands) GetLhs() float64 { + var returns float64 + _jsii_.Get( + o, + \\"lhs\\", + &returns, + map[reflect.Type]reflect.Type{}, + ) + return returns +} + +func (o *Operands) GetRhs() float64 { + var returns float64 + _jsii_.Get( + o, + \\"rhs\\", + &returns, + map[reflect.Type]reflect.Type{}, + ) + return returns +} + + +", + "helloworld/jsii/jsii.go": "package jsii + +import ( + rt \\"github.com/aws/jsii-runtime-go\\" + \\"sync\\" +) + +var once sync.Once + +// Initialize performs the necessary work for the enclosing +// module to be loaded in the jsii kernel. +func Initialize() { + once.Do(func(){ + // Load this library into the kernel + rt.Load(\\"helloworld\\", \\"0.0.0\\", tarball) + }) +} +", + "helloworld/jsii/tarball.embedded.go": "package jsii + +var tarball = []byte{ + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0xed, 0x5a, 0xeb, 0x73, 0xe2, 0xb6, + 0x16, 0xef, 0x67, 0xfe, 0x0a, 0x8f, 0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d5, 0x90, 0xae, 0x5b, 0x4f, + 0x96, 0xa3, 0xc3, 0x80, 0x0f, 0xaf, 0x59, 0x06, 0xb2, 0x99, 0x0b, 0x06, 0x63, 0x94, 0xda, 0x27, + 0x85, 0x42, 0x2c, 0x2d, 0xa4, 0xf0, 0x5d, 0x73, 0x80, 0x1c, 0xb2, 0x64, 0x20, 0xe6, 0xc5, 0x5a, + 0x5e, 0xe4, 0x3e, 0x28, 0x2e, 0xd6, 0x21, 0x57, 0x54, 0x80, 0x5a, 0x99, 0xc0, 0x8f, 0x21, 0xa9, + 0x8e, 0x55, 0x64, 0x92, 0x80, 0xd7, 0xb9, 0x0d, 0x54, 0x0d, 0x7d, 0x2e, 0xe6, 0x85, 0x70, 0xc8, + 0x40, 0x14, 0x40, 0x40, 0xc1, 0xca, 0x4c, 0x9f, 0x6f, 0xdc, 0x63, 0x7d, 0x36, 0xc1, 0x00, 0x0f, + 0x89, 0x37, 0xbe, 0x76, 0x80, 0x5c, 0xa2, 0x09, 0x70, 0x75, 0x2a, 0x9b, 0x14, 0x39, 0x13, 0xa0, + 0x06, 0x26, 0x53, 0xc7, 0x45, 0x4b, 0xa2, 0xe7, 0x5c, 0xf4, 0x37, 0x34, 0x37, 0x02, 0x6f, 0xd3, + 0x4e, 0x07, 0xd9, 0x16, 0xc1, 0xd4, 0x72, 0xbc, 0x95, 0x06, 0xd4, 0xb3, 0x43, 0xa0, 0x31, 0x8d, + 0x40, 0x75, 0x1d, 0x3d, 0x13, 0x89, 0x98, 0x3f, 0x61, 0x56, 0x19, 0xbe, 0x15, 0x81, 0xfe, 0x05, + 0x21, 0x2f, 0x0a, 0x91, 0x89, 0xcc, 0x93, 0xa7, 0x88, 0x92, 0x15, 0xff, 0xa9, 0x95, 0xb4, 0xcf, + 0xb0, 0xa0, 0xab, 0xa3, 0x5e, 0x5a, 0xbf, 0xd0, 0x82, 0xa3, 0x08, 0x95, 0xe4, 0x1c, 0xd3, 0x36, + 0x32, 0x89, 0x63, 0x75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 0x27, 0x5c, 0x58, 0x85, 0x3b, 0xdd, 0x64, 0xb4, 0xad, 0x24, 0x99, 0xcd, 0xc9, 0x49, 0x72, + 0x7a, 0xfe, 0xb6, 0x02, 0xc3, 0xd2, 0x4a, 0x88, 0x54, 0x1d, 0x38, 0x6c, 0xf8, 0x6d, 0xeb, 0x0d, + 0x27, 0x31, 0xa8, 0x1f, 0xb7, 0x62, 0xf2, 0xfa, 0x85, 0x85, 0x97, 0x48, 0xfd, 0x01, 0x15, 0x84, + 0x4c, 0xb1, 0xff, 0x94, 0x3a, 0xe8, 0xa1, 0x1d, 0xda, 0xa1, 0x1d, 0xda, 0xff, 0x5b, 0xfb, 0x2f, + 0xc5, 0xb2, 0x36, 0x3b, 0x00, 0x2c, 0x00, 0x00, +} + +func init() { + if len(tarball) != 1912 { + panic(\\"Tarball data does not have expected length (1912 bytes)\\") + } +} +", +} +`; + exports[`java output 1`] = ` Object { "src/main/java/mypackage/$Module.java": "package mypackage; diff --git a/test/__snapshots__/srcmak.test.ts.snap b/test/__snapshots__/srcmak.test.ts.snap index 42310402..3785e0c1 100644 --- a/test/__snapshots__/srcmak.test.ts.snap +++ b/test/__snapshots__/srcmak.test.ts.snap @@ -163,6 +163,224 @@ namespace Hello.World } `; +exports[`golang + different entrypoint 1`] = ` +Object { + "helloworld/go.mod": "module helloworld/helloworld + +go 1.15 + +require ( + github.com/aws/jsii-runtime-go v1.17.1 +) +", + "helloworld/helloworld.go": "// helloworld +package helloworld + +import ( + _jsii_ \\"github.com/aws/jsii-runtime-go\\" + _init_ \\"helloworld/helloworld/jsii\\" + \\"reflect\\" +) + +// Class interface +type HelloIface interface { + Add(ops OperandsIface) float64 +} + +// Struct proxy +type Hello struct { +} + +func NewHello() HelloIface { + _init_.Initialize() + self := Hello{} + _jsii_.Create( + \\"helloworld.Hello\\", + []interface{}{}, + []_jsii_.FQN{}, + []_jsii_.Override{}, + &self, + ) + return &self +} + +func (h *Hello) Add(ops OperandsIface) float64 { + var returns float64 + _jsii_.Invoke( + h, + \\"add\\", + []interface{}{ops}, + true, + &returns, + map[reflect.Type]reflect.Type{}, + ) + return returns +} + +// OperandsIface is the public interface for the custom type Operands +type OperandsIface interface { + GetLhs() float64 + GetRhs() float64 +} + +// Struct proxy +type Operands struct { + Lhs float64 \`json:\\"lhs\\"\` + Rhs float64 \`json:\\"rhs\\"\` +} + +func (o *Operands) GetLhs() float64 { + var returns float64 + _jsii_.Get( + o, + \\"lhs\\", + &returns, + map[reflect.Type]reflect.Type{}, + ) + return returns +} + +func (o *Operands) GetRhs() float64 { + var returns float64 + _jsii_.Get( + o, + \\"rhs\\", + &returns, + map[reflect.Type]reflect.Type{}, + ) + return returns +} + + +", + "helloworld/jsii/jsii.go": "package jsii + +import ( + rt \\"github.com/aws/jsii-runtime-go\\" + \\"sync\\" +) + +var once sync.Once + +// Initialize performs the necessary work for the enclosing +// module to be loaded in the jsii kernel. +func Initialize() { + once.Do(func(){ + // Load this library into the kernel + rt.Load(\\"helloworld\\", \\"0.0.0\\", tarball) + }) +} +", + "helloworld/jsii/tarball.embedded.go": "package jsii + +var tarball = []byte{ + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0xed, 0x18, 0x6b, 0x6f, 0xda, 0x48, + 0xb0, 0x9f, 0xf9, 0x15, 0x96, 0xef, 0x4b, 0xa3, 0xe6, 0xc0, 0x36, 0x8f, 0x84, 0x44, 0x91, 0xae, + 0x24, 0x01, 0x4c, 0x12, 0x52, 0x48, 0xc2, 0xeb, 0x54, 0x55, 0xeb, 0xf5, 0x02, 0x0b, 0x7e, 0xd5, + 0xbb, 0x4e, 0x30, 0x15, 0xff, 0xbd, 0x63, 0x1b, 0x1b, 0xf3, 0x48, 0x72, 0xd5, 0x25, 0xed, 0x55, + 0x97, 0x91, 0xc0, 0xbb, 0x3b, 0xb3, 0xf3, 0xda, 0xd9, 0xf1, 0x78, 0x1c, 0x84, 0xa7, 0x68, 0x44, + 0x72, 0xd9, 0x09, 0xa3, 0xf4, 0xdd, 0xeb, 0x80, 0x24, 0x49, 0xa5, 0x42, 0x41, 0xd8, 0xb5, 0x0e, + 0x50, 0xc8, 0x97, 0x64, 0xe1, 0x5d, 0xbe, 0x58, 0x92, 0x64, 0xb9, 0x54, 0x92, 0x80, 0x4e, 0x92, + 0x25, 0x45, 0xc9, 0xc3, 0xf3, 0x95, 0xf4, 0x59, 0x03, 0x8f, 0x71, 0xe4, 0x82, 0x2a, 0xff, 0x96, + 0x4f, 0x64, 0x8c, 0x90, 0x3c, 0x7f, 0x13, 0xf8, 0x96, 0x11, 0x04, 0x11, 0x79, 0x7c, 0x6c, 0xbb, + 0xe2, 0x91, 0x10, 0xcc, 0x60, 0x6e, 0x21, 0x93, 0xc0, 0x4c, 0x1c, 0x11, 0x8b, 0xb8, 0x88, 0x13, + 0xfd, 0xaf, 0x64, 0x94, 0xc5, 0xb6, 0x29, 0xee, 0x47, 0x64, 0xae, 0x6d, 0x10, 0x06, 0x74, 0x7f, + 0x87, 0xd3, 0x15, 0x9f, 0x70, 0xfa, 0x19, 0xfe, 0x17, 0x01, 0xa1, 0xa8, 0x13, 0x86, 0x5d, 0xea, + 0x70, 0x6a, 0x5b, 0x01, 0xd3, 0x31, 0x31, 0x0c, 0xfb, 0xc1, 0x76, 0x0d, 0x3d, 0xe4, 0x23, 0x8e, + 0x6d, 0x93, 0x38, 0x10, 0x82, 0x21, 0x8e, 0x73, 0xe7, 0x28, 0x97, 0x4b, 0xa4, 0x45, 0x14, 0x41, + 0x68, 0x76, 0x88, 0xcb, 0x96, 0x0c, 0xe4, 0xac, 0x7c, 0x90, 0x95, 0x85, 0xf7, 0x9a, 0x47, 0x0d, + 0x5d, 0x50, 0x34, 0x84, 0x8b, 0x43, 0x7d, 0x2f, 0x22, 0x35, 0x28, 0x26, 0x16, 0x0b, 0x79, 0x7d, + 0x74, 0x10, 0x1e, 0x93, 0x3f, 0x95, 0xac, 0x14, 0xa1, 0x4c, 0xc2, 0x91, 0x8e, 0x38, 0x5a, 0x99, + 0x19, 0xf0, 0x4d, 0x66, 0x30, 0x87, 0x0d, 0x26, 0x9a, 0xa6, 0x56, 0x02, 0xed, 0x10, 0x3b, 0x23, + 0x43, 0xe4, 0x19, 0x5c, 0xb5, 0x38, 0x71, 0x87, 0x08, 0x87, 0x26, 0x73, 0xd7, 0x23, 0x4b, 0xa2, + 0x45, 0x26, 0xfe, 0x8f, 0xcc, 0x8d, 0x9d, 0xb7, 0x69, 0xa7, 0x4b, 0x1c, 0x9b, 0x51, 0x6e, 0xbb, + 0xfe, 0x4a, 0x03, 0xee, 0x3b, 0x91, 0xa3, 0x29, 0x8f, 0x9d, 0xea, 0xb9, 0xc6, 0x4e, 0x4f, 0x24, + 0xfc, 0x19, 0x58, 0x65, 0x06, 0x56, 0x84, 0xfa, 0xe7, 0xa4, 0xac, 0x2c, 0xc5, 0x26, 0x42, 0x24, + 0x8f, 0x08, 0x67, 0x2b, 0xfe, 0x23, 0x3b, 0x6d, 0x9f, 0x69, 0xeb, 0x9e, 0x41, 0x9a, 0xdb, 0xfa, + 0x45, 0x16, 0xec, 0xc7, 0x5e, 0x49, 0xef, 0xb1, 0x1c, 0x73, 0x27, 0x71, 0xa2, 0x4e, 0x60, 0x42, + 0x4a, 0xe2, 0x8a, 0x30, 0x5b, 0x0f, 0x86, 0x69, 0x5e, 0x88, 0x31, 0x62, 0x6a, 0x86, 0xbf, 0xc3, + 0x3b, 0x21, 0x7e, 0xf8, 0x75, 0x23, 0x40, 0x96, 0x2c, 0x12, 0x02, 0x6a, 0x51, 0x4e, 0x91, 0x41, + 0xe7, 0x24, 0x0c, 0xd6, 0x45, 0x82, 0x98, 0x52, 0x4b, 0x0f, 0xb6, 0x62, 0x03, 0x64, 0xac, 0xe8, + 0x0d, 0x1b, 0xa3, 0x20, 0xec, 0x54, 0xeb, 0x2a, 0x34, 0x7d, 0xfd, 0x68, 0x87, 0xd4, 0x20, 0xf1, + 0x61, 0xe9, 0x74, 0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0x88, 0x5a, 0xbb, 0x0a, 0xcf, 0x09, 0x13, 0xd7, 0x1a, 0x07, 0x5b, 0x04, 0x7a, 0x5c, 0x9b, 0x3e, + 0xd5, 0xcd, 0xd9, 0xd5, 0x4d, 0x79, 0xac, 0x75, 0xb2, 0xbf, 0xdd, 0x6c, 0x49, 0x6a, 0xcc, 0xb5, + 0x1e, 0x90, 0x68, 0x7b, 0x5c, 0xa7, 0x6e, 0xa4, 0x14, 0x4b, 0x5a, 0x32, 0x9b, 0x6d, 0x95, 0xcd, + 0xc6, 0xca, 0xb3, 0xad, 0x95, 0xed, 0x26, 0x91, 0x4e, 0x1c, 0x62, 0xe9, 0xc4, 0xc2, 0xd1, 0x47, + 0x53, 0xd4, 0xca, 0x10, 0x1d, 0x42, 0xdc, 0xb3, 0x4d, 0x4c, 0x66, 0xf1, 0x9a, 0xe7, 0xff, 0x58, + 0xfd, 0x17, 0x1c, 0xc2, 0x4b, 0xc9, 0x78, 0xe6, 0xfe, 0x2b, 0xca, 0x56, 0xfd, 0x97, 0x97, 0x8b, + 0x85, 0xb7, 0xfb, 0xff, 0x33, 0x20, 0xaa, 0xa9, 0x84, 0xa4, 0xa1, 0x20, 0xc4, 0x9f, 0xf7, 0xcb, + 0xe8, 0x76, 0x09, 0xd2, 0x6d, 0xcb, 0xf0, 0x05, 0xa8, 0xc9, 0x8e, 0x84, 0xe8, 0x2b, 0xee, 0x78, + 0x1d, 0xe3, 0xa6, 0x31, 0x71, 0x95, 0x26, 0xe8, 0x04, 0xaa, 0x3e, 0x97, 0x08, 0x8f, 0xd6, 0x7e, + 0x47, 0x89, 0xa8, 0xbd, 0xf4, 0xf6, 0x5f, 0xed, 0x90, 0x37, 0x78, 0x83, 0x37, 0x78, 0x83, 0xff, + 0x09, 0x7c, 0x07, 0xe7, 0xc3, 0xc1, 0x14, 0x00, 0x1e, 0x00, 0x00, +} + +func init() { + if len(tarball) != 1531 { + panic(\\"Tarball data does not have expected length (1531 bytes)\\") + } +} +", +} +`; + exports[`java + different entrypoint 1`] = ` Object { "src/main/java/hello/world/$Module.java": "package hello.world; diff --git a/test/cli.test.ts b/test/cli.test.ts index cdf450a9..1fc50153 100644 --- a/test/cli.test.ts +++ b/test/cli.test.ts @@ -73,6 +73,18 @@ test('fails if only one csharp option is given', () => { )).toThrow(/--csharp-namespace is required/); }); +test('fails if only one golang option is given', () => { + expect(() => srcmakcli(srcdir, + '--entrypoint lib/main.ts', + '--golang-module mypackage', + )).toThrow(/--golang-outdir is required/); + + expect(() => srcmakcli(srcdir, + '--entrypoint lib/main.ts', + '--golang-outdir dir', + )).toThrow(/--golang-module is required/); +}); + test('python output', async () => { await mkdtemp(async tmpdir => { @@ -126,6 +138,23 @@ test('csharp output', async () => { }); }); +test('golang output', async () => { + await mkdtemp(async tmpdir => { + // put under a non-existent directory to verify it is created + const outdir = path.join(tmpdir, 'go'); + + srcmakcli(srcdir, + '--entrypoint lib/main.ts', + `--golang-outdir ${outdir}`, + '--golang-module helloworld', + ); + + expect(await snapshotDirectory(outdir, { + excludeFiles: ['0.0.0.tgz'], + })).toMatchSnapshot(); + }); +}); + test('dependencies', async () => { await mkdtemp(async srcdir2 => { await fs.writeFile(path.join(srcdir2, 'index.ts'), ` diff --git a/test/srcmak.test.ts b/test/srcmak.test.ts index ae0e7d8b..fb4a933b 100644 --- a/test/srcmak.test.ts +++ b/test/srcmak.test.ts @@ -148,6 +148,42 @@ test('csharp + different entrypoint', async () => { }); }); +test('golang + different entrypoint', async () => { + await mkdtemp(async source => { + const entry = 'different/entry.ts'; + const ep = path.join(source, entry); + await fs.mkdirp(path.dirname(ep)); + await fs.writeFile(ep, ` + export interface Operands { + readonly lhs: number; + readonly rhs: number; + } + + export class Hello { + public add(ops: Operands): number { + return ops.lhs + ops.rhs; + } + } + `); + + await mkdtemp(async target => { + await srcmak(source, { + entrypoint: 'different/entry.ts', + moduleKey: 'helloworld', + golang: { + outdir: target, + moduleName: 'helloworld', + }, + }); + + const dir = await snapshotDirectory(target, { + excludeFiles: ['0.0.0.tgz'], + }); + expect(dir).toMatchSnapshot(); + }); + }); +}); + test('deps: compile against a local jsii dependency', async () => { await mkdtemp(async source => { await fs.writeFile(path.join(source, 'index.ts'), `