Skip to content

Commit

Permalink
Automate versions update (#1049)
Browse files Browse the repository at this point in the history
* Use exact deps versions

* Migrated profiles build to typescript

* Separate build/generate steps

* Rebased standard articles on mdx to reuse data

* Updated preview script

* Generate profiles to public

* Fixed linting

* Fixed github link
  • Loading branch information
roll authored Oct 22, 2024
1 parent c1c9c01 commit b9ee508
Show file tree
Hide file tree
Showing 32 changed files with 3,473 additions and 1,764 deletions.
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
profiles/target
public/profiles
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

Data Package is a standard consisting of a set of simple yet extensible specifications to describe datasets, data files and tabular data. It is a data definition language (DDL) and data API that facilitates findability, accessibility, interoperability, and reusability (FAIR) of data. For more information, please visit the [documentation portal](https://datapackage.org).

## Funding

This project is funded through [NGI0 Entrust](https://nlnet.nl/entrust), a fund established by [NLnet](https://nlnet.nl) with financial support from the European Commission's [Next Generation Internet](https://ngi.eu) program. Learn more at the [NLnet project page](https://nlnet.nl/project/FrictionlessStandards/).

[<img src="https://nlnet.nl/logo/banner.png" alt="NLnet foundation logo" width="20%" />](https://nlnet.nl)
[<img src="https://nlnet.nl/image/logos/NGI0_tag.svg" alt="NGI Zero Logo" width="20%" />](https://nlnet.nl/entrust)

## Contributing

One can contribute to the documentation by clicking on the "Edit Page" button on a site page and create a pull request directly on Github.
Expand All @@ -13,9 +20,14 @@ npm install
npm start
```

## Funding
Generating profiles:

This project is funded through [NGI0 Entrust](https://nlnet.nl/entrust), a fund established by [NLnet](https://nlnet.nl) with financial support from the European Commission's [Next Generation Internet](https://ngi.eu) program. Learn more at the [NLnet project page](https://nlnet.nl/project/FrictionlessStandards/).
```bash
npm run generate
```

[<img src="https://nlnet.nl/logo/banner.png" alt="NLnet foundation logo" width="20%" />](https://nlnet.nl)
[<img src="https://nlnet.nl/image/logos/NGI0_tag.svg" alt="NGI Zero Logo" width="20%" />](https://nlnet.nl/entrust)
Building the project:

```bash
npm run build
```
7 changes: 7 additions & 0 deletions build.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { execa } from "execa"

const root = execa({ preferLocal: true, stdout: ["inherit"] })

// Build website

await root`astro build`
1 change: 1 addition & 0 deletions content/docs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ hero:
- text: View on GitHub
link: https://github.com/frictionlessdata/datapackage
icon: external
variant: minimal
banner:
content: |
<p>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
---
title: Data Package
description: A simple container format for describing a coherent collection of data in a single 'package'. It provides the basis for convenient delivery, installation and management of datasets.
description: A simple container format for describing a coherent collection of data in a single package. It provides the basis for convenient delivery, installation and management of datasets.
sidebar:
order: 1
profile: /profiles/2.0/datapackage.json
authors:
- Rufus Pollock
- Paul Walsh
- Adam Kariv
- Evgeny Karev
- Peter Desmet
- Data Package Working Group
---

<table>
<tr>
<th>Authors</th>
<td>Rufus Pollock, Paul Walsh, Adam Kariv, Evgeny Karev, Peter Desmet, Data Package Working Group</td>
<td>{frontmatter.authors.join(", ")}</td>
</tr>
<tr>
<th>Profile</th>
<td><a href="/profiles/2.0/datapackage.json">https://datapackage.org/profiles/2.0/datapackage.json</a></td>
<td>
<a href={frontmatter.profile}>{frontmatter.profile}</a>
</td>
</tr>
</table>

A simple container format for describing a coherent collection of data in a single 'package'. It provides the basis for convenient delivery, installation and management of datasets.
<p>{frontmatter.description}</p>

## Language

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,30 @@ title: Data Resource
description: A simple format to describe and package a single data resource such as an individual table or file. The essence of a Data Resource is a locator for the data it describes. A range of other properties can be declared to provide a richer set of metadata.
sidebar:
order: 2
profile: /profiles/2.0/dataresource.json
authors:
- Rufus Pollock
- Paul Walsh
- Adam Kariv
- Evgeny Karev
- Peter Desmet
- Data Package Working Group
---

<table>
<tr>
<th>Authors</th>
<td>Rufus Pollock, Paul Walsh, Adam Kariv, Evgeny Karev, Peter Desmet, Data Package Working Group</td>
<td>{frontmatter.authors.join(", ")}</td>
</tr>
<tr>
<th>Profile</th>
<td><a href="/profiles/2.0/dataresource.json">https://datapackage.org/profiles/2.0/dataresource.json</a></td>
<td>
<a href={frontmatter.profile}>{frontmatter.profile}</a>
</td>
</tr>
</table>

A simple format to describe and package a single data resource such as an individual table or file. The essence of a Data Resource is a locator for the data it describes. A range of other properties can be declared to provide a richer set of metadata.
<p>{frontmatter.description}</p>

## Language

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,23 @@ title: Extensions
description: The Data Package Standard extensibility features for domain-specific needs.
sidebar:
order: 5
authors:
- Rufus Pollock
- Paul Walsh
- Adam Kariv
- Evgeny Karev
- Peter Desmet
- Data Package Working Group
---

<table>
<tr>
<th>Authors</th>
<td>Rufus Pollock, Paul Walsh, Adam Kariv, Evgeny Karev, Peter Desmet, Data Package Working Group</td>
<td>{frontmatter.authors.join(", ")}</td>
</tr>
</table>

The Data Package Standard extensibility features for domain-specific needs.
<p>{frontmatter.description}</p>

## Language

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,23 @@ title: Glossary
description: A glossary of terms used in the Data Package standard.
sidebar:
order: 6
authors:
- Rufus Pollock
- Paul Walsh
- Adam Kariv
- Evgeny Karev
- Peter Desmet
- Data Package Working Group
---

<table>
<tr>
<th>Authors</th>
<td>Rufus Pollock, Paul Walsh, Adam Kariv, Evgeny Karev, Peter Desmet, Data Package Working Group</td>
<td>{frontmatter.authors.join(", ")}</td>
</tr>
</table>

A dictionary of special terms for the Data Package Standard.
<p>{frontmatter.description}</p>

## Language

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@ title: Security
description: Security considerations around Data Packages and Data Resources.
sidebar:
order: 7
authors:
- Johannes Jander
- Data Package Working Group
---

<table>
<tr>
<th>Authors</th>
<td>Johannes Jander, Data Package Working Group</td>
<td>{frontmatter.authors.join(", ")}</td>
</tr>
</table>

Security considerations around Data Packages and Data Resources.
<p>{frontmatter.description}</p>

## Language

Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,33 @@
---
title: Table Dialect
description: Table Dialect describes how tabular data is stored in a file. It supports delimited text files like CSV, semi-structured formats like JSON and YAML, and spreadsheets like Microsoft Excel.
description: Table Dialect describes how tabular data is stored in a file. It supports delimited text files like CSV, semi-structured formats like JSON and YAML, and spreadsheets like Microsoft Excel. The specification is designed to be expressible as a single JSON-compatible descriptor.
sidebar:
order: 3
profile: /profiles/2.0/tabledialect.json
authors:
- Rufus Pollock
- Paul Walsh
- Adam Kariv
- Evgeny Karev
- Peter Desmet
- Kyle Husmann
- Data Package Working Group
---

<table>
<tr>
<th>Authors</th>
<td>Rufus Pollock, Paul Walsh, Adam Kariv, Evgeny Karev, Peter Desmet, Kyle Husmann, Data Package Working Group</td>
<td>{frontmatter.authors.join(", ")}</td>
</tr>
<tr>
<th>Profile</th>
<td><a href="/profiles/2.0/tabledialect.json">https://datapackage.org/profiles/2.0/tabledialect.json</a></td>
<td>
<a href={frontmatter.profile}>{frontmatter.profile}</a>
</td>
</tr>
</table>

Table Dialect describes how tabular data is stored in a file. It supports delimited text files like CSV, semi-structured formats like JSON and YAML, and spreadsheets like Microsoft Excel. The specification is designed to be expressible as a single JSON-compatible descriptor.
<p>{frontmatter.description}</p>

## Language

Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,35 @@
---
title: Table Schema
description: Table Schema is a simple language- and implementation-agnostic way to declare a schema for tabular data.
description: A simple format to declare a schema for tabular data. The schema is designed to be expressible in JSON.
sidebar:
order: 4
profile: /profiles/2.0/tableschema.json
authors:
- Rufus Pollock
- Paul Walsh
- Adam Kariv
- Evgeny Karev
- Peter Desmet
- Ethan Welty
- DC Slagel
- Kyle Husmann
- Data Package Working Group
---

<table>
<tr>
<th>Authors</th>
<td>Rufus Pollock, Paul Walsh, Adam Kariv, Evgeny Karev, Peter Desmet, Ethan Welty, DC Slagel, Kyle Husmann, Data Package Working Group</td>
<td>{frontmatter.authors.join(", ")}</td>
</tr>
<tr>
<th>Profile</th>
<td><a href="/profiles/2.0/tableschema.json">https://datapackage.org/profiles/2.0/tableschema.json</a></td>
<td>
<a href={frontmatter.profile}>{frontmatter.profile}</a>
</td>
</tr>
</table>

A simple format to declare a schema for tabular data. The schema is designed to be expressible in JSON
<p>{frontmatter.description}</p>

## Language

Expand Down
27 changes: 14 additions & 13 deletions profiles/build.js → generate.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
import { version } from "./package.json"
import JsonSchema from "@apidevtools/json-schema-ref-parser"
import { readPackage } from "@npmcli/package-json/lib/read-package.js"
import fs from "fs-extra"
import { glob } from "glob"
import yaml from "js-yaml"
import nodePath from "path"
import process from "process"
import { replaceInFile } from "replace-in-file"

const VERSION = (await readPackage("./package.json")).version
const SOURCE_DIR = "profiles/source"
const TARGET_DIR = `profiles/target`
const VERSION_DIR = `${TARGET_DIR}/${VERSION}`
const BUILD_DIR = "build/profiles"
const SOURCE_DIR = "profiles"
const TARGET_DIR = `public/profiles`
const VERSION_DIR = `${TARGET_DIR}/${version}`
const EXCLUDE_FILES = ["dictionary.json"]

// Ensure directories
fs.ensureDirSync(VERSION_DIR)
fs.ensureDirSync(BUILD_DIR)
fs.emptyDirSync(BUILD_DIR)

// Init dictionary
const dictionary = {
Expand All @@ -26,7 +23,7 @@ const dictionary = {

// Fill dictionary
for (const path of glob.sync(`${SOURCE_DIR}/dictionary/*.yaml`)) {
const contents = fs.readFileSync(path)
const contents = fs.readFileSync(path).toString()
Object.assign(dictionary.definitions, yaml.load(contents))
}

Expand All @@ -44,7 +41,7 @@ for (const path of glob.sync(`${SOURCE_DIR}/*.json`)) {
for (const path of glob.sync(`${VERSION_DIR}/*.json`)) {
const name = nodePath.basename(path)
if (EXCLUDE_FILES.includes(name)) continue
const rawSchema = JSON.parse(fs.readFileSync(path))
const rawSchema = JSON.parse(fs.readFileSync(path).toString())
const cwd = process.cwd()
process.chdir(VERSION_DIR)
const schema = await JsonSchema.dereference(rawSchema)
Expand All @@ -53,8 +50,12 @@ for (const path of glob.sync(`${VERSION_DIR}/*.json`)) {
fs.writeFileSync(path, contents)
}

// Ensure correct versions in the docs
await replaceInFile({
files: ["content/docs/standard/*.mdx"],
from: /profile: \/profiles\/\d.\d\//g,
to: `profile: /profiles/${version}/`,
})

// Delete dictionary
fs.removeSync(`${VERSION_DIR}/dictionary.json`)

// Copy to build
fs.cpSync(TARGET_DIR, BUILD_DIR, { recursive: true })
Loading

0 comments on commit b9ee508

Please sign in to comment.