Skip to content

Commit a914059

Browse files
committed
Merge branch 'dapr-master'
2 parents bd09da5 + be5bf20 commit a914059

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+3417
-1510
lines changed

.eslintignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# don't ever lint node_modules
2+
node_modules
3+
# don't lint build output (make sure it's set to your correct build folder name)
4+
build
5+
dist
6+
# don't lint nyc coverage output
7+
coverage
8+
# don't lint proto files and output
9+
proto

.eslintrc.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"root": true,
3+
"parser": "@typescript-eslint/parser",
4+
"plugins": [
5+
"@typescript-eslint"
6+
],
7+
"extends": [
8+
"eslint:recommended",
9+
"plugin:@typescript-eslint/recommended"
10+
],
11+
"env": {
12+
"browser": true,
13+
"amd": true,
14+
"node": true
15+
},
16+
"rules": {
17+
"@typescript-eslint/ban-ts-comment": "off"
18+
}
19+
}

daprdocs/content/en/js-sdk-contributing/js-contributing.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,104 @@ description: Guidelines for contributing to the Dapr JavaScript SDK
88

99
When contributing to the [JavaScript SDK](https://github.com/dapr/js-sdk) the following rules and best-practices should be followed.
1010

11+
## Commit Guidelines
12+
13+
The Dapr Javascript SDK uses the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/)
14+
specification. The automatic changelog tool uses these to automatically generate
15+
a changelog based on the commit messages. Here's a guide to writing a commit message
16+
to allow this:
17+
18+
### Format
19+
20+
```
21+
type(scope)!: subject
22+
```
23+
24+
- `type`: the type of the commit is one of the following:
25+
26+
- `feat`: new features.
27+
- `fix`: bug fixes.
28+
- `docs`: documentation changes.
29+
- `refactor`: refactor of a particular code section without introducing
30+
new features or bug fixes.
31+
- `style`: code style improvements.
32+
- `perf`: performance improvements.
33+
- `test`: changes to the test suite.
34+
- `ci`: changes to the CI system.
35+
- `build`: changes to the build system (we don't yet have one so this shouldn't apply).
36+
- `chore`: for other changes that don't match previous types. This doesn't appear
37+
in the changelog.
38+
39+
- `scope`: section of the codebase that the commit makes changes to. If it makes changes to
40+
many sections, or if no section in particular is modified, leave blank without the parentheses.
41+
Examples:
42+
43+
- Commit that adds a `test`:
44+
```
45+
test(actors): add an actor test
46+
```
47+
48+
- Commit that changes many things at once:
49+
```
50+
style: adopt eslint
51+
```
52+
53+
For changes to examples, the scope should be the example name with the `examples/` prefix:
54+
55+
-`fix(agnoster): commit subject`
56+
-`fix(examples/http/actor): commit subject`
57+
58+
- `!`: this goes after the `scope` (or the `type` if scope is empty), to indicate that the commit
59+
introduces breaking changes.
60+
61+
Optionally, you can specify a message that the changelog tool will display to the user to indicate
62+
what's changed and what they can do to deal with it. You can use multiple lines to type this message;
63+
the changelog parser will keep reading until the end of the commit message or until it finds an empty
64+
line.
65+
66+
Example (made up):
67+
68+
```
69+
style(agnoster)!: change dirty git repo glyph
70+
71+
BREAKING CHANGE: the glyph to indicate when a git repository is dirty has
72+
changed from a Powerline character to a standard UTF-8 emoji.
73+
74+
Fixes #420
75+
76+
Co-authored-by: Username <email>
77+
```
78+
79+
- `subject`: a brief description of the changes. This will be displayed in the changelog. If you need
80+
to specify other details you can use the commit body but it won't be visible.
81+
82+
Formatting tricks: the commit subject may contain:
83+
84+
- Links to related issues or PRs by writing `#issue`. This will be highlighted by the changelog tool:
85+
```
86+
feat(archlinux): add support for aura AUR helper (#9467)
87+
```
88+
89+
- Formatted inline code by using backticks: the text inbetween backticks will also be highlighted by
90+
the changelog tool:
91+
```
92+
feat(shell-proxy): enable unexported `DEFAULT_PROXY` setting (#9774)
93+
```
94+
95+
### Style
96+
97+
Try to keep the first commit line short. This is harder to do using this commit style but try to be
98+
concise and if you need more space, you can use the commit body. Try to make sure that the commit
99+
subject is clear and precise enough that users will know what change by just looking at the changelog.
100+
101+
## Coding Rules
102+
103+
To ensure consistency throughout the source code, keep these rules in mind as you are working:
104+
105+
* All features or bug fixes **must be tested** by one or more specs (unit-tests).
106+
* All public API methods **must be documented**.
107+
* We follow [ESLint RecommendedRules][https://eslint.org/docs/rules/].
108+
11109
## Examples
12110
13111
The `examples` directory contains code samples for users to run to try out specific functionality of the various JavaScript SDK packages and extensions. When writing new and updated samples keep in mind:

documentation/development.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ Tests are written per protocol layer: http or grpc. This is done because Dapr re
3737
# Ports: 1883 = TCP MQTT Port | 8081 = HTTP API | 8083 = MQTT/SSL Port | 8883 = MQTT/Websocket/SSL Port | 8084 = MQTT/Websocket Port | 18083 = Dashboard
3838
docker run -d --rm --name emqx -p 1883:1883 -p 8081:8081 -p 8083:8083 -p 8883:8883 -p 8084:8084 -p 18083:18083 emqx/emqx
3939

40+
# Run Unit Tests
41+
npm run test:unit
42+
4043
# Start gRPC tests
4144
npm run test:e2e:grpc:main
4245

@@ -47,4 +50,4 @@ npm run test:e2e:http:actors
4750

4851
## Publishing
4952

50-
./scripts/publish.sh
53+
Publishing is automated in the CI/CD pipeline. Each time a version is release (GitHub ref starting with `refs/tags/v`) then the pipeline will deploy the package as described in [build.yml](./.github/workflows/build.yml).

examples/http/actor-parking-sensor/src/ParkingSensorImpl.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,21 @@ export default class ParkingSensorImpl extends AbstractActor implements ParkingS
6060
}
6161

