Skip to content

Commit

Permalink
Merge branch 'master' into feat/proxy-mode
Browse files Browse the repository at this point in the history
  • Loading branch information
hezhengxu2018 authored Dec 19, 2023
2 parents b0bfa3b + 7e176f2 commit 41876a6
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 5 deletions.
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
# Changelog

## [3.49.2](https://github.com/cnpm/cnpmcore/compare/v3.49.1...v3.49.2) (2023-12-19)


### Bug Fixes

* ignore db query error default logger ([#626](https://github.com/cnpm/cnpmcore/issues/626)) ([6cc2f2d](https://github.com/cnpm/cnpmcore/commit/6cc2f2d8304d34ef4d195e8486a3d23456376cc5))
* should search default packages when text is empty ([#623](https://github.com/cnpm/cnpmcore/issues/623)) ([0c4a52d](https://github.com/cnpm/cnpmcore/commit/0c4a52d220e7206a767423be9deec249c58458b2))

## [3.49.2](https://github.com/cnpm/cnpmcore/compare/v3.49.1...v3.49.2) (2023-12-18)


### Bug Fixes

* should search default packages when text is empty ([#623](https://github.com/cnpm/cnpmcore/issues/623)) ([0c4a52d](https://github.com/cnpm/cnpmcore/commit/0c4a52d220e7206a767423be9deec249c58458b2))

## [3.49.1](https://github.com/cnpm/cnpmcore/compare/v3.49.0...v3.49.1) (2023-12-18)


### Bug Fixes

* use tar fork version to fix memory leak ([#625](https://github.com/cnpm/cnpmcore/issues/625)) ([6c519f7](https://github.com/cnpm/cnpmcore/commit/6c519f73ce453b40bd2f7c9b2bd92fd0a1f6836b))

## [3.49.0](https://github.com/cnpm/cnpmcore/compare/v3.48.4...v3.49.0) (2023-12-12)


Expand Down
2 changes: 1 addition & 1 deletion app/common/PackageUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { createReadStream } from 'node:fs';
import { Readable } from 'node:stream';
import { pipeline } from 'node:stream/promises';
import * as ssri from 'ssri';
import tar from 'tar';
import tar from '@fengmk2/tar';
import { AuthorType, PackageJSONType } from '../repository/PackageRepository';


Expand Down
3 changes: 3 additions & 0 deletions app/core/service/PackageSearchService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ export class PackageSearchService extends AbstractService {

// https://github.com/npms-io/queries/blob/master/lib/search.js#L8C1-L78C2
private _buildMatchQueries(text: string) {
if (!text) {
return [];
}
return [
// Standard match using cross_fields
{
Expand Down
2 changes: 1 addition & 1 deletion app/core/service/PackageVersionFileService.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from 'node:fs/promises';
import { join, dirname, basename } from 'node:path';
import { randomUUID } from 'node:crypto';
import tar from 'tar';
import tar from '@fengmk2/tar';
import {
AccessLevel,
SingletonProto,
Expand Down
6 changes: 5 additions & 1 deletion config/config.default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ export default (appInfo: EggAppConfig) => {
user: process.env.CNPMCORE_MYSQL_USER || process.env.MYSQL_USER || 'root',
password: process.env.CNPMCORE_MYSQL_PASSWORD || process.env.MYSQL_PASSWORD,
charset: 'utf8mb4',
logger: {},
logger: {
// https://github.com/cyjake/leoric/blob/master/docs/zh/logging.md#logqueryerror
// ignore query error
logQueryError() {},
},
};

config.redis = {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cnpmcore",
"version": "3.49.0",
"version": "3.49.2",
"description": "npm core",
"files": [
"dist/**/*"
Expand Down Expand Up @@ -78,6 +78,7 @@
"@eggjs/tegg-schedule-plugin": "^3.12.0",
"@eggjs/tsconfig": "^1.0.0",
"@elastic/elasticsearch": "^8.8.1",
"@fengmk2/tar": "^6.2.0",
"@node-rs/crc32": "^1.2.2",
"@simplewebauthn/server": "^7.0.1",
"@sinclair/typebox": "^0.23.0",
Expand Down Expand Up @@ -108,7 +109,6 @@
"s3-cnpmcore": "^1.1.2",
"semver": "^7.3.5",
"ssri": "^8.0.1",
"tar": "^6.1.13",
"type-fest": "^2.5.3",
"ua-parser-js": "^1.0.34",
"validate-npm-package-name": "^3.0.0"
Expand Down
27 changes: 27 additions & 0 deletions test/port/controller/package/SearchPackageController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,33 @@ describe('test/port/controller/package/SearchPackageController.test.ts', () => {
assert.equal(res.body.total, 1);
});

it('should get example package when search text is empty', async () => {
mockES.add({
method: 'POST',
path: `/${app.config.cnpmcore.elasticsearchIndex}/_search`,
}, () => {
return {
hits: {
total: { value: 1, relation: 'eq' },
hits: [{
_source: {
downloads: {
all: 0,
},
package: {
name: 'example',
description: 'example package',
},
},
}],
},
};
});
const res = await app.httpRequest()
.get('/-/v1/search?from=0&size=1');
assert.equal(res.body.objects[0].package.name, 'example');
assert.equal(res.body.total, 1);
});
});

describe('[PUT /-/v1/search/sync/:fullname] sync()', async () => {
Expand Down

0 comments on commit 41876a6

Please sign in to comment.