Skip to content

Commit

Permalink
Dual publishing CommonJS and ESM (#63)
Browse files Browse the repository at this point in the history
* build: fix CommonJS and ESM build

* docs: update README, tutorial
  • Loading branch information
arnoerpenbeck authored Sep 9, 2024
1 parent 08eebf6 commit eb76571
Show file tree
Hide file tree
Showing 18 changed files with 3,239 additions and 436 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
node_modules
dist/
lib/
.nvmrc
.eslintrc.cjs
jest.config.cjs
jest.setup.cjs
src/fft-api/types/typescript-fetch-client/
*.config.js
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
/lib
/dist
/tmp
/out-tsc
Expand Down
4 changes: 4 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,7 @@ out
.pnp.*

.github/
.vscode/
src/
tsconfig.json
tsconfig.*.json
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Add files here to ignore them from prettier formatting

/dist
/coverage
/dist
/lib
/node_modules
package-lock.json
/src/fft-api/types/typescript-fetch-client/
21 changes: 18 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# fulfillmenttools TypeScript SDK

This is a JavaScript/TypeScript SDK for the [fulfillmenttools REST API](https://docs.fulfillmenttools.com/api-docs/).

<p align="center">
<a href="https://fulfillmenttools.com/">
<img alt="fulfillmenttools logo" src="./.github/images/fft-mach-alliance.svg">
Expand All @@ -14,18 +16,31 @@
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](./CONTRIBUTING.md)
[![TypeScript](https://img.shields.io/badge/Made%20with-TypeScript-1f425f.svg?color=3178c6)](https://www.typescriptlang.org/)

# 🤖 Introduction
## What is fulfillmenttools?

This is a JavaScript/TypeScript SDK for the [fulfillmenttools REST API](https://docs.fulfillmenttools.com/api-docs/).
[fulfillmenttools](https://fulfillmenttools.com) is a next generation order management system that helps retailers and brands to serve their customers faster and more reliably. Its MACH based architecture enables an easy and quick integration.

## Table of contents

- [Get started](#-get-started)
- [Documentation](#-documentation)
- [Development](#-development)
- [License](#-license)
- [Contributing](#-contributing)

## 👉 Get started

The TypeScript SDK is fully open source and is available on [GitHub](https://github.com/fulfillmenttools/fulfillmenttools-sdk-typescript).
The package is published on [npmjs.com](https://www.npmjs.com/package/@fulfillmenttools/fulfillmenttools-sdk-typescript).
It contains both an ESM and a CommonJS build, so you can use it in the browser and in the backend.
You can install it with the command below:

```bash
$ npm install @fulfillmenttools/fulfillmenttools-sdk-typescript
npm install @fulfillmenttools/fulfillmenttools-sdk-typescript

// or

yarn add @fulfillmenttools/fulfillmenttools-sdk-typescript
```

Learn how to set up and use the TypeScript SDK with our [tutorial](./TUTORIAL.md).
Expand Down
5 changes: 3 additions & 2 deletions TUTORIAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,6 @@ const fftApiClient = new FftApiClient(
process.env.FFT_API_PASSWORD || '',
process.env.FFT_API_KEY || ''
);

const fftFacilityService = new FftFacilityService(fftApiClient);
```

> [!NOTE]
Expand All @@ -172,7 +170,10 @@ Remove the `test()` function and replace it with the following code:
```typescript
async function getAllFacilities(): Promise<void> {
console.log(`Getting facilities in ${process.env.FFT_PROJECT_ID}...`);

const fftFacilityService = new FftFacilityService(fftApiClient);
const facilitiesResult = await fftFacilityService.get();

facilitiesResult.facilities?.forEach((facility) => { console.log(facility.name); });
}

Expand Down
4 changes: 4 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* global module */
module.exports = {
presets: [['@babel/preset-env', { targets: { node: 'current' } }], '@babel/preset-typescript'],
};
2 changes: 1 addition & 1 deletion jest.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
setupFilesAfterEnv: ['<rootDir>/jest.setup.cjs'],
testPathIgnorePatterns: ['dist'],
testPathIgnorePatterns: ['lib'],
};
Loading

0 comments on commit eb76571

Please sign in to comment.