Skip to content

Commit 75bb990

Browse files
adjust folder structure
1 parent 91b7a2d commit 75bb990

29 files changed

+1900
-1875
lines changed

.github/workflows/ci.yml

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,30 @@ jobs:
2020
matrix:
2121
node-version: [18.x, 20.x]
2222

23+
defaults:
24+
run:
25+
working-directory: sdk/feature-management
26+
2327
steps:
2428
- uses: actions/checkout@v3
2529
- name: Use Node.js ${{ matrix.node-version }}
2630
uses: actions/setup-node@v3
2731
with:
2832
node-version: ${{ matrix.node-version }}
2933
cache: 'npm'
30-
- run: npm ci
31-
- run: npm run lint
32-
- run: npm run build
33-
- run: npm run test
34-
- run: npm run test-browser
34+
cache-dependency-path: sdk/feature-management/package-lock.json
35+
36+
- name: Install dependencies
37+
run: npm ci
38+
39+
- name: Run lint check
40+
run: npm run lint
41+
42+
- name: Run build
43+
run: npm run build
44+
45+
- name: Run tests
46+
run: npm run test
47+
48+
- name: Run browser tests
49+
run: npm run test-browser

scripts/build-and-pack.sh

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,29 @@ SCRIPT_DIR=$(dirname $(readlink -f $0))
99
# Get the directory of the project.
1010
PROJECT_BASE_DIR=$(dirname $SCRIPT_DIR)
1111

