Skip to content
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
25 changes: 20 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,30 @@ jobs:
matrix:
node-version: [18.x, 20.x]

defaults:
run:
working-directory: sdk/feature-management

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run lint
- run: npm run build
- run: npm run test
- run: npm run test-browser
cache-dependency-path: sdk/feature-management/package-lock.json

- name: Install dependencies
run: npm ci

- name: Run lint check
run: npm run lint

- name: Run build
run: npm run build

- name: Run tests
run: npm run test

- name: Run browser tests
run: npm run test-browser
51 changes: 35 additions & 16 deletions scripts/build-and-pack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,38 @@ SCRIPT_DIR=$(dirname $(readlink -f $0))
# Get the directory of the project.
PROJECT_BASE_DIR=$(dirname $SCRIPT_DIR)

# Change to the project directory.
cd $PROJECT_BASE_DIR

# Install dependencies, build, and test.
echo "npm clean install"
npm ci

echo "npm run build"
npm run build

echo "npm run test"
npm run test

# Create a tarball.
echo "npm pack"
npm pack
# Define the SDK directory.
SDK_DIR="$PROJECT_BASE_DIR/sdk"

# Check if a package directory argument is provided.
if [ -z "$1" ]; then
echo "Please specify a package directory."
exit 1
fi

# The directory of the package to build.
PACKAGE_DIR="$SDK_DIR/$1"

if [ -d "$PACKAGE_DIR" ]; then
echo "Building package in $PACKAGE_DIR"

# Change to the package directory.
cd "$PACKAGE_DIR"

# Install dependencies, build, and test.
echo "npm clean install in $PACKAGE_DIR"
npm ci

echo "npm run build in $PACKAGE_DIR"
npm run build

echo "npm run test in $PACKAGE_DIR"
npm run test

# Create a tarball.
echo "npm pack in $PACKAGE_DIR"
npm pack
else
echo "The specified package directory does not exist."
exit 1
fi
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
114 changes: 57 additions & 57 deletions rollup.config.mjs → sdk/feature-management/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,57 +1,57 @@
// rollup.config.js
import typescript from "@rollup/plugin-typescript";
import dts from "rollup-plugin-dts";
export default [
{
external: ["crypto"],
input: "src/index.ts",
output: [
{
dir: "dist/commonjs/",
format: "cjs",
sourcemap: true,
preserveModules: true,
},
{
dir: "dist/esm/",
format: "esm",
sourcemap: true,
preserveModules: true,
},
{
file: "dist/umd/index.js",
format: "umd",
name: 'FeatureManagement',
sourcemap: true
}
],
plugins: [
typescript({
compilerOptions: {
"lib": [
"DOM",
"WebWorker",
"ESNext"
],
"skipDefaultLibCheck": true,
"module": "ESNext",
"moduleResolution": "Node",
"target": "ES2022",
"strictNullChecks": true,
"strictFunctionTypes": true,
"sourceMap": true,
"inlineSources": true
},
"exclude": [
"test/**/*"
]
})
],
},
{
input: "src/index.ts",
output: [{ file: "types/index.d.ts", format: "esm" }],
plugins: [dts()],
},
];
// rollup.config.js
import typescript from "@rollup/plugin-typescript";
import dts from "rollup-plugin-dts";

export default [
{
external: ["crypto"],
input: "src/index.ts",
output: [
{
dir: "dist/commonjs/",
format: "cjs",
sourcemap: true,
preserveModules: true,
},
{
dir: "dist/esm/",
format: "esm",
sourcemap: true,
preserveModules: true,
},
{
file: "dist/umd/index.js",
format: "umd",
name: 'FeatureManagement',
sourcemap: true
}
],
plugins: [
typescript({
compilerOptions: {
"lib": [
"DOM",
"WebWorker",
"ESNext"
],
"skipDefaultLibCheck": true,
"module": "ESNext",
"moduleResolution": "Node",
"target": "ES2022",
"strictNullChecks": true,
"strictFunctionTypes": true,
"sourceMap": true,
"inlineSources": true
},
"exclude": [
"test/**/*"
]
})
],
},
{
input: "src/index.ts",
output: [{ file: "types/index.d.ts", format: "esm" }],
plugins: [dts()],
},
];
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import { ITargetingContext } from "./common/ITargetingContext";
import { Variant } from "./variant/Variant";
export interface IFeatureManager {
/**
* Get the list of feature names.
*/
listFeatureNames(): Promise<string[]>;
/**
* Check if a feature is enabled.
* @param featureName name of the feature.
* @param context an object providing information that can be used to evaluate whether a feature should be on or off.
*/
isEnabled(featureName: string, context?: unknown): Promise<boolean>;
/**
* Get the allocated variant of a feature given the targeting context.
* @param featureName name of the feature.
* @param context a targeting context object used to evaluate which variant the user will be assigned.
*/
getVariant(featureName: string, context: ITargetingContext): Promise<Variant | undefined>;
}
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

import { ITargetingContext } from "./common/ITargetingContext";
import { Variant } from "./variant/Variant";

export interface IFeatureManager {
/**
* Get the list of feature names.
*/
listFeatureNames(): Promise<string[]>;

/**
* Check if a feature is enabled.
* @param featureName name of the feature.
* @param context an object providing information that can be used to evaluate whether a feature should be on or off.
*/
isEnabled(featureName: string, context?: unknown): Promise<boolean>;

/**
* Get the allocated variant of a feature given the targeting context.
* @param featureName name of the feature.
* @param context a targeting context object used to evaluate which variant the user will be assigned.
*/
getVariant(featureName: string, context: ITargetingContext): Promise<Variant | undefined>;
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
export interface ITargetingContext {
userId?: string;
groups?: string[];
}
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

export interface ITargetingContext {
userId?: string;
groups?: string[];
}

Loading
Loading