Skip to content

Commit

Permalink
Project cleanup, included types to export (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
petruki committed May 5, 2024
1 parent 26fa3c7 commit 4ac0986
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 25 deletions.
19 changes: 15 additions & 4 deletions deno.jsonc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@switcherapi/switcher-client-deno",
"version": "1.0.10",
"version": "1.1.0",
"description": "Switcher4Deno is a Feature Flag Deno SDK client for Switcher API",
"tasks": {
"cache-reload": "deno cache --reload --lock=deno.lock --lock-write mod.ts",
Expand All @@ -13,13 +13,24 @@
"play": "deno run -A test/playground/index.ts"
},
"exports": "./mod.ts",
"publish": {
"exclude": [
".github",
".vscode",
"test",
"sonar-project.properties",
".snyk"
]
},
"fmt": {
"exclude": [
"README.md"
]
},
"lock": false,
"test": {
"include": [
"test/**/*.ts"
]
},
"imports": {
"@std/fs": "jsr:@std/fs@^0.224.0"
}
}
9 changes: 2 additions & 7 deletions deno.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"packages": {
"specifiers": {
"jsr:@std/assert@^0.224.0": "jsr:@std/assert@0.224.0",
"jsr:@std/fs@^0.224.0": "jsr:@std/fs@0.224.0",
"jsr:@std/fs@0.224.0": "jsr:@std/fs@0.224.0",
"jsr:@std/path@^0.224.0": "jsr:@std/path@0.224.0"
},
"jsr": {
Expand All @@ -22,10 +22,5 @@
}
}
},
"remote": {},
"workspace": {
"dependencies": [
"jsr:@std/fs@^0.224.0"
]
}
"remote": {}
}
4 changes: 2 additions & 2 deletions mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
* Switcher Clinet SDK for working with Switcher API
*
* ```ts
* import { Switcher } from '@switcherapi/switcher4deno';
*
* Switcher.buildContext({ url, apiKey, domain, component, environment });
*
* const switcher = Switcher.factory();
Expand All @@ -25,3 +23,5 @@ export {
checkTime,
checkValue,
} from './src/lib/middlewares/check.ts';

export type { Entry, ResultDetail, SwitcherContext, SwitcherOptions } from './src/types/index.d.ts';
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
sonar.projectKey=switcherapi_switcher-client-deno
sonar.projectName=switcher-client-deno
sonar.organization=switcherapi
sonar.projectVersion=1.0.10
sonar.projectVersion=1.1.0

sonar.javascript.lcov.reportPaths=coverage/report.lcov

Expand Down
1 change: 1 addition & 0 deletions src/deps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { existsSync } from 'jsr:@std/fs@0.224.0';
2 changes: 1 addition & 1 deletion src/lib/snapshot.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// deno-lint-ignore-file
import { existsSync } from '@std/fs';
import { existsSync } from '../deps.ts';

import DateMoment from './utils/datemoment.ts';
import IPCIDR from './utils/ipcidr.ts';
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion test/switcher-client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('E2E test - Switcher local:', function () {
const component = 'business-service';
const environment = 'default';
const url = 'http://localhost:3000';
const snapshotLocation = './snapshot/';
const snapshotLocation = './test/snapshot/';

beforeAll(async function() {
Switcher.buildContext({ url, apiKey, domain, component, environment }, {
Expand Down
10 changes: 5 additions & 5 deletions test/switcher-functional.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ describe('Integrated test - Switcher:', function () {

const forceRemoteOptions = {
local: true,
snapshotLocation: './snapshot/',
snapshotLocation: './test/snapshot/',
regexSafe: false
};

Expand Down Expand Up @@ -305,7 +305,7 @@ describe('Integrated test - Switcher:', function () {
});

it('should use silent mode when fail to check switchers', async function() {
Switcher.buildContext(contextSettings, { silentMode: '5m', regexSafe: false, snapshotLocation: './snapshot/' });
Switcher.buildContext(contextSettings, { silentMode: '5m', regexSafe: false, snapshotLocation: './test/snapshot/' });
await assertRejects(async () =>
await Switcher.checkSwitchers(['FEATURE01', 'FEATURE02']),
Error, 'Something went wrong: [FEATURE01,FEATURE02] not found');
Expand All @@ -320,7 +320,7 @@ describe('Integrated test - Switcher:', function () {

// test
let asyncErrorMessage = null;
Switcher.buildContext(contextSettings, { silentMode: '5m', regexSafe: false, snapshotLocation: './snapshot/' });
Switcher.buildContext(contextSettings, { silentMode: '5m', regexSafe: false, snapshotLocation: './test/snapshot/' });
Switcher.subscribeNotifyError((error) => asyncErrorMessage = error.message);

const switcher = Switcher.factory();
Expand Down Expand Up @@ -577,7 +577,7 @@ describe('Integrated test - Switcher:', function () {
it('should run in silent mode', async function () {
// setup context to read the snapshot in case the API does not respond
Switcher.buildContext(contextSettings, {
snapshotLocation: './snapshot/',
snapshotLocation: './test/snapshot/',
regexSafe: false,
silentMode: '2s',
});
Expand Down Expand Up @@ -623,7 +623,7 @@ describe('Integrated test - Switcher:', function () {

it('should run in silent mode when API is unavailable', async function () {
Switcher.buildContext(contextSettings, {
snapshotLocation: './snapshot/',
snapshotLocation: './test/snapshot/',
regexSafe: false,
silentMode: '5m'
});
Expand Down
6 changes: 3 additions & 3 deletions test/switcher-snapshot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ describe('E2E test - Switcher local - Snapshot:', function () {
const token = '[token]';
let contextSettings: SwitcherContext;

const dataBuffer = Deno.readTextFileSync('./snapshot/dev.json');
const dataBuffer = Deno.readTextFileSync('./test/snapshot/dev.json');
const dataJSON = dataBuffer.toString();

const dataBufferV2 = Deno.readTextFileSync('./snapshot/dev_v2.json');
const dataBufferV2 = Deno.readTextFileSync('./test/snapshot/dev_v2.json');
const dataJSONV2 = dataBufferV2.toString();

beforeEach(function() {
Expand All @@ -28,7 +28,7 @@ describe('E2E test - Switcher local - Snapshot:', function () {
};

Switcher.buildContext(contextSettings, {
snapshotLocation: './snapshot/',
snapshotLocation: './test/snapshot/',
local: true,
regexSafe: false
});
Expand Down
2 changes: 1 addition & 1 deletion test/switcher-watch-snapshot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { assertTrue, WaitSafe } from './helper/utils.ts';
import { Switcher } from '../mod.ts';

const updateSwitcher = (status: boolean) => {
const dataBuffer = Deno.readTextFileSync('./snapshot/dev.json');
const dataBuffer = Deno.readTextFileSync('./test/snapshot/dev.json');
const dataJSON = JSON.parse(dataBuffer.toString());

dataJSON.data.domain.group[0].config[0].activated = status;
Expand Down

0 comments on commit 4ac0986

Please sign in to comment.