12-
# Change to the project directory.
13-
cd $PROJECT_BASE_DIR
14-
15-
# Install dependencies, build, and test.
16-
echo "npm clean install"
17-
npm ci
18-
19-
echo "npm run build"
20-
npm run build
21-
22-
echo "npm run test"
23-
npm run test
24-
25-
# Create a tarball.
26-
echo "npm pack"
27-
npm pack
12+
# Define the SDK directory.
13+
SDK_DIR="$PROJECT_BASE_DIR/sdk"
14+
15+
# Loop through each package in the sdk folder.
16+
for PACKAGE_DIR in "$SDK_DIR"/*; do
17+
if [ -d "$PACKAGE_DIR" ]; then
18+
echo "Building package in $PACKAGE_DIR"
19+
20+
# Change to the package directory.
21+
cd "$PACKAGE_DIR"
22+
23+
# Install dependencies, build, and test.
24+
echo "npm clean install in $PACKAGE_DIR"
25+
npm ci
26+
27+
echo "npm run build in $PACKAGE_DIR"
28+
npm run build
29+
30+
echo "npm run test in $PACKAGE_DIR"
31+
npm run test
32+
33+
# Create a tarball.
34+
echo "npm pack in $PACKAGE_DIR"
35+
npm pack
36+
fi
37+
done
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,57 @@
1-
// rollup.config.js
2-
import typescript from "@rollup/plugin-typescript";
3-
import dts from "rollup-plugin-dts";
4-
5-
export default [
6-
{
7-
external: ["crypto"],
8-
input: "src/index.ts",
9-
output: [
10-
{
11-
dir: "dist/commonjs/",
12-
format: "cjs",
13-
sourcemap: true,
14-
preserveModules: true,
15-
},
16-
{
17-
dir: "dist/esm/",
18-
format: "esm",
19-
sourcemap: true,
20-
preserveModules: true,
21-
},
22-
{
23-
file: "dist/umd/index.js",
24-
format: "umd",
25-
name: 'FeatureManagement',
26-
sourcemap: true
27-
}
28-
],
29-
plugins: [
30-
typescript({
31-
compilerOptions: {
32-
"lib": [
33-
"DOM",
34-
"WebWorker",
35-
"ESNext"
36-
],
37-
"skipDefaultLibCheck": true,
38-
"module": "ESNext",
39-
"moduleResolution": "Node",
40-
"target": "ES2022",
41-
"strictNullChecks": true,
42-
"strictFunctionTypes": true,
43-
"sourceMap": true,
44-
"inlineSources": true
45-
},
46-
"exclude": [
47-
"test/**/*"
48-
]
49-
})
50-
],
51-
},
52-
{
53-
input: "src/index.ts",
54-
output: [{ file: "types/index.d.ts", format: "esm" }],
55-
plugins: [dts()],
56-
},
57-
];
1+
// rollup.config.js
2+
import typescript from "@rollup/plugin-typescript";
3+
import dts from "rollup-plugin-dts";
4+
5+
export default [
6+
{
7+
external: ["crypto"],
8+
input: "src/index.ts",
9+
output: [
10+
{
11+
dir: "dist/commonjs/",
12+
format: "cjs",
13+
sourcemap: true,
14+
preserveModules: true,
15+
},
16+
{
17+
dir: "dist/esm/",
18+
format: "esm",
19+
sourcemap: true,
20+
preserveModules: true,
21+
},
22+
{
23+
file: "dist/umd/index.js",
24+
format: "umd",
25+
name: 'FeatureManagement',
26+
sourcemap: true
27+
}
28+
],
29+
plugins: [
30+
typescript({
31+
compilerOptions: {
32+
"lib": [
33+
"DOM",
34+
"WebWorker",
35+
"ESNext"
36+
],
37+
"skipDefaultLibCheck": true,
38+
"module": "ESNext",
39+
"moduleResolution": "Node",
40+
"target": "ES2022",
41+
"strictNullChecks": true,
42+
"strictFunctionTypes": true,
43+
"sourceMap": true,
44+
"inlineSources": true
45+
},
46+
"exclude": [
47+
"test/**/*"
48+
]
49+
})
50+
],
51+
},
52+
{
53+
input: "src/index.ts",
54+
output: [{ file: "types/index.d.ts", format: "esm" }],
55+
plugins: [dts()],
56+
},
57+
];
Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
// Copyright (c) Microsoft Corporation.
2-
// Licensed under the MIT license.
3-
4-
import { ITargetingContext } from "./common/ITargetingContext";
5-
import { Variant } from "./variant/Variant";
6-
7-
export interface IFeatureManager {
8-
/**
9-
* Get the list of feature names.
10-
*/
11-
listFeatureNames(): Promise<string[]>;
12-
13-
/**
14-
* Check if a feature is enabled.
15-
* @param featureName name of the feature.
16-
* @param context an object providing information that can be used to evaluate whether a feature should be on or off.
17-
*/
18-
isEnabled(featureName: string, context?: unknown): Promise<boolean>;
19-
20-
/**
21-
* Get the allocated variant of a feature given the targeting context.
22-
* @param featureName name of the feature.
23-
* @param context a targeting context object used to evaluate which variant the user will be assigned.
24-
*/
25-
getVariant(featureName: string, context: ITargetingContext): Promise<Variant | undefined>;
26-
}
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT license.
3+
4+
import { ITargetingContext } from "./common/ITargetingContext";
5+
import { Variant } from "./variant/Variant";
6+
7+
export interface IFeatureManager {
8+
/**
9+
* Get the list of feature names.
10+
*/
11+
listFeatureNames(): Promise<string[]>;
12+
13+
/**
14+
* Check if a feature is enabled.
15+
* @param featureName name of the feature.
16+
* @param context an object providing information that can be used to evaluate whether a feature should be on or off.
17+
*/
18+
isEnabled(featureName: string, context?: unknown): Promise<boolean>;
19+
20+
/**
21+
* Get the allocated variant of a feature given the targeting context.
22+
* @param featureName name of the feature.
23+
* @param context a targeting context object used to evaluate which variant the user will be assigned.
24+
*/
25+
getVariant(featureName: string, context: ITargetingContext): Promise<Variant | undefined>;
26+
}
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
// Copyright (c) Microsoft Corporation.
2-
// Licensed under the MIT license.
3-
4-
export interface ITargetingContext {
5-
userId?: string;
6-
groups?: string[];
7-
}
8-
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT license.
3+
4+
export interface ITargetingContext {
5+
userId?: string;
6+
groups?: string[];
7+
}
8+

0 commit comments

Comments
 (0)