Skip to content

Commit

Permalink
Fixed versions
Browse files Browse the repository at this point in the history
  • Loading branch information
ozziest committed Sep 25, 2024
1 parent 38d8640 commit 5e31713
Show file tree
Hide file tree
Showing 19 changed files with 462 additions and 16 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,24 @@ jobs:
- run: npm run build --if-present
- run: npm run test

consumer-tests:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x, 21.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: |
npm ci
npm run build
cd tests/consumers/cjs && npm install && npm run test
cd ../esm && npm install && npm run test
cd ../ts-local && npm install && npm run test
linting:
runs-on: ubuntu-latest
strategy:
Expand Down
6 changes: 0 additions & 6 deletions babel.config.cjs

This file was deleted.

7 changes: 5 additions & 2 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
export * from "./src/index";
export * from "./src/Interfaces";
export * from "./src/Config";
export * from "./src/Constants";
export * from "./src/Interfaces";
export * from "./src/Resource";
export * from "./src/Types";
export * from "./src/Api";
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"build": "rm -rf ./dist && microbundle",
"test": "jest --runInBand",
"test:dev": "jest --watch",
"test:consumer": "sh scripts/consumer-test.sh",
"lint": "eslint --max-warnings=0 .",
"lint:watch": "esw --watch --color",
"prepare": "husky"
Expand Down
8 changes: 8 additions & 0 deletions scripts/consumer-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
echo "TESTING!!!"

npm install
npm run build

cd tests/consumers/cjs && npm run test
cd ../esm && npm run test
cd ../ts-local && npm run test
14 changes: 10 additions & 4 deletions src/index.ts → src/Api.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import Resource from "./Resource";
import { addRequest, addResponse } from "./Config";

export * from "./Config";
import { Resource } from "./Resource";
import { addRequest, addResponse, setConfig, getConfig } from "./Config";

export const interceptors = {
addRequest,
Expand All @@ -26,3 +24,11 @@ export const find = async (url: string) => {
* @returns IQueryable
*/
export const resource = (url: string) => new Resource(url);

export const api = {
find,
resource,
setConfig,
getConfig,
interceptors,
};
2 changes: 1 addition & 1 deletion src/Interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Resource from "./Resource";
import { Resource } from "./Resource";
import { ConditionTypes, MethodType, QueryFunctionType } from "./Types";

export interface IRequest {
Expand Down
4 changes: 1 addition & 3 deletions src/Resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
SortType,
} from "./Types";

class Resource implements IQueryable {
export class Resource implements IQueryable {
private url: string;
private config: IInternalConfig;
private params: URLSearchParams;
Expand Down Expand Up @@ -652,5 +652,3 @@ class Resource implements IQueryable {
};
}
}

export default Resource;
11 changes: 11 additions & 0 deletions tests/consumers/cjs/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const api = require("axe-api-client");

const main = async () => {
api.setConfig({
baseURL: "https://axe-api.com",
});
console.log(api.getConfig());
console.log("CJS module tests are succeed!");
};

main();
38 changes: 38 additions & 0 deletions tests/consumers/cjs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions tests/consumers/cjs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "tester",
"version": "1.0.0",
"main": "common.js",
"type": "commonjs",
"scripts": {
"test": "rm -rf node_modules && rm -rf package-lock.json && npm install && node index.js"
},
"dependencies": {
"axe-api-client": "file:../../../"
}
}
11 changes: 11 additions & 0 deletions tests/consumers/cjs/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
rm -rf node_modules
rm -rf package-lock.json

npm unlink axe-api
npm link axe-api

# npm install
pwd
node index.js

npm unlink axe-api
12 changes: 12 additions & 0 deletions tests/consumers/esm/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { api } from "axe-api-client";

const main = async () => {
api.setConfig({
baseURL: "https://axe-api.com",
});
console.log(api.getConfig());

console.log("ESM module tests are succeed!");
};

main();
38 changes: 38 additions & 0 deletions tests/consumers/esm/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions tests/consumers/esm/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "tester",
"version": "1.0.0",
"main": "common.js",
"type": "module",
"scripts": {
"test": "rm -rf node_modules && rm -rf package-lock.json && npm install && node index.js"
},
"dependencies": {
"axe-api-client": "file:../../../"
}
}
12 changes: 12 additions & 0 deletions tests/consumers/ts-local/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { api } from "axe-api-client";

const main = async () => {
api.setConfig({
baseURL: "https://axe-api.com",
});
console.log(api.getConfig());

console.log("ESM module tests are succeed!");
};

main();
Loading

0 comments on commit 5e31713

Please sign in to comment.