Skip to content

Commit

Permalink
Publish browser compatible (#85)
Browse files Browse the repository at this point in the history
* Update `package.json` and `package-lock.json` to use roll-up.js for building

* **package.json**
  - Change `"type"` to `"module"`
  - Update the build script to use roll-up.js
  - Update the prepublish script to use roll-up.js
  - Update the test script to use the correct jest configuration
  - Add roll-up.js and related plugins as devDependencies
  - Add `tslib` as a dependency

* **package-lock.json**
  - Add roll-up.js and related plugins
  - Update versions of `@jest/globals`, `@types/jest`, and `jest`
  - Add `tslib` as a dependency

* fix unit tests

* ci: delete node_module directory before npm ci

* chore: install package updates

* Rollup.js fixes

* update jest packages to latest versions

* Updated ESLint to 9.x.x
  • Loading branch information
EdwinOtten authored Nov 1, 2024
1 parent a8eb375 commit d1c9409
Show file tree
Hide file tree
Showing 14 changed files with 1,016 additions and 519 deletions.
6 changes: 6 additions & 0 deletions .devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"tasks": {
"test": "npm install && npm test",
"build": "npm install && npm run build"
}
}
5 changes: 0 additions & 5 deletions .eslintignore

This file was deleted.

16 changes: 0 additions & 16 deletions .eslintrc.js

This file was deleted.

16 changes: 16 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended-type-checked",
"plugin:@typescript-eslint/stylistic-type-checked"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": ["tsconfig.json"]
},
"plugins": ["@typescript-eslint"],
"root": true,
"rules": {
"semi": ["error", "never"]
}
}
3 changes: 3 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Delete node_modules directory
run: rm -rf node_modules

- name: Install dependencies
run: npm ci

Expand Down
62 changes: 31 additions & 31 deletions .github/workflows/pr-validation.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
# This workflow validates Pull Requests
name: PR Validation

# Trigger with every PR to master
on:
pull_request_target:
branches:
- master

jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Delete node_modules directory
run: rm -rf node_modules

- name: Install dependencies
run: npm ci

- name: Run linting
run: npm run lint

- name: Build
run: npm run build

- name: Run tests & generate code coverage summary
uses: ArtiomTr/jest-coverage-report-action@v2
with:
skip-step: install
# This workflow validates Pull Requests
name: PR Validation

# Trigger with every PR to master
on:
pull_request_target:
branches:
- master

jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Delete node_modules directory
run: rm -rf node_modules

- name: Install dependencies
run: npm ci

- name: Run linting
run: npm run lint

- name: Build
run: npm run build

- name: Run tests & generate code coverage summary
uses: ArtiomTr/jest-coverage-report-action@v2
with:
skip-step: install
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,19 @@ A node module that converts Sportlink exports (.csv) into a csv you can import i
console.log(converter.convertFileToOutput(file))
```
4. Using in a browser:
```html
<script src="https://cdn.jsdelivr.net/npm/sportlink-to-mailchimp-converter/dist/sportlink-to-mailchimp-converter.umd.js"></script>
<script>
const converter = new SportlinkToMailchimpConverter({
nonAthleticsMembershipTypes: ['Gastlid', 'Recreanten', 'Overigen'],
athleticsMembershipTypes: ['Atletiek']
});
console.log(converter.convertFileToOutput(file));
</script>
```
### Examples
You can use [example-input.csv](/example-input.csv) to test.
Expand Down
46 changes: 46 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import typescriptEslint from "@typescript-eslint/eslint-plugin";
import tsParser from "@typescript-eslint/parser";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});

export default [{
ignores: [
"**/.eslintrc.js",
"**/jest.config.js",
"**/coverage",
"**/dist",
"**/node_modules",
],
}, ...compat.extends(
"eslint:recommended",
"plugin:@typescript-eslint/recommended-type-checked",
"plugin:@typescript-eslint/stylistic-type-checked",
), {
plugins: {
"@typescript-eslint": typescriptEslint,
},

languageOptions: {
parser: tsParser,
ecmaVersion: 5,
sourceType: "script",

parserOptions: {
project: ["tsconfig.json"],
},
},

rules: {
semi: ["error", "never"],
},
}];
2 changes: 1 addition & 1 deletion jest.config.js → jest.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
testMatch: ['**/*.test.ts'],
};
};
Loading

0 comments on commit d1c9409

Please sign in to comment.