Skip to content

Commit

Permalink
shape version specified only once
Browse files Browse the repository at this point in the history
  • Loading branch information
giacomociti committed Sep 25, 2024
1 parent e63ee83 commit 36a7648
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 5 deletions.
1 change: 1 addition & 0 deletions cli/lib/commands/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export default runner.create<PublishRunOptions>({
variable.set('publish-graph-store-password', publishStore?.password || process.env.PUBLISH_GRAPH_STORE_PASSWORD)
variable.set('metadata', $rdf.dataset())
variable.set('shapesPath', path.resolve(__dirname, `../../${profile}.ttl`))
variable.set('shapesVersion', 'v0.2.2')

if (cubeCreatorVersion) {
variable.set('cubeCreatorVersion', cubeCreatorVersion)
Expand Down
19 changes: 19 additions & 0 deletions cli/lib/replace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import through2 from 'through2'
import type { Quad } from '@rdfjs/types'
import $rdf from 'rdf-ext'

function replace(version: string) {
const prefix = 'https://cube.link/latest/'
const replacement = `https://cube.link/${version}/`
return through2.obj(function (quad: Quad, _, done) {
if (quad.predicate.value === 'https://code.described.at/imports' && quad.object.value.startsWith(prefix)) {
const replaced = quad.object.value.replace(prefix, replacement)
const triple = $rdf.triple(quad.subject, quad.predicate, $rdf.namedNode(replaced))
done(null, triple)
} else {
done(null, quad)
}
})
}

export default replace
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
10 changes: 10 additions & 0 deletions cli/pipelines/publish.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
:stepList
(
<#open>
<#replace>
<#imports>
)
] .
Expand All @@ -107,6 +108,15 @@
code:arguments ( 'shapesPath'^^:VariableName )
.

<#replace> a :Step ;
code:implementedBy
[
a code:EcmaScript ;
code:link <file:../lib/replace#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 36a7648

Please sign in to comment.