Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(go): run "go build" on generated code #2485

Merged
merged 23 commits into from
Jan 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
extends: ../../../../eslint-config.yaml
extends: ../../../eslint-config.yaml
rules:
'import/no-extraneous-dependencies':
- error
Expand Down
3 changes: 3 additions & 0 deletions packages/@jsii/go-runtime/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
/jsii-calc/
*.generated.go

*.js
*.d.ts
6 changes: 0 additions & 6 deletions packages/@jsii/go-runtime/build-tools/tsconfig.json

This file was deleted.

3 changes: 3 additions & 0 deletions packages/@jsii/go-runtime/lib/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import * as path from 'path';

export const runtimePath = path.resolve(__dirname, '..', 'jsii-runtime-go');
8 changes: 4 additions & 4 deletions packages/@jsii/go-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
"version": "0.0.0",
"private": true,
"description": "",
"main": "index.js",
"main": "lib/index.js",
"scripts": {
"build": "npm run gen:rt && (cd ./jsii-runtime-go && go build)",
"build": "tsc --build && npm run gen:rt && (cd ./jsii-runtime-go && go build)",
"fmt": "go fmt ./... && (cd ./jsii-runtime-go && go fmt)",
"gen:calc": "ts-node build-tools/gen-calc.ts",
"gen:rt": "ts-node build-tools/gen.ts",
"gen:calc": "node build-tools/gen-calc.js",
"gen:rt": "node build-tools/gen.js",
"generate": "npm run gen:rt && npm run gen:calc",
"lint": "go vet ./... && (cd ./jsii-runtime-go && go vet)",
"lint:fix": "yarn lint --fix",
Expand Down
4 changes: 4 additions & 0 deletions packages/@jsii/go-runtime/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../../../tsconfig-base",
"include": ["**/*.ts"]
}
33 changes: 23 additions & 10 deletions packages/@scope/jsii-calc-base/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,34 @@
import { IVeryBaseInterface, VeryBaseProps } from '@scope/jsii-calc-base-of-base';
import {
IVeryBaseInterface,
VeryBaseProps,
StaticConsumer as StaticConsumerBase,
} from '@scope/jsii-calc-base-of-base';

/**
* A base class.
*/
export abstract class Base {
/**
* @returns the name of the class (to verify native type names are created for derived classes).
*/
public typeName() {
return (this.constructor as any).name;
}
/**
* @returns the name of the class (to verify native type names are created for derived classes).
*/
public typeName() {
return (this.constructor as any).name;
}
}

export interface BaseProps extends VeryBaseProps {
readonly bar: string;
readonly bar: string;
}

export interface IBaseInterface extends IVeryBaseInterface {
bar(): void;
}
bar(): void;
}

/**
* Hides the transitive dependency of base-of-base
*/
export class StaticConsumer {
eladb marked this conversation as resolved.
Show resolved Hide resolved
public static consume(...args: any[]) {
return StaticConsumerBase.consume(...args);
}
}
48 changes: 41 additions & 7 deletions packages/@scope/jsii-calc-base/test/assembly.jsii
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"kind": "class",
"locationInModule": {
"filename": "lib/index.ts",
"line": 6
"line": 10
},
"methods": [
{
Expand All @@ -102,7 +102,7 @@
},
"locationInModule": {
"filename": "lib/index.ts",
"line": 10
"line": 14
},
"name": "typeName",
"returns": {
Expand All @@ -124,7 +124,7 @@
"kind": "interface",
"locationInModule": {
"filename": "lib/index.ts",
"line": 15
"line": 19
},
"name": "BaseProps",
"properties": [
Expand All @@ -133,7 +133,7 @@
"immutable": true,
"locationInModule": {
"filename": "lib/index.ts",
"line": 16
"line": 20
},
"name": "bar",
"type": {
Expand All @@ -151,21 +151,55 @@
"kind": "interface",
"locationInModule": {
"filename": "lib/index.ts",
"line": 19
"line": 23
},
"methods": [
{
"abstract": true,
"locationInModule": {
"filename": "lib/index.ts",
"line": 20
"line": 24
},
"name": "bar"
}
],
"name": "IBaseInterface"
},
"@scope/jsii-calc-base.StaticConsumer": {
"assembly": "@scope/jsii-calc-base",
"docs": {
"summary": "Hides the transitive dependency of base-of-base."
},
"fqn": "@scope/jsii-calc-base.StaticConsumer",
"initializer": {},
"kind": "class",
"locationInModule": {
"filename": "lib/index.ts",
"line": 30
},
"methods": [
{
"locationInModule": {
"filename": "lib/index.ts",
"line": 31
},
"name": "consume",
"parameters": [
{
"name": "args",
"type": {
"primitive": "any"
},
"variadic": true
}
],
"static": true,
"variadic": true
}
],
"name": "StaticConsumer"
}
},
"version": "0.0.0",
"fingerprint": "Ajk3MslkfbYCrArr+xpk4fCqUsDaJMcCWIRdaVGDWDo="
"fingerprint": "nk3lZyZihw8+X5KKk4nmX16b78gkSh2KmOCC72ZlkYk="
}
7 changes: 3 additions & 4 deletions packages/jsii-calc/lib/compliance.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as base from '@scope/jsii-calc-base';
import { StaticConsumer } from '@scope/jsii-calc-base-of-base';
import {
EnumFromScopedModule,
IDoublable,
Expand Down Expand Up @@ -291,19 +290,19 @@ export class RuntimeTypeChecking {
* Used to verify verification of number of method arguments.
*/
public methodWithOptionalArguments(arg1: number, arg2: string, arg3?: Date) {
StaticConsumer.consume(arg1, arg2, arg3);
base.StaticConsumer.consume(arg1, arg2, arg3);
}

public methodWithDefaultedArguments(
arg1 = 2,
arg2?: string,
arg3: Date = new Date(),
) {
StaticConsumer.consume(arg1, arg2, arg3);
base.StaticConsumer.consume(arg1, arg2, arg3);
}

public methodWithOptionalAnyArgument(arg?: any) {
StaticConsumer.consume(arg);
base.StaticConsumer.consume(arg);
}
}

Expand Down
4 changes: 1 addition & 3 deletions packages/jsii-calc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,16 @@
"watch": "jsii --project-references -w",
"lint": "eslint . --ext .js,.ts --ignore-path=.gitignore",
"lint:fix": "yarn lint --fix",
"test": "node test/test.calc.js && diff-test test/assembly.jsii .jsii",
"test": "(ls test/test.*.js | xargs -n1 node) && diff-test test/assembly.jsii .jsii",
eladb marked this conversation as resolved.
Show resolved Hide resolved
"test:update": "npm run build && UPDATE_DIFF=1 npm run test"
},
"dependencies": {
"@fixtures/jsii-calc-bundled": "file:../@fixtures/jsii-calc-bundled",
"@scope/jsii-calc-base": "^0.0.0",
"@scope/jsii-calc-base-of-base": "^0.0.0",
"@scope/jsii-calc-lib": "^0.0.0"
},
"peerDependencies": {
"@scope/jsii-calc-base": "^0.0.0",
"@scope/jsii-calc-base-of-base": "^0.0.0",
"@scope/jsii-calc-lib": "^0.0.0"
},
"devDependencies": {
Expand Down
Loading