6262
generateRandomPoint(center: { lat: number, lng: number }, radius: number) {
63-
var x0 = center.lng;
64-
var y0 = center.lat;
63+
const x0 = center.lng;
64+
const y0 = center.lat;
6565

6666
// Convert Radius from meters to degrees.
67-
var rd = radius / 111300;
67+
const rd = radius / 111300;
6868

69-
var u = Math.random();
70-
var v = Math.random();
69+
const u = Math.random();
70+
const v = Math.random();
7171

72-
var w = rd * Math.sqrt(u);
73-
var t = 2 * Math.PI * v;
74-
var x = w * Math.cos(t);
75-
var y = w * Math.sin(t);
72+
const w = rd * Math.sqrt(u);
73+
const t = 2 * Math.PI * v;
74+
const x = w * Math.cos(t);
75+
const y = w * Math.sin(t);
7676

77-
var xp = x / Math.cos(y0);
77+
const xp = x / Math.cos(y0);
7878

7979
// Resulting point.
8080
return { 'lat': y + y0, 'lng': xp + x0 };

examples/http/actor-parking-sensor/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ async function start() {
3737
console.log("Waiting 10 seconds before starting");
3838
await sleep(10000);
3939

40-
while (true) {
40+
const isRunning = true;
41+
while (isRunning) {
4142
console.log("Simulating cars entering and leaving for 5% of the population");
4243

4344
const populationSize = Math.floor(amount * 0.05);

examples/http/actor/src/actor/DemoActorCounterImpl.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import { AbstractActor } from "dapr-client";
22
import DemoActorCounterInterface from "./DemoActorCounterInterface";
33

44
export default class DemoActorCounterImpl extends AbstractActor implements DemoActorCounterInterface {
5-
counter: number = 0;
5+
counter = 0;
66

7-
async count(): Promise<void> {
8-
this.counter++;
9-
}
7+
async count(): Promise<void> {
8+
this.counter++;
9+
}
1010

11-
async countBy(amount: number): Promise<void> {
12-
this.counter += amount;
13-
}
11+
async countBy(amount: number): Promise<void> {
12+
this.counter += amount;
13+
}
1414
}
Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import { AbstractActor } from "dapr-client";
2-
import DemoActorReminderInterface from "./DemoActorReminderInterface";
32

4-
export default class DemoActorReminderImpl extends AbstractActor implements DemoActorReminderInterface {
5-
counter: number = 0;
3+
export default class DemoActorReminderImpl extends AbstractActor {
4+
counter = 0;
65

7-
async count(): Promise<void> {
8-
this.counter++;
9-
}
6+
async count(): Promise<void> {
7+
this.counter++;
8+
}
109

11-
async countBy(amount: number): Promise<void> {
12-
this.counter += amount;
13-
}
10+
async countBy(amount: number): Promise<void> {
11+
this.counter += amount;
12+
}
1413
}

examples/http/actor/src/actor/DemoActorReminderInterface.ts

Lines changed: 0 additions & 2 deletions
This file was deleted.

examples/http/actor/src/actor/DemoActorTimerImpl.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ import { AbstractActor } from "dapr-client";
22
import DemoActorTimerInterface from "./DemoActorTimerInterface";
33

44
export default class DemoActorTimerImpl extends AbstractActor implements DemoActorTimerInterface {
5-
counter: number = 0;
5+
counter = 0;
66

7-
async init(): Promise<string> {
8-
return "Actor Activated";
9-
}
7+
async init(): Promise<string> {
8+
return "Actor Activated";
9+
}
1010

11-
async count(): Promise<void> {
12-
this.counter++;
13-
}
11+
async count(): Promise<void> {
12+
this.counter++;
13+
}
1414

15-
async countBy(amount: number): Promise<void> {
16-
this.counter += amount;
17-
}
15+
async countBy(amount: number): Promise<void> {
16+
this.counter += amount;
17+
}
1818
}

0 commit comments

Comments
 (0)