From a77b3da3fc9b05409e1f60c97cf0b635ae7b26ac Mon Sep 17 00:00:00 2001 From: Zeke Sikelianos Date: Thu, 1 Dec 2016 14:54:16 -0800 Subject: [PATCH] new report names --- bin/build.js | 24 ++++++++++++------- lib/report.js | 11 +++++---- ...pp_dependencies.json => dependencies.json} | 8 +++---- ...ependencies.json => dev_dependencies.json} | 8 +++---- ...ributors.json => github_contributors.json} | 8 +++---- ...ges.json => most_downloaded_packages.json} | 6 ++--- ...kage_authors.json => package_authors.json} | 6 ++--- ...dencies.json => package_dependencies.json} | 6 ++--- test/report.js | 8 +++++++ 9 files changed, 50 insertions(+), 35 deletions(-) rename reports/{popular_app_dependencies.json => dependencies.json} (99%) rename reports/{popular_app_development_dependencies.json => dev_dependencies.json} (99%) rename reports/{prolific_github_contributors.json => github_contributors.json} (99%) rename reports/{most_downloaded_npm_packages.json => most_downloaded_packages.json} (99%) rename reports/{prolific_package_authors.json => package_authors.json} (99%) rename reports/{popular_low_level_dependencies.json => package_dependencies.json} (99%) diff --git a/bin/build.js b/bin/build.js index 8f7a541..d7262ff 100644 --- a/bin/build.js +++ b/bin/build.js @@ -30,42 +30,48 @@ function finish () { topDevDeps.forEach(pkg => Object.assign(pkg, registryData[pkg.name])) new Report({ - title: 'Popular App Dependencies', - description: 'A list of the top npm packages most often listed as `dependencies` in Electron apps.', + slug: 'dependencies', + title: 'App Dependencies', + description: 'We searched every public repository on GitHub to compile this list of npm packages that are most often listed as `dependencies` in apps that also depend on `electron` or `electron-prebuilt`.', collectionType: 'Package', collection: topDeps }).save() new Report({ - title: 'Popular App Development Dependencies', - description: 'A list of the top npm packages most often listed as `devDependencies` in Electron apps.', + slug: 'dev_dependencies', + title: 'App Development Dependencies', + description: 'This list highlights npm packages that are most often listed as `devDependencies` in apps that also depend on `electron` or `electron-prebuilt`.', collectionType: 'Package', collection: topDevDeps }).save() new Report({ - title: 'Prolific GitHub Contributors', - description: 'GitHub users that have contributed to the most Electron-related repositories.', + slug: 'github_contributors', + title: 'GitHub Contributors', + description: 'GitHub users who have contributed to numerous Electron-related repositories.', collectionType: 'GithubUser', collection: utils.getTopContributors(repos) }).save() new Report({ - title: 'Popular Low-level Dependencies', + slug: 'package_dependencies', + title: 'Package Dependencies', description: 'Electron-related npm packages that are frequently depended on by other npm packages.', collectionType: 'Package', collection: electronNpmPackages.sort((a, b) => b.totalDeps - a.totalDeps) }).save() new Report({ - title: 'Most-downloaded npm Packages', + slug: 'most_downloaded_packages', + title: 'Most Downloaded Packages', description: 'Electron-related npm packages that are downloaded a lot.', collectionType: 'Package', collection: electronNpmPackages.sort((a, b) => b.downloadsInLastMonth - a.downloadsInLastMonth) }).save() new Report({ - title: 'Prolific Package Authors', + slug: 'package_authors', + title: 'Package Authors', description: 'npm users who maintain numerous Electron-related packages.', collectionType: 'npmUser', collection: utils.getTopPackageAuthors(electronNpmPackages) diff --git a/lib/report.js b/lib/report.js index 4321317..ffce276 100644 --- a/lib/report.js +++ b/lib/report.js @@ -7,10 +7,6 @@ module.exports = class Report { constructor (props) { Object.assign(this, props) - if (this.title) { - this.basename = this.title.toLowerCase().replace(/[\s-]/g, '_') - } - switch (this.collectionType) { case 'Package': this.cleanPackages() @@ -34,7 +30,7 @@ module.exports = class Report { if (!this.valid) return console.error(this.validationErrors) fs.writeFileSync( - path.join(__dirname, `../reports/${this.basename}.json`), + path.join(__dirname, `../reports/${this.slug}.json`), JSON.stringify(this, null, 2) ) } @@ -78,6 +74,11 @@ module.exports = class Report { const schema = { properties: { + slug: { + type: 'string', + required: true, + allowEmpty: false + }, title: { type: 'string', required: true, diff --git a/reports/popular_app_dependencies.json b/reports/dependencies.json similarity index 99% rename from reports/popular_app_dependencies.json rename to reports/dependencies.json index 4c9c173..22e0936 100644 --- a/reports/popular_app_dependencies.json +++ b/reports/dependencies.json @@ -1,6 +1,7 @@ { - "title": "Popular App Dependencies", - "description": "A list of the top npm packages most often listed as `dependencies` in Electron apps.", + "slug": "dependencies", + "title": "App Dependencies", + "description": "We searched every public repository on GitHub to compile this list of npm packages that are most often listed as `dependencies` in apps that also depend on `electron` or `electron-prebuilt`.", "collectionType": "Package", "collection": [ { @@ -18858,6 +18859,5 @@ } ] } - ], - "basename": "popular_app_dependencies" + ] } \ No newline at end of file diff --git a/reports/popular_app_development_dependencies.json b/reports/dev_dependencies.json similarity index 99% rename from reports/popular_app_development_dependencies.json rename to reports/dev_dependencies.json index de68ff4..ec3d744 100644 --- a/reports/popular_app_development_dependencies.json +++ b/reports/dev_dependencies.json @@ -1,6 +1,7 @@ { - "title": "Popular App Development Dependencies", - "description": "A list of the top npm packages most often listed as `devDependencies` in Electron apps.", + "slug": "dev_dependencies", + "title": "App Development Dependencies", + "description": "This list highlights npm packages that are most often listed as `devDependencies` in apps that also depend on `electron` or `electron-prebuilt`.", "collectionType": "Package", "collection": [ { @@ -19679,6 +19680,5 @@ } ] } - ], - "basename": "popular_app_development_dependencies" + ] } \ No newline at end of file diff --git a/reports/prolific_github_contributors.json b/reports/github_contributors.json similarity index 99% rename from reports/prolific_github_contributors.json rename to reports/github_contributors.json index 79e2885..00639ce 100644 --- a/reports/prolific_github_contributors.json +++ b/reports/github_contributors.json @@ -1,6 +1,7 @@ { - "title": "Prolific GitHub Contributors", - "description": "GitHub users that have contributed to the most Electron-related repositories.", + "slug": "github_contributors", + "title": "GitHub Contributors", + "description": "GitHub users who have contributed to numerous Electron-related repositories.", "collectionType": "GithubUser", "collection": [ { @@ -2003,6 +2004,5 @@ "user": "ruiming", "repos": 3 } - ], - "basename": "prolific_github_contributors" + ] } \ No newline at end of file diff --git a/reports/most_downloaded_npm_packages.json b/reports/most_downloaded_packages.json similarity index 99% rename from reports/most_downloaded_npm_packages.json rename to reports/most_downloaded_packages.json index edbf671..2447925 100644 --- a/reports/most_downloaded_npm_packages.json +++ b/reports/most_downloaded_packages.json @@ -1,5 +1,6 @@ { - "title": "Most-downloaded npm Packages", + "slug": "most_downloaded_packages", + "title": "Most Downloaded Packages", "description": "Electron-related npm packages that are downloaded a lot.", "collectionType": "Package", "collection": [ @@ -19143,6 +19144,5 @@ } ] } - ], - "basename": "most_downloaded_npm_packages" + ] } \ No newline at end of file diff --git a/reports/prolific_package_authors.json b/reports/package_authors.json similarity index 99% rename from reports/prolific_package_authors.json rename to reports/package_authors.json index 854b6de..e425097 100644 --- a/reports/prolific_package_authors.json +++ b/reports/package_authors.json @@ -1,5 +1,6 @@ { - "title": "Prolific Package Authors", + "slug": "package_authors", + "title": "Package Authors", "description": "npm users who maintain numerous Electron-related packages.", "collectionType": "npmUser", "collection": [ @@ -1587,6 +1588,5 @@ "freenode": null, "gravatar": "https://gravatar.com/avatar/98014649279dcef04f67ee307e3b9597?size=200&default=https%3A%2F%2Fcldup.com%2FFIjisumbxl.png" } - ], - "basename": "prolific_package_authors" + ] } \ No newline at end of file diff --git a/reports/popular_low_level_dependencies.json b/reports/package_dependencies.json similarity index 99% rename from reports/popular_low_level_dependencies.json rename to reports/package_dependencies.json index b8b90e4..1e87d16 100644 --- a/reports/popular_low_level_dependencies.json +++ b/reports/package_dependencies.json @@ -1,5 +1,6 @@ { - "title": "Popular Low-level Dependencies", + "slug": "package_dependencies", + "title": "Package Dependencies", "description": "Electron-related npm packages that are frequently depended on by other npm packages.", "collectionType": "Package", "collection": [ @@ -18540,6 +18541,5 @@ } ] } - ], - "basename": "popular_low_level_dependencies" + ] } \ No newline at end of file diff --git a/test/report.js b/test/report.js index 319a837..16ef231 100644 --- a/test/report.js +++ b/test/report.js @@ -3,6 +3,7 @@ const expect = require('chai').expect describe('Report class', () => { const goodParams = { + slug: 'githubbers', title: 'Prolific GitHubbers', description: 'Users on GitHub who work on lots of Electron apps.', collection: ['sally', 'bob', 'haxor'], @@ -14,6 +15,13 @@ describe('Report class', () => { expect(report.valid).to.equal(true) }) + it('requires a slug', () => { + const report = new Report(Object.assign({}, goodParams, {slug: null})) + expect(report.valid).to.equal(false) + expect(report.validationErrors.length).to.equal(1) + expect(report.validationErrors[0].property).to.equal('slug') + }) + it('requires a title', () => { const report = new Report(Object.assign({}, goodParams, {title: null})) expect(report.valid).to.equal(false)