Skip to content

Commit 15a49f2

Browse files
feat: implement the baseline node sdk (#3)
* feat: init * chore: sync * chore: sync * using prettier and single quote * finish all tests * add spec test * add docs Co-authored-by: frankzhaopeng <poryzhao@featureprobe.com>
1 parent 1f2297b commit 15a49f2

Some content is hidden

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

42 files changed

+21181
-2
lines changed

.github/licenserc.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
header:
2+
license:
3+
spdx-id: Apache-2.0
4+
copyright-owner: FeatureProbe
5+
6+
paths:
7+
- 'src/**/*'
8+
- '**/*.ts'
9+
- '**/*.js'
10+
11+
paths-ignore:
12+
- '**/*.md'
13+
14+
comment: on-failure

.github/workflows/codeql.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: "CodeQL"
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
schedule:
8+
- cron: '0 18 * * 1'
9+
10+
jobs:
11+
analyze:
12+
name: Analyze
13+
runs-on: ubuntu-latest
14+
permissions:
15+
actions: read
16+
contents: read
17+
security-events: write
18+
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
language: [ 'javascript' ]
23+
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v3
27+
with:
28+
fetch-depth: 2
29+
submodules: recursive
30+
31+
# Initializes the CodeQL tools for scanning.
32+
- name: Initialize CodeQL
33+
uses: github/codeql-action/init@v2
34+
with:
35+
languages: ${{ matrix.language }}
36+
# If you wish to specify custom queries, you can do so here or in a config file.
37+
# By default, queries listed here will override any specified in a config file.
38+
# Prefix the list here with "+" to use these queries and those in the config file.
39+
40+
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
41+
# queries: security-extended,security-and-quality
42+
43+
44+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
45+
# If this step fails, then you should remove it and run the build manually (see below)
46+
- name: Autobuild
47+
uses: github/codeql-action/autobuild@v2
48+
49+
# ℹ️ Command-line programs to run using the OS shell.
50+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
51+
52+
# If the Autobuild fails above, remove it and uncomment the following three lines.
53+
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
54+
55+
# - run: |
56+
# echo "Run, Build Application using script"
57+
# ./location_of_script_within_repo/buildscript.sh
58+
59+
- name: Perform CodeQL Analysis
60+
uses: github/codeql-action/analyze@v2

.github/workflows/license.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: "Check license & format"
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request_target:
7+
8+
9+
jobs:
10+
check:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
15+
- name: Checkout commit
16+
if: github.event_name == 'push'
17+
uses: actions/checkout@v3
18+
19+
- name: Checkout pull request
20+
if: github.event_name == 'pull_request_target'
21+
env:
22+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
uses: actions/checkout@v3
24+
with:
25+
repository: ${{ github.event.pull_request.head.repo.full_name }}
26+
ref: ${{ github.event.pull_request.head.ref }}
27+
28+
29+
- name: Check license headers
30+
uses: apache/skywalking-eyes@v0.3.0
31+
env:
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33+
with:
34+
config: .github/licenserc.yml
35+
mode: fix
36+
37+
- name: Commit licensed files
38+
if: github.event_name == 'pull_request_target'
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
uses: EndBug/add-and-commit@v8.0.2
42+
with:
43+
default_author: github_actions
44+
message: "chore: add license header(s)"
45+
46+
- name: Create pull request
47+
if: github.event_name == 'push'
48+
uses: peter-evans/create-pull-request@v3
49+
with:
50+
author: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com>
51+
commit-message: "chore: add license header(s)"
52+
title: "chore: add license header(s)"
53+
body: Add missing license header(s) in source and test code.
54+
branch: add-license

.github/workflows/npm-publish.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
3+
4+
name: Node.js Package
5+
6+
on:
7+
release:
8+
types: [ created ]
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v3
15+
with:
16+
fetch-depth: 2
17+
submodules: recursive
18+
- uses: actions/setup-node@v3
19+
with:
20+
node-version: 16
21+
- run: npm ci
22+
- run: npm test
23+
24+
publish-npm:
25+
needs: build
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@v3
29+
with:
30+
fetch-depth: 2
31+
submodules: recursive
32+
- uses: actions/setup-node@v3
33+
with:
34+
node-version: 16
35+
registry-url: https://registry.npmjs.org/
36+
- run: npm ci
37+
- run: npm run build --if-present
38+
- run: npm publish
39+
env:
40+
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: "Lint PR"
2+
3+
on:
4+
pull_request_target:
5+
types:
6+
- opened
7+
- edited
8+
- synchronize
9+
10+
jobs:
11+
main:
12+
name: Validate PR title
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: amannn/action-semantic-pull-request@v4
17+
env:
18+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19+
with:
20+
wip: true
21+
ignoreLabels: |
22+
bot
23+
ignore-semantic-pull-request
24+
25+
- name: Hint valid formats
26+
if: ${{ failure() }}
27+
uses: thollander/actions-comment-pull-request@v1.4.1
28+
with:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
message: |
31+
Please adjust your PR title to match the [Conventional Commits spec](https://www.conventionalcommits.org/).
32+
33+
For example:
34+
- fix: fix http client code
35+
- feat: allow provided config object to extend other configs
36+
- refactor!: drop support for node 6
37+
- feat(ui): add button component

.github/workflows/test.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3+
4+
name: Node.js CI
5+
6+
on:
7+
push:
8+
branches: [ main ]
9+
pull_request:
10+
branches: [ main ]
11+
12+
concurrency:
13+
group: >-
14+
${{ github.workflow }}-
15+
${{ github.ref_type }}-
16+
${{ github.event.pull_request.number || github.sha }}
17+
cancel-in-progress: true
18+
19+
jobs:
20+
build:
21+
runs-on: ubuntu-latest
22+
23+
strategy:
24+
matrix:
25+
node-version: [12.x, 14.x, 16.x, 18.x]
26+
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
27+
28+
steps:
29+
- uses: actions/checkout@v3
30+
with:
31+
fetch-depth: 2
32+
submodules: recursive
33+
- name: Use Node.js ${{ matrix.node-version }}
34+
uses: actions/setup-node@v3
35+
with:
36+
node-version: ${{ matrix.node-version }}
37+
cache: 'npm'
38+
- run: npm ci
39+
- run: npm run build --if-present
40+
- run: npm run test:cov
41+
42+
- name: Upload coverage to Codecov
43+
uses: codecov/codecov-action@v3

.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
node_modules/
2+
.DS_Store
3+
typings
4+
5+
# Logs
6+
logs
7+
*.log
8+
9+
.vscode/
10+
.idea/
11+
12+
coverage/
13+
14+
dist/

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "test/fixtures/spec"]
2+
path = test/fixtures/spec
3+
url = git@github.com:FeatureProbe/server-sdk-specification.git

.prettierrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"singleQuote": true,
3+
"printWidth": 120
4+
}

