Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESM #316

Merged
merged 10 commits into from
Feb 15, 2024
Merged

ESM #316

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
9 changes: 9 additions & 0 deletions .changeset/cool-donkeys-jam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"alcaeus": major
---

Convert to ESM-only. Other changes include:

1. `isomorphic-fetch` and `isomorhpic-form-data` are removed as dependencies. They should be loaded by consumer s if necessary
2. Removed `./web` and `./node` modules. Instead, consumers must use `alcaeus/Factory.js` module with an appropriate RDF/JS environment
3. Extracted packages `alcaeus-model` and `alcaeus-core`
10 changes: 10 additions & 0 deletions .changeset/pre.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"mode": "pre",
"tag": "esm",
"initialVersions": {
"alcaeus": "2.3.3",
"alcaeus-core": "0.0.0",
"alcaeus-model": "0.0.0"
},
"changesets": []
}
6 changes: 6 additions & 0 deletions .changeset/proud-islands-rush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"alcaeus-model": major
"alcaeus-core": major
---

First release. Code extracted from `alceaus` v2
4 changes: 2 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ indent_style = space
indent_size = 2

[*.ts]
indent_size = 4
indent_size = 2

[*.conf*.js]
indent_size = 4
indent_size = 2
42 changes: 6 additions & 36 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,20 @@
"extends": [
"@tpluscode"
],
"parserOptions": {
"project": "./tsconfig.eslint.json",
"extraFileExtensions": [".mjs"]
},
"env": {
"browser": true,
"jest/globals": true
"mocha": true
},
"plugins": [
"jest"
],
"rules": {
"@typescript-eslint/indent": ["error", 4],
"import/no-extraneous-dependencies": ["error", {"devDependencies": ["tests/**"]}]
"@typescript-eslint/no-explicit-any": "off"
},
"overrides": [
{
"extends": [
"eslint:recommended",
"plugin:import/errors",
"plugin:import/warnings"
"files": [
"**/test/**"
],
"files": ["**/*.mjs"],
"rules": {
"no-void": "off",
"no-func-assign": "off",
"prefer-const": "off",
"@typescript-eslint/no-empty-function": "off"
},
"settings": {
"import/extensions": [
".js",
".mjs"
]
}
},
{
"files": ["tests/**/*.ts"],
"rules": {
"@typescript-eslint/no-object-literal-type-assertion": "off",
"no-prototype-builtins": "off",
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/explicit-function-return-type": "off"
"no-unused-expressions": "off",
"import/no-extraneous-dependencies": "off"
}
}
]
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@master
uses: actions/checkout@v4
with:
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v2.1.2
uses: actions/setup-node@v4
with:
node-version: 14
node-version: 18

- name: Install Dependencies
run: yarn

- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@master
uses: changesets/action@v1
with:
# This expects you to have a script called release which does a build for your packages and calls changeset publish
publish: yarn release
Expand Down
31 changes: 15 additions & 16 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,33 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '14'
- run: yarn
- run: yarn test
node-version: '18'
- run: npm ci
- run: npm test
- name: Codecov
uses: codecov/codecov-action@v1.0.5
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '14'
- run: yarn
- run: yarn build
- run: yarn eslint . --ext .mjs --fix --quiet
node-version: '18'
- run: npm ci
- run: npx wsrun -c build --noEmit

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '14'
- run: yarn
node-version: '18'
- run: npm ci
- run: yarn lint
6 changes: 6 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged
cp packages/alcaeus/README.md README.md
git add README.md
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2016 Tomasz Pluskiewicz
Copyright (c) 2024 Tomasz Pluskiewicz

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,27 @@ Alcaeus is the birth name of Heracles. The demigod who defeated Hydra.
Use npm or yarn:

``` bash
npm i -S alcaeus
npm i alcaeus
```

## Requirements

| Environment | Version | Notes |
| -- | -- | -- |
| node.js | 12+ | v12 requires `--experimental-modules` flag |
| TypeScript | 3.8+ | |
Alcaues `v3` is implemented only as ES Modules. It will work in recent versions on node and modern browsers.

## Usage

``` js
import { Hydra } from 'alcaeus/web' // (or 'alcaeus/node')
Since `v3` Alcaeus is configured using an RDF/JS Environment factory. This decouples the library from any specific RDF/JS implementation.

const { response, representation } = await Hydra.loadResource('http://example.com/resource');
It is recommended to use the implementation provided by `@zazuko/env` which allows to easily reuse extend existing environments.

```js
import create from 'alcaeus'
import Environment from '@zazuko/env/Environment.js'
import rdf from '@zazuko/env'

const env = new Environment(create(), { parent: rdf })

const { response, representation } = await env.hydra.loadResource('http://example.com/resource');
const rootResource = representation.root;

// contains supported classes, operations, etc.
Expand All @@ -36,12 +41,7 @@ const apiDocs = Hydra.apiDocumentations[0];
const id = rootResource.id;
```

To learn more head to http://alcaeus.hydra.how.

### More examples (outdated)

* [Introduction to heracles](http://t-code.pl/blog/2016/04/introducing-heracles/)
* [Working with jsonld.js](http://t-code.pl/blog/2016/04/heracles-compacting-resources/)
To learn more, head to http://alcaeus.hydra.how.

## License

Expand Down
40 changes: 0 additions & 40 deletions babel.config.json

This file was deleted.

5 changes: 0 additions & 5 deletions husky.config.js

This file was deleted.

11 changes: 0 additions & 11 deletions jest.config.js

This file was deleted.

Loading
Loading