Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/@types/nice-package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export interface NicePackageType {
bundlesize?: Array<Record<string, unknown>>;
created: string;
dependencies?: Record<string, string>;
deprecated?: boolean;
deprecated?: boolean | string;
description: string;
devDependencies?: Record<string, string>;
gitHead?: string;
Expand Down
1 change: 1 addition & 0 deletions src/@types/pkg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export interface RawPkg {
readme: string;
owner: Owner | null;
deprecated: boolean;
deprecatedReason: string | null;
homepage: string | null;
license: string | null;
keywords: string[];
Expand Down
78 changes: 78 additions & 0 deletions src/__tests__/__snapshots__/formatPkg.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,77 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`deprecated log deprecated reason and flag 1`] = `
Object {
"_searchInternal": Object {
"alternativeNames": Array [
"0",
"0.js",
"0js",
],
},
"bin": Object {},
"computedKeywords": Array [],
"computedMetadata": Object {},
"created": NaN,
"dependencies": Object {},
"deprecated": true,
"deprecatedReason": "Yes this is deprecated",
"description": null,
"devDependencies": Object {},
"downloadsLast30Days": 0,
"downloadsRatio": 0,
"gitHead": "master",
"githubRepo": Object {
"head": "master",
"path": "",
"project": "npm-search",
"user": "algolia",
},
"homepage": null,
"humanDownloadsLast30Days": "0",
"keywords": Array [],
"lastCrawl": Any<String>,
"lastPublisher": null,
"license": null,
"modified": NaN,
"moduleTypes": Array [
"unknown",
],
"name": "0",
"objectID": "0",
"originalAuthor": undefined,
"owner": Object {
"avatar": "https://github.com/algolia.png",
"link": "https://github.com/algolia",
"name": "algolia",
},
"owners": Array [],
"popular": false,
"readme": "",
"repository": Object {
"branch": "master",
"head": undefined,
"host": "github.com",
"path": "",
"project": "npm-search",
"type": "git",
"url": "https://github.com/algolia/npm-search",
"user": "algolia",
},
"tags": Object {
"latest": "1.2.3",
},
"types": Object {
"ts": Object {
"dtsMain": "index.d.ts",
"possible": true,
},
},
"version": "0.0.0",
"versions": Object {},
}
`;

exports[`nice-package should nice atlaskit 1`] = `
Package {
"_resolved": "file:packages/input",
Expand Down Expand Up @@ -661,6 +733,7 @@ Object {
"styled-components": "^1.4.6",
},
"deprecated": false,
"deprecatedReason": null,
"description": "Internal component used by field-base to create field-text. DO NOT USE DIRECTLY",
"devDependencies": Object {
"@atlaskit/field-base": "^8.0.2",
Expand Down Expand Up @@ -856,6 +929,7 @@ Object {
"@atomic-package/utility": "0.0.2",
},
"deprecated": false,
"deprecatedReason": null,
"description": "atomic-package - tab",
"devDependencies": Object {
"@types/node": "^7.0.14",
Expand Down Expand Up @@ -990,6 +1064,7 @@ Object {
"validate-npm-package-name": "3.0.0",
},
"deprecated": false,
"deprecatedReason": null,
"description": "⚡️ Build InstantSearch apps at the speed of thought",
"devDependencies": Object {
"babel-eslint": "10.0.1",
Expand Down Expand Up @@ -1097,6 +1172,7 @@ Object {
"created": 1346430013243,
"dependencies": Object {},
"deprecated": false,
"deprecatedReason": null,
"description": "Microsoft sucks",
"devDependencies": Object {},
"downloadsLast30Days": 0,
Expand Down Expand Up @@ -1183,6 +1259,7 @@ Object {
"clipboard": "^2.0.0",
},
"deprecated": false,
"deprecatedReason": null,
"description": "Lightweight, robust, elegant syntax highlighting. A spin-off project from Dabblet.",
"devDependencies": Object {
"chai": "^4.2.0",
Expand Down Expand Up @@ -1383,6 +1460,7 @@ Object {
"created": NaN,
"dependencies": Object {},
"deprecated": false,
"deprecatedReason": null,
"description": null,
"devDependencies": Object {},
"downloadsLast30Days": 0,
Expand Down
24 changes: 24 additions & 0 deletions src/__tests__/formatPkg.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -698,3 +698,27 @@ describe('getVersions', () => {
});
});
});

describe('deprecated', () => {
it('log deprecated reason and flag', () => {
const pkg: GetPackage = {
...BASE,
'dist-tags': {
latest: '1.2.3',
},
versions: {
'1.2.3': {
...BASE_VERSION,
deprecated: 'Yes this is deprecated',
},
},
};
const formatted = formatPkg(pkg);

expect(formatted).toMatchSnapshot({
lastCrawl: expect.any(String),
deprecated: true,
deprecatedReason: 'Yes this is deprecated',
});
});
});
5 changes: 4 additions & 1 deletion src/formatPkg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ export default function formatPkg(pkg: GetPackage): RawPkg | undefined {
const moduleTypes = getModuleTypes(cleaned);

const tags = pkg['dist-tags'];
const isDeprecated =
cleaned.deprecated !== undefined && cleaned.deprecated !== false;

const rawPkg: RawPkg = {
objectID: cleaned.name,
Expand All @@ -157,7 +159,8 @@ export default function formatPkg(pkg: GetPackage): RawPkg | undefined {
gitHead: githubRepo ? githubRepo.head : null, // remove this when we update to the new schema frontend
readme: pkg.readme,
owner,
deprecated: cleaned.deprecated !== undefined ? cleaned.deprecated : false,
deprecated: isDeprecated,
deprecatedReason: isDeprecated ? String(cleaned.deprecated) : null,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we can afford breaking changes on the index, can you keep deprecated as is, and add a new field isDeprecated for the boolean form?

Copy link
Contributor Author

@bodinsamuel bodinsamuel Jul 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could, we are providing this for free and it was not good.
However we can indeed provide a grace period for the transition, by not changing deprecated for the moment.
Do we have a list of authorised user somewhere to contact?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added the new field and put back deprecated

homepage: getHomePage(cleaned),
license,
keywords,
Expand Down
3 changes: 3 additions & 0 deletions src/npm/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export interface GetVersion {
_id: string;
_npmUser?: GetUser;
_npmVersion?: string;
_nodeVersion?: string;
_npmOperationalInternal?: Record<string, string>;
author?: GetUser;
description: string;
dist: {
Expand All @@ -32,6 +34,7 @@ export interface GetVersion {
name: string;
scripts?: Record<string, string>;
version: string;
deprecated?: string | boolean;
}

export interface PackageRepo {
Expand Down