README.md

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,30 @@
1-
# server-sdk-node
2-
FeatureProbe Server Side SDK for Node.js
1+
# FeatureProbe Server Side SDK for Node.js
2+
3+
[![Top Language](https://img.shields.io/github/languages/top/FeatureProbe/server-sdk-node)](https://github.com/FeatureProbe/server-sdk-node/search?l=rust)
4+
[![Coverage Status](https://coveralls.io/repos/github/FeatureProbe/server-sdk-node/badge.svg?branch=demo)](https://coveralls.io/github/FeatureProbe/server-sdk-node?branch=demo)
5+
[![Github Star](https://img.shields.io/github/stars/FeatureProbe/server-sdk-node)](https://github.com/FeatureProbe/server-sdk-node/stargazers)
6+
[![Apache-2.0 license](https://img.shields.io/github/license/FeatureProbe/FeatureProbe)](https://github.com/FeatureProbe/FeatureProbe/blob/demo/LICENSE)
7+
8+
FeatureProbe is an open source feature management service. This SDK is used to control features in Node.js programs. This
9+
SDK is designed primarily for use in multi-user systems such as web servers and applications.
10+
11+
## Basic Terms
12+
13+
Reading the short [Introduction](https://docs.featureprobe.io/reference/sdk-introduction) will help to understand the code blow more easily. [中文](https://docs.featureprobe.io/zh-CN/reference/sdk-introduction)
14+
15+
## How to Use This SDK
16+
17+
See [SDK Doc](https://docs.featureprobe.io/how-to/Server-Side%20SDKs/node-sdk) for detail. [中文](https://docs.featureprobe.io/zh-CN/how-to/Server-Side%20SDKs/node-sdk)
18+
19+
## Contributing
20+
21+
We are working on continue evolving FeatureProbe core, making it flexible and easier to use.
22+
Development of FeatureProbe happens in the open on GitHub, and we are grateful to the
23+
community for contributing bugfixes and improvements.
24+
25+
Please read [CONTRIBUTING](https://github.com/FeatureProbe/featureprobe/blob/master/CONTRIBUTING.md)
26+
for details on our code of conduct, and the process for taking part in improving FeatureProbe.
27+
28+
## License
29+
30+
This project is licensed under the Apache 2.0 License - see the [LICENSE](LICENSE) file for details.

0 commit comments

Comments
 (0)