diff --git a/cli/lib/commands/publish.ts b/cli/lib/commands/publish.ts index b1fb6cba6..ee6cb5ff5 100644 --- a/cli/lib/commands/publish.ts +++ b/cli/lib/commands/publish.ts @@ -42,6 +42,7 @@ export default runner.create({ 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) diff --git a/cli/lib/replace.ts b/cli/lib/replace.ts new file mode 100644 index 000000000..cc1686479 --- /dev/null +++ b/cli/lib/replace.ts @@ -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 diff --git a/cli/lib/variables.ts b/cli/lib/variables.ts index e72a51abe..050be1db4 100644 --- a/cli/lib/variables.ts +++ b/cli/lib/variables.ts @@ -28,6 +28,7 @@ declare module 'barnard59-core' { bnodeUuid: string metadata: DatasetExt shapesPath: string + shapesVersion: string sourceCube: NamedNode sourceEndpoint: NamedNode sourceGraph: NamedNode | undefined diff --git a/cli/pipelines/publish.ttl b/cli/pipelines/publish.ttl index ede9a1d06..5f33072d4 100644 --- a/cli/pipelines/publish.ttl +++ b/cli/pipelines/publish.ttl @@ -94,6 +94,7 @@ :stepList ( <#open> + <#replace> <#imports> ) ] . @@ -107,6 +108,15 @@ code:arguments ( 'shapesPath'^^:VariableName ) . +<#replace> a :Step ; + code:implementedBy + [ + a code:EcmaScript ; + code:link + ] ; + code:arguments ( 'shapesVersion'^^:VariableName ) +. + <#imports> a :Step ; code:implementedBy [ diff --git a/cli/shapes-all.ttl b/cli/shapes-all.ttl index c7c898907..3f2a37d09 100644 --- a/cli/shapes-all.ttl +++ b/cli/shapes-all.ttl @@ -6,11 +6,11 @@ prefix code: ] . [ - code:imports ; + code:imports ; code:extension "ttl" ; ] . [ - code:imports ; + code:imports ; code:extension "ttl" ; ] . \ No newline at end of file diff --git a/cli/shapes-default.ttl b/cli/shapes-default.ttl index 4e05a7c46..115a63232 100644 --- a/cli/shapes-default.ttl +++ b/cli/shapes-default.ttl @@ -6,6 +6,6 @@ prefix code: ] . [ - code:imports ; + code:imports ; code:extension "ttl" ; ] . \ No newline at end of file diff --git a/cli/shapes-opendataswiss.ttl b/cli/shapes-opendataswiss.ttl index bd8a8f11f..da66d6268 100644 --- a/cli/shapes-opendataswiss.ttl +++ b/cli/shapes-opendataswiss.ttl @@ -6,6 +6,6 @@ prefix code: ] . [ - code:imports ; + code:imports ; code:extension "ttl" ; ] . diff --git a/cli/shapes-visualize.ttl b/cli/shapes-visualize.ttl index cdc741613..26fcb391b 100644 --- a/cli/shapes-visualize.ttl +++ b/cli/shapes-visualize.ttl @@ -6,6 +6,6 @@ prefix code: ] . [ - code:imports ; + code:imports ; code:extension "ttl" ; ] .