Skip to content

Commit

Permalink
Merge pull request #1537 from zazuko/shape-version
Browse files Browse the repository at this point in the history
shape version specified only once
  • Loading branch information
giacomociti authored Sep 27, 2024
2 parents e63ee83 + 805f370 commit cd26d53
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 6 deletions.
19 changes: 19 additions & 0 deletions cli/lib/replaceShapesVersion.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import type { Quad } from '@rdfjs/types'
import { Context } from 'barnard59-core'

export default function replaceShapesVersion(this: Context, version = 'v0.2.2') {
const prefix = 'https://cube.link/latest/'
const replacement = `https://cube.link/${version}/`
const { env } = this

return async function * (stream: AsyncIterable<Quad>) {
for await (const quad of stream) {
if (quad.predicate.equals(env.ns.code.imports) && quad.object.value.startsWith(prefix)) {
const replaced = quad.object.value.replace(prefix, replacement)
yield env.quad(quad.subject, quad.predicate, env.namedNode(replaced))
} else {
yield quad
}
}
}
}
1 change: 1 addition & 0 deletions cli/lib/variables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ declare module 'barnard59-core' {
bnodeUuid: string
metadata: DatasetExt
shapesPath: string
shapesVersion: string
sourceCube: NamedNode
sourceEndpoint: NamedNode
sourceGraph: NamedNode | undefined
Expand Down
2 changes: 1 addition & 1 deletion cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"alcaeus": "^2",
"aws-sdk": "^2.559.0",
"barnard59": "^5.0.4",
"barnard59-core": "^6.0.0",
"barnard59-base": "^2.4.2",
"barnard59-cube": "^1.4.8",
"barnard59-formats": "^4.0.0",
Expand Down Expand Up @@ -112,7 +113,6 @@
"@types/sinon-chai": "^3.2.4",
"@types/sparql-http-client": "^2",
"@types/through2": "^2.0.36",
"barnard59-core": "^6.0.0",
"chai": "^4.3.4",
"dotenv": "^16.0.0",
"dotenv-cli": "^5.0.0",
Expand Down
15 changes: 15 additions & 0 deletions cli/pipelines/publish.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
:name "executionUrl" ;
:required false
] ;
:variable
[
:name "shapesVersion" ;
:required false
] ;
] ;
:steps
[
Expand Down Expand Up @@ -94,6 +99,7 @@
:stepList
(
<#open>
<#replace>
<#imports>
)
] .
Expand All @@ -107,6 +113,15 @@
code:arguments ( 'shapesPath'^^:VariableName )
.

<#replace> a :Step ;
code:implementedBy
[
a code:EcmaScript ;
code:link <file:../lib/replaceShapesVersion#default>
] ;
code:arguments ( 'shapesVersion'^^:VariableName )
.

<#imports> a :Step ;
code:implementedBy
[
Expand Down
4 changes: 2 additions & 2 deletions cli/shapes-all.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ prefix code: <https://code.described.at/>
] .

[
code:imports <https://cube.link/v0.2.2/shape/profile-opendataswiss-lindas> ;
code:imports <https://cube.link/latest/shape/profile-opendataswiss-lindas> ;
code:extension "ttl" ;
] .

[
code:imports <https://cube.link/v0.2.2/shape/profile-visualize> ;
code:imports <https://cube.link/latest/shape/profile-visualize> ;
code:extension "ttl" ;
] .
2 changes: 1 addition & 1 deletion cli/shapes-default.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ prefix code: <https://code.described.at/>
] .

[
code:imports <https://cube.link/v0.2.2/shape/standalone-constraint-constraint> ;
code:imports <https://cube.link/latest/shape/standalone-constraint-constraint> ;
code:extension "ttl" ;
] .
2 changes: 1 addition & 1 deletion cli/shapes-opendataswiss.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ prefix code: <https://code.described.at/>
] .

[
code:imports <https://cube.link/v0.2.2/shape/profile-opendataswiss-lindas> ;
code:imports <https://cube.link/latest/shape/profile-opendataswiss-lindas> ;
code:extension "ttl" ;
] .
2 changes: 1 addition & 1 deletion cli/shapes-visualize.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ prefix code: <https://code.described.at/>
] .

[
code:imports <https://cube.link/v0.2.2/shape/profile-visualize> ;
code:imports <https://cube.link/latest/shape/profile-visualize> ;
code:extension "ttl" ;
] .

0 comments on commit cd26d53

Please sign in to comment.