Skip to content

Commit

Permalink
Merge pull request #23 from hypermedia-app/esm
Browse files Browse the repository at this point in the history
BREAKING: esm-only
  • Loading branch information
tpluscode authored Mar 19, 2023
2 parents 953ee36 + 29f2709 commit 6948223
Show file tree
Hide file tree
Showing 13 changed files with 328 additions and 2,243 deletions.
5 changes: 5 additions & 0 deletions .changeset/sour-walls-mate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"clownface-shacl-path": major
---

Package is now ESM-only
20 changes: 10 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,33 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2.1.2
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 14
node-version: 18
- run: yarn install --ci
- run: yarn lint

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2.1.2
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 14
node-version: 18
- run: yarn install --ci
- run: yarn build

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2.1.2
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 14
node-version: 18
- run: yarn install --ci
- run: yarn test
- name: Codecov
uses: codecov/codecov-action@v1.0.5
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
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@v3
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@v3
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
37 changes: 0 additions & 37 deletions babel.config.json

This file was deleted.

49 changes: 22 additions & 27 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,62 +10,59 @@
],
"sideEffects": false,
"exports": {
"require": "./index.cjs",
"import": "./index.js"
".": "./index.js"
},
"scripts": {
"prepare": "husky install",
"prepack": "npm run build",
"build": "run-p build:*",
"build:declarations": "tsc",
"build:esm": "BABEL_ENV=esm babel src --out-dir . --extensions .ts",
"build:cjs": "BABEL_ENV=cjs babel src --out-dir . --extensions .ts --out-file-extension .cjs",
"build": "tsc",
"test": "c8 --all --reporter=lcov mocha --recursive 'test/*.test.ts'",
"lint": "eslint . --ext .ts --quiet --ignore-path .gitignore",
"release": "changeset publish"
},
"dependencies": {
"@rdf-esm/term-set": "^0.5.0",
"@tpluscode/rdf-ns-builders": "^2.0.0",
"@tpluscode/rdf-string": "^0.2.26"
"@rdfjs/term-set": "^2.0.1",
"@tpluscode/rdf-ns-builders": "^3.0.2",
"@tpluscode/rdf-string": "^1.0.1"
},
"peerDependencies": {
"clownface": "^1"
},
"devDependencies": {
"@babel/cli": "^7.14.5",
"@babel/core": "^7.14.6",
"@babel/preset-env": "^7.14.7",
"@babel/preset-typescript": "^7.14.5",
"@babel/register": "^7.14.5",
"@changesets/cli": "^2.19.0",
"@rdf-esm/data-model": "^0.5.4",
"@rdf-esm/dataset": "^0.5.1",
"@rdf-esm/namespace": "^0.5.3",
"@tpluscode/eslint-config": "^0.3.0",
"@rdfjs/data-model": "^2.0.1",
"@rdfjs/dataset": "^2.0.1",
"@rdfjs/namespace": "^2.0.0",
"@tpluscode/eslint-config": "^0.4.2",
"@types/chai": "^4.2.19",
"@types/clownface": "^1.2.0",
"@types/mocha": "^10",
"@types/node": "^18",
"@types/rdf-js": "^4.0.1",
"@types/rdfjs__dataset": "^1.0.5",
"@types/rdfjs__term-set": "^1.0.3",
"@typescript-eslint/eslint-plugin": "^5.52.0",
"@typescript-eslint/parser": "^5.52.0",
"@types/rdfjs__data-model": "^2.0.2",
"@types/rdfjs__dataset": "^2.0.1",
"@types/rdfjs__term-set": "^2.0.2",
"@typescript-eslint/eslint-plugin": "^5.55.0",
"@typescript-eslint/parser": "^5.55.0",
"babel-plugin-add-import-extension": "^1.5.1",
"c8": "^7.13.0",
"chai": "^4.3.4",
"clownface": "^1.3.0",
"eslint": "^8.34.0",
"eslint-config-standard": "^16.0.3",
"eslint-config-standard": "^17.0.0",
"eslint-import-resolver-typescript": "^3.5.3",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-n": "^15.6.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-require-extensions": "^0.1.2",
"husky": "^7.0.0",
"lint-staged": "^11.0.0",
"mocha": "^10.2.0",
"npm-run-all": "^4.1.5",
"standard": "^17.0.0",
"typescript": "^3.9.3"
"ts-node": "^10.9.1",
"typescript": "^5.0.2"
},
"repository": {
"type": "git",
Expand All @@ -80,9 +77,7 @@
"watch-files": [
"./**/*.ts"
],
"require": [
"test-setup.cjs"
]
"loader": "ts-node/esm"
},
"lint-staged": {
"*.{js,ts}": [
Expand Down
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export { findNodes } from './lib/findNodes'
export { toSparql } from './lib/toSparql'
export { findNodes } from './lib/findNodes.js'
export { toSparql } from './lib/toSparql.js'
export {
PathVisitor,
ShaclPropertyPath,
Expand All @@ -11,4 +11,4 @@ export {
SequencePath,
ZeroOrOnePath,
fromNode,
} from './lib/path'
} from './lib/path.js'
4 changes: 2 additions & 2 deletions src/lib/findNodes.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { NamedNode, Term } from 'rdf-js'
import type { MultiPointer } from 'clownface'
import TermSet from '@rdf-esm/term-set'
import * as Path from './path'
import TermSet from '@rdfjs/term-set'
import * as Path from './path.js'

interface Context {
pointer: MultiPointer
Expand Down
4 changes: 2 additions & 2 deletions src/lib/toSparql.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { NamedNode } from 'rdf-js'
import { SparqlTemplateResult, sparql } from '@tpluscode/rdf-string'
import { MultiPointer } from 'clownface'
import { assertWellFormedPath, fromNode, PathVisitor } from './path'
import * as Path from './path'
import { assertWellFormedPath, fromNode, PathVisitor } from './path.js'
import * as Path from './path.js'

class ToSparqlPropertyPath extends PathVisitor<SparqlTemplateResult, { isRoot: boolean }> {
visitSequencePath({ paths }: Path.SequencePath, { isRoot = true } = {}): SparqlTemplateResult {
Expand Down
5 changes: 0 additions & 5 deletions test-setup.cjs

This file was deleted.

10 changes: 5 additions & 5 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { expect } from 'chai'
import { describe, it } from 'mocha'
import { schema, sh, skos, foaf, rdf, owl } from '@tpluscode/rdf-ns-builders'
import type { GraphPointer } from 'clownface'
import { literal } from '@rdf-esm/data-model'
import namespace from '@rdf-esm/namespace'
import { findNodes, toSparql } from '../src'
import { any, blankNode, namedNode } from './nodeFactory'
import RDF from '@rdfjs/data-model'
import namespace from '@rdfjs/namespace'
import { findNodes, toSparql } from '../src/index.js'
import { any, blankNode, namedNode } from './nodeFactory.js'

const tbbt = namespace('http://example.com/')

Expand Down Expand Up @@ -186,7 +186,7 @@ describe('clownface-shacl-path', () => {
const nodes = findNodes(leonard, path)

// then
expect(nodes.terms).to.deep.contain.members([literal('Amy'), literal('Amy Farrah-Fowler')])
expect(nodes.terms).to.deep.contain.members([RDF.literal('Amy'), RDF.literal('Amy Farrah-Fowler')])
})

it('follows an alternative of two inverse paths', () => {
Expand Down
8 changes: 4 additions & 4 deletions test/nodeFactory.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { NamedNode } from 'rdf-js'
import clownface from 'clownface'
import { dataset } from '@rdf-esm/dataset'
import RDF from '@rdfjs/dataset'

export function blankNode() {
return clownface({ dataset: dataset() }).blankNode()
return clownface({ dataset: RDF.dataset() }).blankNode()
}

export function namedNode(uri: string | NamedNode) {
return clownface({ dataset: dataset() }).namedNode(uri)
return clownface({ dataset: RDF.dataset() }).namedNode(uri)
}

export function any() {
return clownface({ dataset: dataset() })
return clownface({ dataset: RDF.dataset() })
}
1 change: 0 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"target": "es2019",
"module": "ESNext",
"outDir": ".",
"emitDeclarationOnly": true,
"forceConsistentCasingInFileNames": true,
"moduleResolution": "Node",
"declaration": true,
Expand Down
Loading

0 comments on commit 6948223

Please sign in to comment.