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: use typescript with wing cli and worker thread for preflight #5247

Merged
merged 21 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from 8 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
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ jobs:
set -o pipefail

cd dist
PACKAGES=("@winglang/sdk" "@winglang/compiler" "@wingconsole/design-system" "@wingconsole/ui" "@wingconsole/server" "@wingconsole/app" "winglang" "@winglang/platform-awscdk")
PACKAGES=("@winglang/sdk" "@winglang/compiler" "@wingconsole/design-system" "@wingconsole/ui" "@wingconsole/server" "@wingconsole/app" "winglang" "@winglang/platform-awscdk" "ts4wing")
for PACKAGE in "${PACKAGES[@]}"; do
# Check if already published
VERSION_FOUND=$(npm view "$PACKAGE@$PACKAGE_VERSION" version --verbose || true)
Expand Down
5 changes: 5 additions & 0 deletions apps/jsii-docgen/.projen/deps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apps/jsii-docgen/.projen/tasks.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions apps/jsii-docgen/.projenrc.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { typescript, javascript } from "projen";
import { typescript, javascript, DependencyType } from "projen";

const project = new typescript.TypeScriptProject({
name: "@winglang/jsii-docgen",
Expand All @@ -19,7 +19,6 @@ const project = new typescript.TypeScriptProject({
"@types/fs-extra",
"@types/semver",
"@types/yargs@^16",
"@types/node",
"constructs",
],
deps: [
Expand Down Expand Up @@ -73,4 +72,6 @@ project.addFields({
project.package.file.addDeletionOverride("pnpm");
project.tryRemoveFile(".npmrc");

project.deps.addDependency("@types/node@^18.17.13", DependencyType.DEVENV);

project.synth();
2 changes: 1 addition & 1 deletion apps/jsii-docgen/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions apps/jsii-docgen/test/docgen/view/_npm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ class MockChildProcess extends EventEmitter implements ChildProcess {
public unref(): never {
throw new UnsupportedCallError();
}

[Symbol.dispose](): void {}
}

export class UnsupportedCallError extends Error {
Expand Down
5 changes: 5 additions & 0 deletions apps/vscode-wing/.projen/deps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apps/vscode-wing/.projen/tasks.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions apps/vscode-wing/.projenrc.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IgnoreFile } from "projen";
import { IgnoreFile, DependencyType } from "projen";
import { NodePackageManager } from "projen/lib/javascript";
import { TypeScriptAppProject } from "projen/lib/typescript";
import { VSCodeExtensionContributions } from "./src/project/vscode_types";
Expand Down Expand Up @@ -61,7 +61,6 @@ const project = new TypeScriptAppProject({
"ws",
"open",
"node-fetch@^2.6.7",
"@types/node",
"@types/which",
"@vscode/vsce",
"@types/node-fetch",
Expand Down Expand Up @@ -251,4 +250,6 @@ project.tryRemoveFile(".npmrc");

project.addTask("dev").exec("node scripts/dev.mjs");

project.deps.addDependency("@types/node@^18.17.13", DependencyType.DEVENV);

project.synth();
2 changes: 1 addition & 1 deletion apps/vscode-wing/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions apps/wing-api-checker/.projen/deps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apps/wing-api-checker/.projen/tasks.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions apps/wing-api-checker/.projenrc.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { javascript, typescript } from "projen";
import { javascript, typescript, DependencyType } from "projen";

const project = new typescript.TypeScriptProject({
defaultReleaseBranch: "main",
Expand All @@ -20,7 +20,7 @@ const project = new typescript.TypeScriptProject({
prettier: true,
package: false,
deps: ["chalk", "chokidar", "glob-promise", "jsii-reflect", "yargs"],
devDeps: ["@types/node@^18", "@types/yargs"],
devDeps: ["@types/yargs"],
});

const bumpTask = project.tasks.tryFind("bump")!;
Expand All @@ -37,4 +37,6 @@ project.addFields({
project.package.file.addDeletionOverride("pnpm");
project.tryRemoveFile(".npmrc");

project.deps.addDependency("@types/node@^18.17.13", DependencyType.DEVENV);

project.synth();
2 changes: 1 addition & 1 deletion apps/wing-api-checker/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

140 changes: 140 additions & 0 deletions docs/docs/04-standard-library/cloud/endpoint.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,143 @@ browserSupport: bool;
- *Type:* bool

Whether the endpoint is supported through browsers. For UI purposes.
## API Reference <a name="API Reference" id="API Reference"></a>

### Endpoint <a name="Endpoint" id="@winglang/sdk.cloud.Endpoint"></a>

A cloud Endpoint.

#### Initializers <a name="Initializers" id="@winglang/sdk.cloud.Endpoint.Initializer"></a>

```wing
bring cloud;

new cloud.Endpoint(url: str, props?: EndpointProps);
```

| **Name** | **Type** | **Description** |
| --- | --- | --- |
| <code><a href="#@winglang/sdk.cloud.Endpoint.Initializer.parameter.url">url</a></code> | <code>str</code> | *No description.* |
| <code><a href="#@winglang/sdk.cloud.Endpoint.Initializer.parameter.props">props</a></code> | <code><a href="#@winglang/sdk.cloud.EndpointProps">EndpointProps</a></code> | *No description.* |

---

##### `url`<sup>Required</sup> <a name="url" id="@winglang/sdk.cloud.Endpoint.Initializer.parameter.url"></a>

- *Type:* str

---

##### `props`<sup>Optional</sup> <a name="props" id="@winglang/sdk.cloud.Endpoint.Initializer.parameter.props"></a>

- *Type:* <a href="#@winglang/sdk.cloud.EndpointProps">EndpointProps</a>

---



#### Properties <a name="Properties" id="Properties"></a>

| **Name** | **Type** | **Description** |
| --- | --- | --- |
| <code><a href="#@winglang/sdk.cloud.Endpoint.property.node">node</a></code> | <code>constructs.Node</code> | The tree node. |
| <code><a href="#@winglang/sdk.cloud.Endpoint.property.url">url</a></code> | <code>str</code> | The endpoint url. |

---

##### `node`<sup>Required</sup> <a name="node" id="@winglang/sdk.cloud.Endpoint.property.node"></a>

```wing
node: Node;
```

- *Type:* constructs.Node

The tree node.

---

##### `url`<sup>Required</sup> <a name="url" id="@winglang/sdk.cloud.Endpoint.property.url"></a>

```wing
url: str;
```

- *Type:* str

The endpoint url.

---



## Structs <a name="Structs" id="Structs"></a>

### EndpointProps <a name="EndpointProps" id="@winglang/sdk.cloud.EndpointProps"></a>

Options for `Endpoint`.

#### Initializer <a name="Initializer" id="@winglang/sdk.cloud.EndpointProps.Initializer"></a>

```wing
bring cloud;

let EndpointProps = cloud.EndpointProps{ ... };
```

#### Properties <a name="Properties" id="Properties"></a>

| **Name** | **Type** | **Description** |
| --- | --- | --- |
| <code><a href="#@winglang/sdk.cloud.EndpointProps.property.browserSupport">browserSupport</a></code> | <code>bool</code> | Whether the endpoint is supported through browsers. |
| <code><a href="#@winglang/sdk.cloud.EndpointProps.property.label">label</a></code> | <code>str</code> | The endpoint's label. |

---

##### `browserSupport`<sup>Optional</sup> <a name="browserSupport" id="@winglang/sdk.cloud.EndpointProps.property.browserSupport"></a>

```wing
browserSupport: bool;
```

- *Type:* bool
- *Default:* undefined

Whether the endpoint is supported through browsers.

For UI purposes.

---

##### `label`<sup>Optional</sup> <a name="label" id="@winglang/sdk.cloud.EndpointProps.property.label"></a>

```wing
label: str;
```

- *Type:* str
- *Default:* undefined

The endpoint's label.

For UI purposes.

---

*Example*

```wing
"My Dashboard"
```


## Protocols <a name="Protocols" id="Protocols"></a>

### IEndpointClient <a name="IEndpointClient" id="@winglang/sdk.cloud.IEndpointClient"></a>

- *Implemented By:* <a href="#@winglang/sdk.cloud.IEndpointClient">IEndpointClient</a>

Inflight interface for `Endpoint`.



2 changes: 1 addition & 1 deletion examples/tests/sdk_tests/util/env.test.w
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ let NOT_ACTUAL_ENV = "__NOT_ACTUAL_ENV_SHOULD_FAIL__";
/**
* env()
*/
assert(util.env("PATH").length > 0);
assert(util.env("WING_TARGET") != "");
MarkMcCulloh marked this conversation as resolved.
Show resolved Hide resolved
assert(util.env("APP_NAME") == "foo");
assert(util.env("BASE_URL") == "https://www.winglang.io");
assert(util.env("API_BASE_URL") == "https://www.winglang.io/api");
Expand Down
1 change: 1 addition & 0 deletions examples/ts-fixture/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# TypeScript Wing Project
16 changes: 16 additions & 0 deletions examples/ts-fixture/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "ts-fixture",
"version": "0.0.0",
"scripts": {
"compile": "wing compile ./src/main.ts",
"test": "wing test ./src/main.ts"
},
"dependencies": {
"ts4wing": "workspace:^",
"@winglang/sdk": "workspace:^",
"winglang": "workspace:^"
},
"volta": {
"extends": "../../package.json"
}
}
6 changes: 6 additions & 0 deletions examples/ts-fixture/src/main.ts
MarkMcCulloh marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { wing } from "ts4wing";
import { cloud } from "@winglang/sdk";

wing((app) => {
MarkMcCulloh marked this conversation as resolved.
Show resolved Hide resolved
new cloud.Bucket(app, "Bucket");
});
10 changes: 10 additions & 0 deletions examples/ts-fixture/turbo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "https://turborepo.org/schema.json",
"extends": ["//"],
"pipeline": {
"compile": {
"outputs": ["src/target/**"]
},
"test": {}
}
}
1 change: 1 addition & 0 deletions libs/ts4wing/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/
17 changes: 17 additions & 0 deletions libs/ts4wing/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# ts4wing - Experimental TypeScript experience for Wing

```ts
// main.ts
import { wing } from "ts4wing";
MarkMcCulloh marked this conversation as resolved.
Show resolved Hide resolved
import { cloud } from "@winglang/sdk";

wing((app) => {
new cloud.Bucket(app, "Bucket");
})
```

```shell
wing compile main.ts
wing compile -t tf-aws main.ts
wing test main.ts
```
Loading