diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7f51a74..7448c1d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -17,6 +17,4 @@ npm test ## Authors -### Maintainers - - Timur Moziev ([@TimurRin](https://github.com/TimurRin)) diff --git a/README.md b/README.md index c33852f..61d69e3 100644 --- a/README.md +++ b/README.md @@ -18,9 +18,7 @@ npm install -g anca Visit [`CONTRIBUTING.md`](CONTRIBUTING.md). -Current maintainers: - -- Timur Moziev ([@TimurRin](https://github.com/TimurRin)) +Current maintainer - Timur Moziev ([@TimurRin](https://github.com/TimurRin)) ## License diff --git a/anca.json b/anca.json index c464ee8..8ee0ede 100644 --- a/anca.json +++ b/anca.json @@ -4,7 +4,8 @@ "name": "Timur Moziev", "github": "TimurRin", "email": "timur.moziev@gmail.com", - "type": "maintainer", + "type": "author", + "status": "active", "url": "https://timurrin.github.io/" } ], @@ -12,8 +13,8 @@ "dataVersion": 0, "version": { "latest": "0.1.0-dev.2", - "latestNext": "0.1.0-dev.2+next.20240812_132412", - "timestamp": 1723469052 + "latestNext": "0.1.0-dev.2+next.20240812_153741", + "timestamp": 1723477061 }, "files": [ { diff --git a/package.json b/package.json index 92e155e..a33649f 100755 --- a/package.json +++ b/package.json @@ -6,13 +6,11 @@ "project manager" ], "license": "ISC", - "contributors": [ - { - "email": "timur.moziev@gmail.com", - "name": "Timur Moziev", - "url": "https://timurrin.github.io/" - } - ], + "author": { + "email": "timur.moziev@gmail.com", + "name": "Timur Moziev", + "url": "https://timurrin.github.io/" + }, "files": [ "bin", "dist" diff --git a/src/actions/contributing.ts b/src/actions/contributing.ts index 5fa6d6f..83fa20d 100644 --- a/src/actions/contributing.ts +++ b/src/actions/contributing.ts @@ -42,15 +42,17 @@ function getContents(development: AncaDevelopment) { if (development.state.config.authors) { lines.push(`## Authors`); - // Group authors by type const groupedAuthors: Record = { + authors: [], contributors: [], maintainers: [], specials: [], }; development.state.config.authors.forEach((author) => { - if (author.type === "maintainer") { + if (author.type === "author") { + groupedAuthors.authors.push(author); + } else if (author.type === "maintainer") { groupedAuthors.maintainers.push(author); } else if (author.type === "contributor") { groupedAuthors.contributors.push(author); @@ -59,12 +61,16 @@ function getContents(development: AncaDevelopment) { } }); - // Sort each group alphabetically by name Object.keys(groupedAuthors).forEach((key) => { groupedAuthors[key].sort((a, b) => a.name.localeCompare(b.name)); }); - // Generate sections for each group + if (groupedAuthors.authors.length > 0) { + groupedAuthors.authors.forEach((author) => { + lines.push(formatAuthorLine(author)); + }); + } + if (groupedAuthors.maintainers.length > 0) { lines.push(`### Maintainers`); groupedAuthors.maintainers.forEach((author) => { diff --git a/src/actions/nodejs.ts b/src/actions/nodejs.ts index 1c45aa2..bb789df 100644 --- a/src/actions/nodejs.ts +++ b/src/actions/nodejs.ts @@ -53,6 +53,7 @@ const packageNameOrder = [ "homepage", "bugs", "license", + "author", "contributors", "funding", "files", @@ -143,16 +144,48 @@ const FILE_PATH = "package.json"; * * @param config */ -function getContributors(config: AncaConfig) { - return ( - config.authors?.map((author) => { - return { +function getAuthors(config: AncaConfig) { + const authors: { + author?: NodeJsPackageAuthor; + contributors?: NodeJsPackageAuthor[]; + } = {}; + + if (config.authors == null) { + return authors; + } + + for (const author of config.authors) { + const isAuthor = author.type === "author" && authors.author == null; + const isMaintainer = + author.type === "maintainer" && author.status !== "retired"; + + if (!isAuthor && !isMaintainer) { + continue; + } + + const authorNew: NodeJsPackageAuthor = { name: author.name }; + if (author.email) { + authorNew.email = author.email; + } + if (author.url) { + authorNew.url = author.url; + } + + if (isAuthor) { + authors.author = { email: author.email, name: author.name, url: author.url, }; - }) || [] - ); + } else if (isMaintainer) { + if (authors.contributors == null) { + authors.contributors = []; + } + authors.contributors.push(authorNew); + } + } + + return authors; } /** @@ -279,8 +312,11 @@ function hasLicense(contents: NodejsPackageJson) { * @param config */ function hasContributors(contents: NodejsPackageJson, config: AncaConfig) { - const contributors = getContributors(config); - return isDeepStrictEqual(contributors, contents.contributors); + const authors = getAuthors(config); + return ( + isDeepStrictEqual(authors.author, contents.author) && + isDeepStrictEqual(authors.contributors, contents.contributors) + ); } /** @@ -781,9 +817,19 @@ async function fixPackageContributors( contents: NodejsPackageJson, config: AncaConfig, ) { - const contributors = getContributors(config); - rebuildFile.contributors = contributors; - contents.author = null; + const authors = getAuthors(config); + + if (authors.author) { + rebuildFile.author = authors.author; + } else { + contents.author = null; + } + + if (authors.contributors) { + rebuildFile.contributors = authors.contributors; + } else { + contents.contributors = null; + } } /** diff --git a/src/actions/readme.ts b/src/actions/readme.ts index 42b162c..1831f57 100644 --- a/src/actions/readme.ts +++ b/src/actions/readme.ts @@ -107,11 +107,15 @@ function getContents(development: AncaDevelopment) { if (development.state.config.authors) { const maintainers = development.state.config.authors.filter( - (author) => author.type === "maintainer", + (author) => + (author.type === "author" || author.type === "maintainer") && + author.status !== "retired", ); - if (maintainers.length > 0) { + if (maintainers.length > 1) { lines.push(`Current maintainers:`); lines.push(...maintainers.map(formatAuthorLine)); + } else if (maintainers.length === 1) { + lines.push(`Current maintainer ${formatAuthorLine(maintainers[0])}`); } } diff --git a/src/cinnabar.ts b/src/cinnabar.ts index 44ef50b..ec56652 100644 --- a/src/cinnabar.ts +++ b/src/cinnabar.ts @@ -1,4 +1,4 @@ // This file was generated by Cinnabar Meta. Do not edit. -export const CINNABAR_PROJECT_TIMESTAMP = 1723469052; -export const CINNABAR_PROJECT_VERSION = "0.1.0-dev.2+next.20240812_132412"; +export const CINNABAR_PROJECT_TIMESTAMP = 1723477061; +export const CINNABAR_PROJECT_VERSION = "0.1.0-dev.2+next.20240812_153741"; diff --git a/src/schema.ts b/src/schema.ts index cb53ec9..4c56519 100644 --- a/src/schema.ts +++ b/src/schema.ts @@ -88,8 +88,9 @@ export interface AncaConfigAuthor { email?: string; github?: string; name: string; + status?: "active" | "inactive" | "retired"; text?: string; - type?: "contributor" | "maintainer" | "special"; + type?: "author" | "contributor" | "maintainer" | "special"; url?: string; } @@ -199,9 +200,10 @@ export const ANCA_CONFIG_SCHEMA = { email: { type: "string" }, github: { type: "string" }, name: { type: "string" }, + status: { enum: ["active", "inactive", "retired"], type: "string" }, text: { type: "string" }, type: { - enum: ["contributor", "maintainer", "special"], + enum: ["author", "contributor", "maintainer", "special"], type: "string", }, url: { type: "string" }, @@ -317,6 +319,9 @@ export function formatAuthorLine(author: AncaConfigAuthor): string { } else if (author.email) { authorLine += ` — <${author.email}>`; } + if (author.status != null && author.status !== "active") { + authorLine += ` — ${author.status}`; + } if (author.text) { authorLine += ` — ${author.text}`; }