diff --git a/CITATION.cff b/CITATION.cff index c3e1beb..fd7984c 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -1,7 +1,7 @@ authors: - family-names: Hieber - given-names: Daniel W. - orcid: 'https://orcid.org/0000-0002-1411-3773' + given-names: Daniel W. + orcid: https://orcid.org/0000-0002-1411-3773 website: https://danielhieber.info cff-version: 1.2.0 license: MIT @@ -10,4 +10,4 @@ repository-code: https://github.com/digitallinguistics/tools title: Tools for Linguistic Productivity (TooLiP) type: software url: https://tools.digitallinguistics.io -version: 0.1.0 \ No newline at end of file +version: 0.1.0 diff --git a/LICENSE b/LICENSE index 2a94377..64d2965 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2024 Digital Linguistics +Copyright (c) 2013–2024 Daniel W. Hieber Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/build/updateDocs.js b/build/updateDocs.js new file mode 100644 index 0000000..6ca79e2 --- /dev/null +++ b/build/updateDocs.js @@ -0,0 +1,50 @@ +/** + * Updates the version number and dates in documentation. + * NOTE: This script is run using npm scripts rather than 11ty + * because it's not part of the website build, just the project build. + */ + +import path from 'node:path' +import { readFile } from 'node:fs/promises' + +import { outputFile, readJSON } from 'fs-extra/esm' + +import { + parse as parseYAML, + stringify as stringifyYAML, +} from 'yaml' + +const citationPath = path.resolve(import.meta.dirname, `../CITATION.cff`) +const licensePath = path.resolve(import.meta.dirname, `../LICENSE`) +const packagePath = path.resolve(import.meta.dirname, `../package.json`) + +const yearRegExp = /(?<=[0-9]{4}\u2013)[0-9]{4}/v + +async function updateCitation() { + + const meta = await readJSON(packagePath) + const citationYAML = await readFile(citationPath, `utf8`) + const citationData = parseYAML(citationYAML) + + citationData.version = meta.version + + await outputFile(citationPath, stringifyYAML(citationData)) + +} + +async function updateLicense() { + + const currentYear = (new Date).getFullYear() + const licenseText = await readFile(licensePath, `utf8`) + const updatedText = licenseText.replace(yearRegExp, `${ currentYear }`) + + await outputFile(licensePath, updatedText) + +} + +export default async function updateDocs() { + await updateCitation() + await updateLicense() +} + +updateDocs() diff --git a/package-lock.json b/package-lock.json index 8e5e653..75d40cd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,7 +14,8 @@ "@eslint/js": "^9.3.0", "@stylistic/eslint-plugin-js": "^2.1.0", "eslint": "^9.3.0", - "fs-extra": "^11.2.0" + "fs-extra": "^11.2.0", + "yaml": "^2.4.2" } }, "node_modules/@11ty/dependency-tree": { @@ -2961,6 +2962,18 @@ } } }, + "node_modules/yaml": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.4.2.tgz", + "integrity": "sha512-B3VqDZ+JAg1nZpaEmWtTXUlBneoGx6CPM9b0TENK6aoSu5t73dItudwdgmi6tHlIZZId4dZ9skcAQ2UbcyAeVA==", + "dev": true, + "bin": { + "yaml": "bin.mjs" + }, + "engines": { + "node": ">= 14" + } + }, "node_modules/yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", diff --git a/package.json b/package.json index 9a2774c..fc7d043 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "type": "module", "scripts": { "build": "eleventy", + "postbuild": "node build/updateDocs.js", "start": "eleventy --serve" }, "devDependencies": { @@ -33,6 +34,7 @@ "@eslint/js": "^9.3.0", "@stylistic/eslint-plugin-js": "^2.1.0", "eslint": "^9.3.0", - "fs-extra": "^11.2.0" + "fs-extra": "^11.2.0", + "yaml": "^2.4.2" } }