refactor: use tegg v4 (#765)
This commit is contained in:
6
.oxlintrc.json
Normal file
6
.oxlintrc.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"plugins": ["import"],
|
||||
"rules": {
|
||||
"import/no-cycle": "error"
|
||||
}
|
||||
}
|
||||
8
app.ts
8
app.ts
@@ -1,7 +1,7 @@
|
||||
import path from 'node:path';
|
||||
import { readFile } from 'node:fs/promises';
|
||||
import { Application } from 'egg';
|
||||
import { ChangesStreamService } from './app/core/service/ChangesStreamService';
|
||||
import { Application, ILifecycleBoot } from 'egg';
|
||||
import { ChangesStreamService } from './app/core/service/ChangesStreamService.js';
|
||||
|
||||
declare module 'egg' {
|
||||
interface Application {
|
||||
@@ -9,7 +9,7 @@ declare module 'egg' {
|
||||
}
|
||||
}
|
||||
|
||||
export default class CnpmcoreAppHook {
|
||||
export default class CnpmcoreAppHook implements ILifecycleBoot {
|
||||
private readonly app: Application;
|
||||
|
||||
constructor(app: Application) {
|
||||
@@ -17,7 +17,7 @@ export default class CnpmcoreAppHook {
|
||||
this.app.binaryHTML = '';
|
||||
}
|
||||
|
||||
async configWillLoad() {
|
||||
configWillLoad() {
|
||||
const app = this.app;
|
||||
// https://github.com/eggjs/tegg/blob/master/plugin/orm/app.ts#L37
|
||||
// store query sql to log
|
||||
|
||||
@@ -6,7 +6,7 @@ import url from 'node:url';
|
||||
import { randomBytes } from 'node:crypto';
|
||||
import { EggContextHttpClient, HttpClientResponse } from 'egg';
|
||||
import mime from 'mime-types';
|
||||
import dayjs from './dayjs';
|
||||
import dayjs from './dayjs.js';
|
||||
|
||||
interface DownloadToTempfileOptionalConfig {
|
||||
retries?: number,
|
||||
|
||||
@@ -2,8 +2,9 @@ import { createReadStream } from 'node:fs';
|
||||
import { Readable } from 'node:stream';
|
||||
import { pipeline } from 'node:stream/promises';
|
||||
import * as ssri from 'ssri';
|
||||
// @ts-expect-error type error
|
||||
import tar from '@fengmk2/tar';
|
||||
import { AuthorType, PackageJSONType } from '../repository/PackageRepository';
|
||||
import type { AuthorType, PackageJSONType } from '../repository/PackageRepository.js';
|
||||
|
||||
|
||||
// /@cnpm%2ffoo
|
||||
@@ -12,7 +13,7 @@ import { AuthorType, PackageJSONType } from '../repository/PackageRepository';
|
||||
// /foo
|
||||
// name max length is 214 chars
|
||||
// https://www.npmjs.com/package/path-to-regexp#custom-matching-parameters
|
||||
export const FULLNAME_REG_STRING = '@[^/]{1,220}\/[^/]{1,220}|@[^%]+\%2[fF][^/]{1,220}|[^@/]{1,220}';
|
||||
export const FULLNAME_REG_STRING = '@[^/]{1,220}/[^/]{1,220}|@[^%]+%2[fF][^/]{1,220}|[^@/]{1,220}';
|
||||
|
||||
export function getScopeAndName(fullname: string): string[] {
|
||||
if (fullname.startsWith('@')) {
|
||||
@@ -86,7 +87,7 @@ export async function hasShrinkWrapInTgz(contentOrFile: Uint8Array | string): Pr
|
||||
const parser = tar.t({
|
||||
// options.strict 默认为 false,会忽略 Recoverable errors,例如 tar 解析失败
|
||||
// 详见 https://github.com/isaacs/node-tar#warnings-and-errors
|
||||
onentry(entry) {
|
||||
onentry(entry: any) {
|
||||
if (entry.path === 'package/npm-shrinkwrap.json') {
|
||||
hasShrinkWrap = true;
|
||||
abortController.abort();
|
||||
@@ -122,8 +123,8 @@ export async function extractPackageJSON(tarballBytes: Buffer): Promise<PackageJ
|
||||
return new Promise((resolve, reject) => {
|
||||
Readable.from(tarballBytes)
|
||||
.pipe(tar.t({
|
||||
filter: name => name === 'package/package.json',
|
||||
onentry: async entry => {
|
||||
filter: (name: string) => name === 'package/package.json',
|
||||
onentry: async (entry: any) => {
|
||||
const chunks: Buffer[] = [];
|
||||
for await (const chunk of entry) {
|
||||
chunks.push(chunk);
|
||||
@@ -131,7 +132,7 @@ export async function extractPackageJSON(tarballBytes: Buffer): Promise<PackageJ
|
||||
try {
|
||||
const data = Buffer.concat(chunks);
|
||||
return resolve(JSON.parse(data.toString()));
|
||||
} catch (err) {
|
||||
} catch {
|
||||
reject(new Error('Error parsing package.json'));
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { AccessLevel, SingletonProto } from '@eggjs/tegg';
|
||||
import { BugVersion } from '../../core/entity/BugVersion';
|
||||
import { BugVersion } from '../../core/entity/BugVersion.js';
|
||||
|
||||
@SingletonProto({
|
||||
accessLevel: AccessLevel.PUBLIC,
|
||||
|
||||
@@ -7,8 +7,8 @@ import {
|
||||
} from '@eggjs/tegg';
|
||||
import { Pointcut } from '@eggjs/tegg/aop';
|
||||
import { EggLogger } from 'egg';
|
||||
import { AsyncTimer } from '../aop/AsyncTimer';
|
||||
import { NFSClient } from '../typing';
|
||||
import { AsyncTimer } from '../aop/AsyncTimer.js';
|
||||
import { NFSClient } from '../typing.js';
|
||||
|
||||
const INSTANCE_NAME = 'nfsAdapter';
|
||||
|
||||
|
||||
@@ -11,8 +11,8 @@ import {
|
||||
HttpClientRequestOptions,
|
||||
HttpClientResponse,
|
||||
} from 'egg';
|
||||
import { PackageManifestType } from '../../repository/PackageRepository';
|
||||
import { isTimeoutError } from '../ErrorUtil';
|
||||
import { PackageManifestType } from '../../repository/PackageRepository.js';
|
||||
import { isTimeoutError } from '../ErrorUtil.js';
|
||||
|
||||
type HttpMethod = HttpClientRequestOptions['method'];
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ImplDecorator, Inject, QualifierImplDecoratorUtil } from '@eggjs/tegg';
|
||||
import { BinaryType } from '../../enum/Binary';
|
||||
import { EggHttpClient, EggLogger } from 'egg';
|
||||
import { BinaryName, BinaryTaskConfig } from '../../../../config/binaries';
|
||||
import { BinaryType } from '../../enum/Binary.js';
|
||||
import { BinaryName, BinaryTaskConfig } from '../../../../config/binaries.js';
|
||||
|
||||
export type BinaryItem = {
|
||||
name: string;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { AbstractBinary, FetchResult, BinaryItem, BinaryAdapter } from './AbstractBinary';
|
||||
import { Inject, SingletonProto } from '@eggjs/tegg';
|
||||
import { BinaryType } from '../../enum/Binary';
|
||||
import { EggAppConfig } from 'egg';
|
||||
import { BinaryType } from '../../enum/Binary.js';
|
||||
import { AbstractBinary, FetchResult, BinaryItem, BinaryAdapter } from './AbstractBinary.js';
|
||||
|
||||
@SingletonProto()
|
||||
@BinaryAdapter(BinaryType.Api)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { SingletonProto } from '@eggjs/tegg';
|
||||
import { BinaryType } from '../../enum/Binary';
|
||||
import binaries, { BinaryName, BinaryTaskConfig } from '../../../../config/binaries';
|
||||
import path from 'node:path';
|
||||
import { AbstractBinary, FetchResult, BinaryItem, BinaryAdapter } from './AbstractBinary';
|
||||
import { SingletonProto } from '@eggjs/tegg';
|
||||
import { BinaryType } from '../../enum/Binary.js';
|
||||
import binaries, { BinaryName, BinaryTaskConfig } from '../../../../config/binaries.js';
|
||||
import { AbstractBinary, FetchResult, BinaryItem, BinaryAdapter } from './AbstractBinary.js';
|
||||
|
||||
@SingletonProto()
|
||||
@BinaryAdapter(BinaryType.Bucket)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { basename } from 'node:path';
|
||||
import { SingletonProto } from '@eggjs/tegg';
|
||||
import { BinaryType } from '../../enum/Binary';
|
||||
import { AbstractBinary, FetchResult, BinaryItem, BinaryAdapter } from './AbstractBinary';
|
||||
import { BinaryType } from '../../enum/Binary.js';
|
||||
import { AbstractBinary, FetchResult, BinaryItem, BinaryAdapter } from './AbstractBinary.js';
|
||||
|
||||
@SingletonProto()
|
||||
@BinaryAdapter(BinaryType.ChromeForTesting)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { SingletonProto } from '@eggjs/tegg';
|
||||
import { BinaryType } from '../../enum/Binary';
|
||||
import { AbstractBinary, FetchResult, BinaryItem, BinaryAdapter } from './AbstractBinary';
|
||||
import { BinaryType } from '../../enum/Binary.js';
|
||||
import { AbstractBinary, FetchResult, BinaryItem, BinaryAdapter } from './AbstractBinary.js';
|
||||
|
||||
@SingletonProto()
|
||||
@BinaryAdapter(BinaryType.Cypress)
|
||||
|
||||
@@ -2,8 +2,8 @@ import path from 'node:path';
|
||||
import { SingletonProto } from '@eggjs/tegg';
|
||||
import {
|
||||
AbstractBinary, FetchResult, BinaryItem, BinaryAdapter,
|
||||
} from './AbstractBinary';
|
||||
import { BinaryType } from '../../enum/Binary';
|
||||
} from './AbstractBinary.js';
|
||||
import { BinaryType } from '../../enum/Binary.js';
|
||||
|
||||
@SingletonProto()
|
||||
@BinaryAdapter(BinaryType.Edgedriver)
|
||||
@@ -175,7 +175,7 @@ export class EdgedriverBinary extends AbstractBinary {
|
||||
#parseItems(xml: string): BinaryItem[] {
|
||||
const items: BinaryItem[] = [];
|
||||
// <Blob><Name>124.0.2478.97/edgedriver_arm64.zip</Name><Url>https://msedgewebdriverstorage.blob.core.windows.net/edgewebdriver/124.0.2478.97/edgedriver_arm64.zip</Url><Properties><Last-Modified>Fri, 10 May 2024 18:35:44 GMT</Last-Modified><Etag>0x8DC712000713C13</Etag><Content-Length>9191362</Content-Length><Content-Type>application/octet-stream</Content-Type><Content-Encoding /><Content-Language /><Content-MD5>1tjPTf5JU6KKB06Qf1JOGw==</Content-MD5><Cache-Control /><BlobType>BlockBlob</BlobType><LeaseStatus>unlocked</LeaseStatus></Properties></Blob>
|
||||
const fileRe = /<Blob><Name>([^<]+?)<\/Name><Url>([^<]+?)<\/Url><Properties><Last\-Modified>([^<]+?)<\/Last\-Modified><Etag>(?:[^<]+?)<\/Etag><Content\-Length>(\d+)<\/Content\-Length>/g;
|
||||
const fileRe = /<Blob><Name>([^<]+?)<\/Name><Url>([^<]+?)<\/Url><Properties><Last-Modified>([^<]+?)<\/Last-Modified><Etag>(?:[^<]+?)<\/Etag><Content-Length>(\d+)<\/Content-Length>/g;
|
||||
const matchItems = xml.matchAll(fileRe);
|
||||
for (const m of matchItems) {
|
||||
const fullname = m[1].trim();
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { SingletonProto } from '@eggjs/tegg';
|
||||
import { BinaryType } from '../../enum/Binary';
|
||||
import binaries, { BinaryName } from '../../../../config/binaries';
|
||||
import { BinaryAdapter, BinaryItem, FetchResult } from './AbstractBinary';
|
||||
import { GithubBinary } from './GithubBinary';
|
||||
import binaries, { BinaryName } from '../../../../config/binaries.js';
|
||||
import { BinaryType } from '../../enum/Binary.js';
|
||||
import { BinaryAdapter, BinaryItem, FetchResult } from './AbstractBinary.js';
|
||||
import { GithubBinary } from './GithubBinary.js';
|
||||
|
||||
@SingletonProto()
|
||||
@BinaryAdapter(BinaryType.Electron)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { SingletonProto } from '@eggjs/tegg';
|
||||
import { BinaryType } from '../../enum/Binary';
|
||||
import binaries, { BinaryName, BinaryTaskConfig } from '../../../../config/binaries';
|
||||
import { AbstractBinary, FetchResult, BinaryItem, BinaryAdapter } from './AbstractBinary';
|
||||
import binaries, { BinaryName, BinaryTaskConfig } from '../../../../config/binaries.js';
|
||||
import { BinaryType } from '../../enum/Binary.js';
|
||||
import { AbstractBinary, FetchResult, BinaryItem, BinaryAdapter } from './AbstractBinary.js';
|
||||
|
||||
@SingletonProto()
|
||||
@BinaryAdapter(BinaryType.GitHub)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { SingletonProto } from '@eggjs/tegg';
|
||||
import { BinaryType } from '../../enum/Binary';
|
||||
import binaries, { BinaryName } from '../../../../config/binaries';
|
||||
import { AbstractBinary, FetchResult, BinaryItem, BinaryAdapter } from './AbstractBinary';
|
||||
import binaries, { BinaryName } from '../../../../config/binaries.js';
|
||||
import { BinaryType } from '../../enum/Binary.js';
|
||||
import { AbstractBinary, FetchResult, BinaryItem, BinaryAdapter } from './AbstractBinary.js';
|
||||
|
||||
@SingletonProto()
|
||||
@BinaryAdapter(BinaryType.Imagemin)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { basename } from 'node:path';
|
||||
import { SingletonProto } from '@eggjs/tegg';
|
||||
import { BinaryType } from '../../enum/Binary';
|
||||
import binaries, { BinaryName } from '../../../../config/binaries';
|
||||
import { AbstractBinary, FetchResult, BinaryItem, BinaryAdapter } from './AbstractBinary';
|
||||
import { BinaryType } from '../../enum/Binary.js';
|
||||
import binaries, { BinaryName } from '../../../../config/binaries.js';
|
||||
import { AbstractBinary, FetchResult, BinaryItem, BinaryAdapter } from './AbstractBinary.js';
|
||||
|
||||
@SingletonProto()
|
||||
@BinaryAdapter(BinaryType.Node)
|
||||
@@ -30,7 +30,7 @@ export class NodeBinary extends AbstractBinary {
|
||||
// <a href="/dist/v18.15.0/SHASUMS256.txt.asc">SHASUMS256.txt.asc</a> 04-Nov-2024 17:29 3.7 KB
|
||||
// <a href="/dist/v18.15.0/SHASUMS256.txt.sig">SHASUMS256.txt.sig</a> 04-Nov-2024 17:29 310 B
|
||||
// <a href="/dist/v18.15.0/SHASUMS256.txt">SHASUMS256.txt</a> 04-Nov-2024 17:29 3.2 KB
|
||||
const re = /<a href="([^\"]+?)"[^>]*?>[^<]+?<\/a>\s+?((?:[\w\-]+? \w{2}\:\d{2})|\-)\s+?([\d\.\-\s\w]+)/ig;
|
||||
const re = /<a href="([^"]+?)"[^>]*?>[^<]+?<\/a>\s+?((?:[\w-]+? \w{2}:\d{2})|-)\s+?([\d.\-\s\w]+)/ig;
|
||||
const matchs = html.matchAll(re);
|
||||
const items: BinaryItem[] = [];
|
||||
for (const m of matchs) {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { SingletonProto } from '@eggjs/tegg';
|
||||
import { BinaryType } from '../../enum/Binary';
|
||||
import binaries, { BinaryName } from '../../../../config/binaries';
|
||||
import { join } from 'node:path';
|
||||
import { AbstractBinary, FetchResult, BinaryItem, BinaryAdapter } from './AbstractBinary';
|
||||
import { SingletonProto } from '@eggjs/tegg';
|
||||
import binaries, { BinaryName } from '../../../../config/binaries.js';
|
||||
import { BinaryType } from '../../enum/Binary.js';
|
||||
import { AbstractBinary, FetchResult, BinaryItem, BinaryAdapter } from './AbstractBinary.js';
|
||||
|
||||
@SingletonProto()
|
||||
@BinaryAdapter(BinaryType.NodePreGyp)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { SingletonProto } from '@eggjs/tegg';
|
||||
import { BinaryType } from '../../enum/Binary';
|
||||
import binaries from '../../../../config/binaries';
|
||||
import { FetchResult, BinaryItem, BinaryAdapter } from './AbstractBinary';
|
||||
import { BucketBinary } from './BucketBinary';
|
||||
import binaries from '../../../../config/binaries.js';
|
||||
import { BinaryType } from '../../enum/Binary.js';
|
||||
import { FetchResult, BinaryItem, BinaryAdapter } from './AbstractBinary.js';
|
||||
import { BucketBinary } from './BucketBinary.js';
|
||||
|
||||
@SingletonProto()
|
||||
@BinaryAdapter(BinaryType.Nwjs)
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
|
||||
import { AbstractBinary, BinaryAdapter, BinaryItem, FetchResult } from './AbstractBinary';
|
||||
import util from 'node:util';
|
||||
import path from 'node:path';
|
||||
import { SingletonProto } from '@eggjs/tegg';
|
||||
import { BinaryType } from '../../enum/Binary';
|
||||
import { BinaryType } from '../../enum/Binary.js';
|
||||
import { AbstractBinary, BinaryAdapter, BinaryItem, FetchResult } from './AbstractBinary.js';
|
||||
|
||||
const PACKAGE_URL = 'https://registry.npmjs.com/playwright-core';
|
||||
const DOWNLOAD_HOST = 'https://playwright.azureedge.net/';
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import path from 'node:path';
|
||||
import { SingletonProto } from '@eggjs/tegg';
|
||||
import { BinaryType } from '../../enum/Binary';
|
||||
import binaries, { BinaryName } from '../../../../config/binaries';
|
||||
import { AbstractBinary, FetchResult, BinaryItem, BinaryAdapter } from './AbstractBinary';
|
||||
import { BinaryType } from '../../enum/Binary.js';
|
||||
import binaries, { BinaryName } from '../../../../config/binaries.js';
|
||||
import { AbstractBinary, FetchResult, BinaryItem, BinaryAdapter } from './AbstractBinary.js';
|
||||
|
||||
@SingletonProto()
|
||||
@BinaryAdapter(BinaryType.Prisma)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { SingletonProto } from '@eggjs/tegg';
|
||||
import { BinaryType } from '../../enum/Binary';
|
||||
import { AbstractBinary, FetchResult, BinaryItem, BinaryAdapter } from './AbstractBinary';
|
||||
import { BinaryType } from '../../enum/Binary.js';
|
||||
import { AbstractBinary, FetchResult, BinaryItem, BinaryAdapter } from './AbstractBinary.js';
|
||||
|
||||
@SingletonProto()
|
||||
@BinaryAdapter(BinaryType.Puppeteer)
|
||||
@@ -37,7 +37,7 @@ export class PuppeteerBinary extends AbstractBinary {
|
||||
// };
|
||||
const unpkgURL = 'https://unpkg.com/puppeteer-core@latest/lib/cjs/puppeteer/revisions.js';
|
||||
const text = await this.requestXml(unpkgURL);
|
||||
const m = /chromium:\s+\'(\d+)\'\,/.exec(text);
|
||||
const m = /chromium:\s+'(\d+)',/.exec(text);
|
||||
if (m && !chromiumRevisions.has(m[1])) {
|
||||
chromiumRevisions.set(m[1], new Date().toISOString());
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { SingletonProto } from '@eggjs/tegg';
|
||||
import { BinaryType } from '../../enum/Binary';
|
||||
import { AbstractBinary, FetchResult, BinaryItem, BinaryAdapter } from './AbstractBinary';
|
||||
import { BinaryType } from '../../enum/Binary.js';
|
||||
import { AbstractBinary, FetchResult, BinaryItem, BinaryAdapter } from './AbstractBinary.js';
|
||||
|
||||
@SingletonProto()
|
||||
@BinaryAdapter(BinaryType.Sqlcipher)
|
||||
|
||||
@@ -3,8 +3,8 @@ import {
|
||||
Inject,
|
||||
QualifierImplDecoratorUtil,
|
||||
} from '@eggjs/tegg';
|
||||
import { RegistryType } from '../../../common/enum/Registry';
|
||||
import { Registry } from '../../../core/entity/Registry';
|
||||
import { RegistryType } from '../../../common/enum/Registry.js';
|
||||
import { Registry } from '../../../core/entity/Registry.js';
|
||||
import {
|
||||
EggHttpClient,
|
||||
EggLogger,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { SingletonProto } from '@eggjs/tegg';
|
||||
import { RegistryType } from '../../../common/enum/Registry';
|
||||
import { Registry } from '../../../core/entity/Registry';
|
||||
import { E500 } from 'egg-errors';
|
||||
import { AbstractChangeStream, RegistryChangesStream } from './AbstractChangesStream';
|
||||
import { RegistryType } from '../../../common/enum/Registry.js';
|
||||
import { Registry } from '../../../core/entity/Registry.js';
|
||||
import { AbstractChangeStream, RegistryChangesStream } from './AbstractChangesStream.js';
|
||||
|
||||
@SingletonProto()
|
||||
@RegistryChangesStream(RegistryType.Cnpmcore)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { SingletonProto } from '@eggjs/tegg';
|
||||
import { RegistryType } from '../../../common/enum/Registry';
|
||||
import { Registry } from '../../../core/entity/Registry';
|
||||
import { E500 } from 'egg-errors';
|
||||
import { AbstractChangeStream, RegistryChangesStream } from './AbstractChangesStream';
|
||||
import { RegistryType } from '../../../common/enum/Registry.js';
|
||||
import { Registry } from '../../../core/entity/Registry.js';
|
||||
import { AbstractChangeStream, RegistryChangesStream } from './AbstractChangesStream.js';
|
||||
|
||||
const MAX_LIMIT = 10000;
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { SingletonProto } from '@eggjs/tegg';
|
||||
import { E500 } from 'egg-errors';
|
||||
import { RegistryType } from '../../../common/enum/Registry';
|
||||
import { Registry } from '../../../core/entity/Registry';
|
||||
import { AbstractChangeStream, ChangesStreamChange, RegistryChangesStream } from './AbstractChangesStream';
|
||||
import { RegistryType } from '../../../common/enum/Registry.js';
|
||||
import { Registry } from '../../../core/entity/Registry.js';
|
||||
import { AbstractChangeStream, ChangesStreamChange, RegistryChangesStream } from './AbstractChangesStream.js';
|
||||
|
||||
@SingletonProto()
|
||||
@RegistryChangesStream(RegistryType.Npm)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import dayjs from 'dayjs';
|
||||
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
||||
import customParseFormat from 'dayjs/plugin/customParseFormat.js';
|
||||
dayjs.extend(customParseFormat);
|
||||
|
||||
export default dayjs;
|
||||
|
||||
@@ -2,5 +2,6 @@
|
||||
"name": "cnpmcore-common",
|
||||
"eggModule": {
|
||||
"name": "cnpmcoreCommon"
|
||||
}
|
||||
},
|
||||
"type": "module"
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Readable } from 'node:stream';
|
||||
import { IncomingHttpHeaders } from 'node:http';
|
||||
import { EggContext } from '@eggjs/tegg';
|
||||
import { estypes } from '@elastic/elasticsearch';
|
||||
import { CnpmcoreConfig } from '../port/config';
|
||||
import { CnpmcoreConfig } from '../port/config.js';
|
||||
|
||||
export interface UploadResult {
|
||||
key: string;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Entity, EntityData } from './Entity';
|
||||
import { EasyData, EntityUtil } from '../util/EntityUtil';
|
||||
import { Entity, EntityData } from './Entity.js';
|
||||
import { EasyData, EntityUtil } from '../util/EntityUtil.js';
|
||||
|
||||
interface BinaryData extends EntityData {
|
||||
binaryId: string;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Entity, EntityData } from './Entity';
|
||||
import { EasyData, EntityUtil } from '../util/EntityUtil';
|
||||
import { Entity, EntityData } from './Entity.js';
|
||||
import { EasyData, EntityUtil } from '../util/EntityUtil.js';
|
||||
|
||||
interface ChangeData extends EntityData {
|
||||
changeId: string;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Entity, EntityData } from './Entity';
|
||||
import { EasyData, EntityUtil } from '../util/EntityUtil';
|
||||
import { Entity, EntityData } from './Entity.js';
|
||||
import { EasyData, EntityUtil } from '../util/EntityUtil.js';
|
||||
|
||||
interface DistData extends EntityData {
|
||||
distId: string;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Entity, EntityData } from './Entity';
|
||||
import { EasyData, EntityUtil } from '../util/EntityUtil';
|
||||
import { HookType } from '../../common/enum/Hook';
|
||||
import crypto from 'node:crypto';
|
||||
import { Entity, EntityData } from './Entity.js';
|
||||
import { EasyData, EntityUtil } from '../util/EntityUtil.js';
|
||||
import { HookType } from '../../common/enum/Hook.js';
|
||||
|
||||
export type CreateHookData = Omit<EasyData<HookData, 'hookId'>, 'enable' | 'latestTaskId'>;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { HookEventType } from '../../common/enum/Hook';
|
||||
import { HookEventType } from '../../common/enum/Hook.js';
|
||||
|
||||
export interface PublishChangePayload {
|
||||
'dist-tag'?: string;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Entity, EntityData } from './Entity';
|
||||
import { EasyData, EntityUtil } from '../util/EntityUtil';
|
||||
import { Dist } from './Dist';
|
||||
import { getFullname } from '../../common/PackageUtil';
|
||||
import { Entity, EntityData } from './Entity.js';
|
||||
import { EasyData, EntityUtil } from '../util/EntityUtil.js';
|
||||
import { Dist } from './Dist.js';
|
||||
import { getFullname } from '../../common/PackageUtil.js';
|
||||
|
||||
interface PackageData extends EntityData {
|
||||
scope: string;
|
||||
@@ -22,6 +22,10 @@ export enum DIST_NAMES {
|
||||
ABBREVIATED_MANIFESTS = 'abbreviated_manifests.json',
|
||||
}
|
||||
|
||||
export function isPkgManifest(fileType: DIST_NAMES) {
|
||||
return fileType === DIST_NAMES.FULL_MANIFESTS || fileType === DIST_NAMES.ABBREVIATED_MANIFESTS;
|
||||
}
|
||||
|
||||
interface FileInfo {
|
||||
size: number;
|
||||
shasum: string;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Entity, EntityData } from './Entity';
|
||||
import { EasyData, EntityUtil } from '../util/EntityUtil';
|
||||
import { Entity, EntityData } from './Entity.js';
|
||||
import { EasyData, EntityUtil } from '../util/EntityUtil.js';
|
||||
|
||||
interface PackageTagData extends EntityData {
|
||||
packageId: string;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Dist } from './Dist';
|
||||
import { Entity, EntityData } from './Entity';
|
||||
import { EasyData, EntityUtil } from '../util/EntityUtil';
|
||||
import { PaddingSemVer } from './PaddingSemVer';
|
||||
import { Dist } from './Dist.js';
|
||||
import { Entity, EntityData } from './Entity.js';
|
||||
import { EasyData, EntityUtil } from '../util/EntityUtil.js';
|
||||
import { PaddingSemVer } from './PaddingSemVer.js';
|
||||
|
||||
interface PackageVersionData extends EntityData {
|
||||
packageId: string;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Entity, EntityData } from './Entity';
|
||||
import { EasyData, EntityUtil } from '../util/EntityUtil';
|
||||
import { Entity, EntityData } from './Entity.js';
|
||||
import { EasyData, EntityUtil } from '../util/EntityUtil.js';
|
||||
|
||||
interface PackageVersionBlockData extends EntityData {
|
||||
packageVersionBlockId: string;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Dist } from './Dist';
|
||||
import { Entity, EntityData } from './Entity';
|
||||
import { EasyData, EntityUtil } from '../util/EntityUtil';
|
||||
import { Dist } from './Dist.js';
|
||||
import { Entity, EntityData } from './Entity.js';
|
||||
import { EasyData, EntityUtil } from '../util/EntityUtil.js';
|
||||
|
||||
interface PackageVersionFileData extends EntityData {
|
||||
packageVersionFileId: string;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Entity, EntityData } from './Entity';
|
||||
import { EasyData, EntityUtil } from '../util/EntityUtil';
|
||||
import { Entity, EntityData } from './Entity.js';
|
||||
import { EasyData, EntityUtil } from '../util/EntityUtil.js';
|
||||
|
||||
interface PackageVersionManifestData extends EntityData {
|
||||
packageId: string;
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { Entity, EntityData } from './Entity';
|
||||
import { EasyData } from '../util/EntityUtil';
|
||||
import { DIST_NAMES } from './Package';
|
||||
import { isPkgManifest } from '../service/ProxyCacheService';
|
||||
import { PROXY_CACHE_DIR_NAME } from '../../common/constants';
|
||||
import { Entity, EntityData } from './Entity.js';
|
||||
import { EasyData } from '../util/EntityUtil.js';
|
||||
import { DIST_NAMES, isPkgManifest } from './Package.js';
|
||||
import { PROXY_CACHE_DIR_NAME } from '../../common/constants.js';
|
||||
interface ProxyCacheData extends EntityData {
|
||||
fullname: string;
|
||||
fileType: DIST_NAMES;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Entity, EntityData } from './Entity';
|
||||
import { EasyData, EntityUtil } from '../util/EntityUtil';
|
||||
import type { RegistryType } from '../../common/enum/Registry';
|
||||
import { Entity, EntityData } from './Entity.js';
|
||||
import { EasyData, EntityUtil } from '../util/EntityUtil.js';
|
||||
import type { RegistryType } from '../../common/enum/Registry.js';
|
||||
|
||||
interface RegistryData extends EntityData {
|
||||
name: string;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Entity, EntityData } from './Entity';
|
||||
import { EasyData, EntityUtil } from '../util/EntityUtil';
|
||||
import { Entity, EntityData } from './Entity.js';
|
||||
import { EasyData, EntityUtil } from '../util/EntityUtil.js';
|
||||
|
||||
interface ScopeData extends EntityData {
|
||||
name: string;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Range, Comparator } from 'semver';
|
||||
import { PaddingSemVer } from './PaddingSemVer';
|
||||
import { PaddingSemVer } from './PaddingSemVer.js';
|
||||
|
||||
const OPERATOR_MAP = {
|
||||
'<': '$lt',
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
import { Entity, EntityData } from './Entity';
|
||||
import { EasyData, EntityUtil } from '../util/EntityUtil';
|
||||
import { TaskType, TaskState } from '../../common/enum/Task';
|
||||
import { PROXY_CACHE_DIR_NAME } from '../../common/constants';
|
||||
import dayjs from '../../common/dayjs';
|
||||
import { HookEvent } from './HookEvent';
|
||||
import { DIST_NAMES } from './Package';
|
||||
import { isPkgManifest } from '../service/ProxyCacheService';
|
||||
import { InternalServerError } from 'egg-errors';
|
||||
import { Entity, EntityData } from './Entity.js';
|
||||
import { EasyData, EntityUtil } from '../util/EntityUtil.js';
|
||||
import { TaskType, TaskState } from '../../common/enum/Task.js';
|
||||
import { PROXY_CACHE_DIR_NAME } from '../../common/constants.js';
|
||||
import dayjs from '../../common/dayjs.js';
|
||||
import { HookEvent } from './HookEvent.js';
|
||||
import { DIST_NAMES, isPkgManifest } from './Package.js';
|
||||
|
||||
export const HOST_NAME = os.hostname();
|
||||
export const PID = process.pid;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import dayjs from 'dayjs';
|
||||
import { Entity, EntityData } from './Entity';
|
||||
import { EasyData, EntityUtil } from '../util/EntityUtil';
|
||||
import { Entity, EntityData } from './Entity.js';
|
||||
import { EasyData, EntityUtil } from '../util/EntityUtil.js';
|
||||
|
||||
export enum TokenType {
|
||||
granular = 'granular',
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Entity, EntityData } from './Entity';
|
||||
import { EasyData, EntityUtil } from '../util/EntityUtil';
|
||||
import { cleanUserPrefix } from '../../common/PackageUtil';
|
||||
import { Entity, EntityData } from './Entity.js';
|
||||
import { EasyData, EntityUtil } from '../util/EntityUtil.js';
|
||||
import { cleanUserPrefix } from '../../common/PackageUtil.js';
|
||||
|
||||
interface UserData extends EntityData {
|
||||
userId: string;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Entity, EntityData } from './Entity';
|
||||
import { EasyData, EntityUtil } from '../util/EntityUtil';
|
||||
import { Entity, EntityData } from './Entity.js';
|
||||
import { EasyData, EntityUtil } from '../util/EntityUtil.js';
|
||||
|
||||
interface WebauthnCredentialData extends EntityData {
|
||||
wancId: string;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Event, Inject } from '@eggjs/tegg';
|
||||
import { EggLogger } from 'egg';
|
||||
import { PACKAGE_VERSION_ADDED } from './index';
|
||||
import { BUG_VERSIONS } from '../../common/constants';
|
||||
import { BugVersionService } from '../service/BugVersionService';
|
||||
import { PACKAGE_VERSION_ADDED } from './index.js';
|
||||
import { BUG_VERSIONS } from '../../common/constants.js';
|
||||
import { BugVersionService } from '../service/BugVersionService.js';
|
||||
|
||||
@Event(PACKAGE_VERSION_ADDED)
|
||||
export class BugVersionFixHandler {
|
||||
|
||||
@@ -11,8 +11,8 @@ import {
|
||||
PACKAGE_MAINTAINER_CHANGED,
|
||||
PACKAGE_MAINTAINER_REMOVED,
|
||||
PACKAGE_META_CHANGED,
|
||||
} from './index';
|
||||
import { CacheService } from '../../core/service/CacheService';
|
||||
} from './index.js';
|
||||
import { CacheService } from '../../core/service/CacheService.js';
|
||||
|
||||
class CacheCleanerEvent {
|
||||
@Inject()
|
||||
|
||||
@@ -10,13 +10,13 @@ import {
|
||||
PACKAGE_MAINTAINER_CHANGED,
|
||||
PACKAGE_MAINTAINER_REMOVED,
|
||||
PACKAGE_META_CHANGED, PackageMetaChange,
|
||||
} from './index';
|
||||
import { ChangeRepository } from '../../repository/ChangeRepository';
|
||||
import { Change } from '../entity/Change';
|
||||
import { HookEvent } from '../entity/HookEvent';
|
||||
import { Task } from '../entity/Task';
|
||||
import { User } from '../entity/User';
|
||||
import { TaskService } from '../service/TaskService';
|
||||
} from './index.js';
|
||||
import { ChangeRepository } from '../../repository/ChangeRepository.js';
|
||||
import { Change } from '../entity/Change.js';
|
||||
import { HookEvent } from '../entity/HookEvent.js';
|
||||
import { Task } from '../entity/Task.js';
|
||||
import { User } from '../entity/User.js';
|
||||
import { TaskService } from '../service/TaskService.js';
|
||||
|
||||
class ChangesStreamEvent {
|
||||
@Inject()
|
||||
|
||||
@@ -2,11 +2,11 @@ import { Event, Inject } from '@eggjs/tegg';
|
||||
import {
|
||||
EggAppConfig,
|
||||
} from 'egg';
|
||||
import { PACKAGE_VERSION_ADDED } from './index';
|
||||
import { getScopeAndName } from '../../common/PackageUtil';
|
||||
import { PackageVersionManifest as PackageVersionManifestEntity } from '../entity/PackageVersionManifest';
|
||||
import { PackageRepository } from '../../repository/PackageRepository';
|
||||
import { DistRepository } from '../../repository/DistRepository';
|
||||
import { PACKAGE_VERSION_ADDED } from './index.js';
|
||||
import { getScopeAndName } from '../../common/PackageUtil.js';
|
||||
import { PackageVersionManifest as PackageVersionManifestEntity } from '../entity/PackageVersionManifest.js';
|
||||
import { PackageRepository } from '../../repository/PackageRepository.js';
|
||||
import { DistRepository } from '../../repository/DistRepository.js';
|
||||
|
||||
class StoreManifestEvent {
|
||||
@Inject()
|
||||
|
||||
@@ -14,9 +14,8 @@ import {
|
||||
PACKAGE_META_CHANGED,
|
||||
PACKAGE_BLOCKED,
|
||||
PACKAGE_UNBLOCKED,
|
||||
} from './index';
|
||||
|
||||
import { PackageSearchService } from '../service/PackageSearchService';
|
||||
} from './index.js';
|
||||
import { PackageSearchService } from '../service/PackageSearchService.js';
|
||||
|
||||
class SyncESPackage {
|
||||
@Inject()
|
||||
|
||||
@@ -3,10 +3,10 @@ import {
|
||||
EggAppConfig, EggLogger,
|
||||
} from 'egg';
|
||||
import { ForbiddenError } from 'egg-errors';
|
||||
import { PACKAGE_VERSION_ADDED, PACKAGE_TAG_ADDED, PACKAGE_TAG_CHANGED } from './index';
|
||||
import { getScopeAndName } from '../../common/PackageUtil';
|
||||
import { PackageManagerService } from '../service/PackageManagerService';
|
||||
import { PackageVersionFileService } from '../service/PackageVersionFileService';
|
||||
import { PACKAGE_VERSION_ADDED, PACKAGE_TAG_ADDED, PACKAGE_TAG_CHANGED } from './index.js';
|
||||
import { getScopeAndName } from '../../common/PackageUtil.js';
|
||||
import { PackageManagerService } from '../service/PackageManagerService.js';
|
||||
import { PackageVersionFileService } from '../service/PackageVersionFileService.js';
|
||||
|
||||
class SyncPackageVersionFileEvent {
|
||||
@Inject()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import '@eggjs/tegg';
|
||||
import { User } from '../entity/User';
|
||||
import { User } from '../entity/User.js';
|
||||
|
||||
export const PACKAGE_UNPUBLISHED = 'PACKAGE_UNPUBLISHED';
|
||||
export const PACKAGE_BLOCKED = 'PACKAGE_BLOCKED';
|
||||
|
||||
@@ -2,5 +2,6 @@
|
||||
"name": "cnpmcore-core",
|
||||
"eggModule": {
|
||||
"name": "cnpmcoreCore"
|
||||
}
|
||||
},
|
||||
"type": "module"
|
||||
}
|
||||
|
||||
@@ -8,19 +8,19 @@ import {
|
||||
EggHttpClient,
|
||||
} from 'egg';
|
||||
import fs from 'node:fs/promises';
|
||||
import { sortBy } from 'lodash';
|
||||
import binaries, { BinaryName, CategoryName } from '../../../config/binaries';
|
||||
import { BinaryRepository } from '../../repository/BinaryRepository';
|
||||
import { Task } from '../entity/Task';
|
||||
import { Binary } from '../entity/Binary';
|
||||
import { TaskService } from './TaskService';
|
||||
import { NFSAdapter } from '../../common/adapter/NFSAdapter';
|
||||
import { downloadToTempfile } from '../../common/FileUtil';
|
||||
import { isTimeoutError } from '../../common/ErrorUtil';
|
||||
import { AbstractBinary, BinaryItem } from '../../common/adapter/binary/AbstractBinary';
|
||||
import { AbstractService } from '../../common/AbstractService';
|
||||
import { BinaryType } from '../../common/enum/Binary';
|
||||
import { TaskType, TaskState } from '../../common/enum/Task';
|
||||
import { sortBy } from 'lodash-es';
|
||||
import binaries, { BinaryName, CategoryName } from '../../../config/binaries.js';
|
||||
import { BinaryRepository } from '../../repository/BinaryRepository.js';
|
||||
import { Task } from '../entity/Task.js';
|
||||
import { Binary } from '../entity/Binary.js';
|
||||
import { TaskService } from './TaskService.js';
|
||||
import { NFSAdapter } from '../../common/adapter/NFSAdapter.js';
|
||||
import { downloadToTempfile } from '../../common/FileUtil.js';
|
||||
import { isTimeoutError } from '../../common/ErrorUtil.js';
|
||||
import { AbstractBinary, BinaryItem } from '../../common/adapter/binary/AbstractBinary.js';
|
||||
import { AbstractService } from '../../common/AbstractService.js';
|
||||
import { BinaryType } from '../../common/enum/Binary.js';
|
||||
import { TaskType, TaskState } from '../../common/enum/Task.js';
|
||||
|
||||
function isoNow() {
|
||||
return new Date().toISOString();
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { AccessLevel, SingletonProto, Inject } from '@eggjs/tegg';
|
||||
import { EggLogger } from 'egg';
|
||||
import pMap from 'p-map';
|
||||
import { BugVersion } from '../entity/BugVersion';
|
||||
import { PackageJSONType, PackageRepository } from '../../repository/PackageRepository';
|
||||
import { DistRepository } from '../../repository/DistRepository';
|
||||
import { getScopeAndName } from '../../common/PackageUtil';
|
||||
import { CacheService } from './CacheService';
|
||||
import { BUG_VERSIONS, LATEST_TAG } from '../../common/constants';
|
||||
import { BugVersionStore } from '../../common/adapter/BugVersionStore';
|
||||
import { BugVersion } from '../entity/BugVersion.js';
|
||||
import { PackageJSONType, PackageRepository } from '../../repository/PackageRepository.js';
|
||||
import { DistRepository } from '../../repository/DistRepository.js';
|
||||
import { getScopeAndName } from '../../common/PackageUtil.js';
|
||||
import { CacheService } from './CacheService.js';
|
||||
import { BUG_VERSIONS, LATEST_TAG } from '../../common/constants.js';
|
||||
import { BugVersionStore } from '../../common/adapter/BugVersionStore.js';
|
||||
|
||||
@SingletonProto({
|
||||
accessLevel: AccessLevel.PUBLIC,
|
||||
|
||||
@@ -3,11 +3,11 @@ import {
|
||||
SingletonProto,
|
||||
Inject,
|
||||
} from '@eggjs/tegg';
|
||||
import { CacheAdapter } from '../../common/adapter/CacheAdapter';
|
||||
import { AbstractService } from '../../common/AbstractService';
|
||||
import { ChangesStreamTaskData } from '../entity/Task';
|
||||
import { CacheAdapter } from '../../common/adapter/CacheAdapter.js';
|
||||
import { AbstractService } from '../../common/AbstractService.js';
|
||||
import { ChangesStreamTaskData } from '../entity/Task.js';
|
||||
|
||||
type PackageCacheAttribe = 'etag' | 'manifests';
|
||||
type PackageCacheAttribute = 'etag' | 'manifests';
|
||||
|
||||
export type UpstreamRegistryInfo = {
|
||||
registry_name: string;
|
||||
@@ -95,14 +95,14 @@ export class CacheService extends AbstractService {
|
||||
|
||||
public async removeCache(fullname: string) {
|
||||
await Promise.all([
|
||||
await this.cacheAdapter.delete(this.cacheKey(fullname, true, 'etag')),
|
||||
await this.cacheAdapter.delete(this.cacheKey(fullname, true, 'manifests')),
|
||||
await this.cacheAdapter.delete(this.cacheKey(fullname, false, 'etag')),
|
||||
await this.cacheAdapter.delete(this.cacheKey(fullname, false, 'manifests')),
|
||||
this.cacheAdapter.delete(this.cacheKey(fullname, true, 'etag')),
|
||||
this.cacheAdapter.delete(this.cacheKey(fullname, true, 'manifests')),
|
||||
this.cacheAdapter.delete(this.cacheKey(fullname, false, 'etag')),
|
||||
this.cacheAdapter.delete(this.cacheKey(fullname, false, 'manifests')),
|
||||
]);
|
||||
}
|
||||
|
||||
private cacheKey(fullname: string, isFullManifests: boolean, attribute: PackageCacheAttribe) {
|
||||
private cacheKey(fullname: string, isFullManifests: boolean, attribute: PackageCacheAttribute) {
|
||||
return `${fullname}|${isFullManifests ? 'full' : 'abbr'}:${attribute}`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,20 +7,20 @@ import {
|
||||
Inject,
|
||||
} from '@eggjs/tegg';
|
||||
import { E500 } from 'egg-errors';
|
||||
import { PackageSyncerService, RegistryNotMatchError } from './PackageSyncerService';
|
||||
import { TaskService } from './TaskService';
|
||||
import { RegistryManagerService } from './RegistryManagerService';
|
||||
import { ScopeManagerService } from './ScopeManagerService';
|
||||
import { PackageRepository } from '../../repository/PackageRepository';
|
||||
import { TaskRepository } from '../../repository/TaskRepository';
|
||||
import { HOST_NAME, ChangesStreamTask, Task } from '../entity/Task';
|
||||
import { Registry } from '../entity/Registry';
|
||||
import { AbstractChangeStream } from '../../common/adapter/changesStream/AbstractChangesStream';
|
||||
import { getScopeAndName } from '../../common/PackageUtil';
|
||||
import { isTimeoutError } from '../../common/ErrorUtil';
|
||||
import { GLOBAL_WORKER } from '../../common/constants';
|
||||
import { TaskState, TaskType } from '../../common/enum/Task';
|
||||
import { AbstractService } from '../../common/AbstractService';
|
||||
import { PackageSyncerService, RegistryNotMatchError } from './PackageSyncerService.js';
|
||||
import { TaskService } from './TaskService.js';
|
||||
import { RegistryManagerService } from './RegistryManagerService.js';
|
||||
import { ScopeManagerService } from './ScopeManagerService.js';
|
||||
import { PackageRepository } from '../../repository/PackageRepository.js';
|
||||
import { TaskRepository } from '../../repository/TaskRepository.js';
|
||||
import { HOST_NAME, ChangesStreamTask, Task } from '../entity/Task.js';
|
||||
import { Registry } from '../entity/Registry.js';
|
||||
import { AbstractChangeStream } from '../../common/adapter/changesStream/AbstractChangesStream.js';
|
||||
import { getScopeAndName } from '../../common/PackageUtil.js';
|
||||
import { isTimeoutError } from '../../common/ErrorUtil.js';
|
||||
import { GLOBAL_WORKER } from '../../common/constants.js';
|
||||
import { TaskState, TaskType } from '../../common/enum/Task.js';
|
||||
import { AbstractService } from '../../common/AbstractService.js';
|
||||
|
||||
@SingletonProto({
|
||||
accessLevel: AccessLevel.PUBLIC,
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import { AccessLevel, SingletonProto, Inject } from '@eggjs/tegg';
|
||||
import { AbstractService } from '../../common/AbstractService';
|
||||
import { HookType } from '../../common/enum/Hook';
|
||||
import { TaskState } from '../../common/enum/Task';
|
||||
import { HookEvent } from '../entity/HookEvent';
|
||||
import { CreateHookTask, Task } from '../entity/Task';
|
||||
import { HookRepository } from '../../repository/HookRepository';
|
||||
import { PackageRepository } from '../../repository/PackageRepository';
|
||||
import pMap from 'p-map';
|
||||
import { Hook } from '../entity/Hook';
|
||||
import { TaskService } from './TaskService';
|
||||
import { isoNow } from '../../common/LogUtil';
|
||||
import { getScopeAndName } from '../../common/PackageUtil';
|
||||
import { AbstractService } from '../../common/AbstractService.js';
|
||||
import { HookType } from '../../common/enum/Hook.js';
|
||||
import { TaskState } from '../../common/enum/Task.js';
|
||||
import { HookEvent } from '../entity/HookEvent.js';
|
||||
import { CreateHookTask, Task } from '../entity/Task.js';
|
||||
import { HookRepository } from '../../repository/HookRepository.js';
|
||||
import { PackageRepository } from '../../repository/PackageRepository.js';
|
||||
import { Hook } from '../entity/Hook.js';
|
||||
import { TaskService } from './TaskService.js';
|
||||
import { isoNow } from '../../common/LogUtil.js';
|
||||
import { getScopeAndName } from '../../common/PackageUtil.js';
|
||||
|
||||
@SingletonProto({
|
||||
accessLevel: AccessLevel.PUBLIC,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { SingletonProto, AccessLevel, Inject } from '@eggjs/tegg';
|
||||
import { EggLogger } from 'egg';
|
||||
import pMap from 'p-map';
|
||||
import { PackageVersionRepository } from '../../repository/PackageVersionRepository';
|
||||
import { PaddingSemVer } from '../entity/PaddingSemVer';
|
||||
import { PackageVersionRepository } from '../../repository/PackageVersionRepository.js';
|
||||
import { PaddingSemVer } from '../entity/PaddingSemVer.js';
|
||||
|
||||
@SingletonProto({
|
||||
accessLevel: AccessLevel.PUBLIC,
|
||||
|
||||
@@ -2,9 +2,9 @@ import {
|
||||
AccessLevel,
|
||||
SingletonProto,
|
||||
} from '@eggjs/tegg';
|
||||
import { AbstractService } from '../../common/AbstractService';
|
||||
import { NOT_IMPLEMENTED_PATH } from '../../common/constants';
|
||||
import { NotFoundError, NotImplementedError } from 'egg-errors';
|
||||
import { AbstractService } from '../../common/AbstractService.js';
|
||||
import { NOT_IMPLEMENTED_PATH } from '../../common/constants.js';
|
||||
|
||||
@SingletonProto({
|
||||
accessLevel: AccessLevel.PUBLIC,
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { AccessLevel, SingletonProto, Inject } from '@eggjs/tegg';
|
||||
import { Hook } from '../entity/Hook';
|
||||
import { HookType } from '../../common/enum/Hook';
|
||||
import {
|
||||
ForbiddenError,
|
||||
NotFoundError,
|
||||
} from 'egg-errors';
|
||||
import { HookRepository } from '../../repository/HookRepository';
|
||||
import { EggAppConfig } from 'egg';
|
||||
import { HookRepository } from '../../repository/HookRepository.js';
|
||||
import { Hook } from '../entity/Hook.js';
|
||||
import { HookType } from '../../common/enum/Hook.js';
|
||||
|
||||
export interface CreateHookCommand {
|
||||
type: HookType;
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import { AccessLevel, SingletonProto, Inject } from '@eggjs/tegg';
|
||||
import { TriggerHookTask } from '../entity/Task';
|
||||
import { HookEvent } from '../entity/HookEvent';
|
||||
import { HookRepository } from '../../repository/HookRepository';
|
||||
import { PackageRepository } from '../../repository/PackageRepository';
|
||||
import { DistRepository } from '../../repository/DistRepository';
|
||||
import { UserRepository } from '../../repository/UserRepository';
|
||||
import { Hook } from '../entity/Hook';
|
||||
import { EggContextHttpClient } from 'egg';
|
||||
import { isoNow } from '../../common/LogUtil';
|
||||
import { TaskState } from '../../common/enum/Task';
|
||||
import { TaskService } from './TaskService';
|
||||
import { getScopeAndName } from '../../common/PackageUtil';
|
||||
import { TriggerHookTask } from '../entity/Task.js';
|
||||
import { HookEvent } from '../entity/HookEvent.js';
|
||||
import { HookRepository } from '../../repository/HookRepository.js';
|
||||
import { PackageRepository } from '../../repository/PackageRepository.js';
|
||||
import { DistRepository } from '../../repository/DistRepository.js';
|
||||
import { UserRepository } from '../../repository/UserRepository.js';
|
||||
import { Hook } from '../entity/Hook.js';
|
||||
import { isoNow } from '../../common/LogUtil.js';
|
||||
import { TaskState } from '../../common/enum/Task.js';
|
||||
import { TaskService } from './TaskService.js';
|
||||
import { getScopeAndName } from '../../common/PackageUtil.js';
|
||||
|
||||
@SingletonProto({
|
||||
accessLevel: AccessLevel.PUBLIC,
|
||||
|
||||
@@ -18,19 +18,25 @@ import {
|
||||
getFullname,
|
||||
getScopeAndName,
|
||||
hasShrinkWrapInTgz,
|
||||
} from '../../common/PackageUtil';
|
||||
import { AbstractService } from '../../common/AbstractService';
|
||||
import { AbbreviatedPackageJSONType, AbbreviatedPackageManifestType, PackageJSONType, PackageManifestType, PackageRepository } from '../../repository/PackageRepository';
|
||||
import { PackageVersionBlockRepository } from '../../repository/PackageVersionBlockRepository';
|
||||
import { PackageVersionDownloadRepository } from '../../repository/PackageVersionDownloadRepository';
|
||||
import { DistRepository } from '../../repository/DistRepository';
|
||||
import { isDuplicateKeyError } from '../../repository/util/ErrorUtil';
|
||||
import { Package } from '../entity/Package';
|
||||
import { PackageVersion } from '../entity/PackageVersion';
|
||||
import { PackageVersionBlock } from '../entity/PackageVersionBlock';
|
||||
import { PackageTag } from '../entity/PackageTag';
|
||||
import { User } from '../entity/User';
|
||||
import { Dist } from '../entity/Dist';
|
||||
} from '../../common/PackageUtil.js';
|
||||
import { AbstractService } from '../../common/AbstractService.js';
|
||||
import {
|
||||
AbbreviatedPackageJSONType,
|
||||
AbbreviatedPackageManifestType,
|
||||
PackageJSONType,
|
||||
PackageManifestType,
|
||||
PackageRepository,
|
||||
} from '../../repository/PackageRepository.js';
|
||||
import { PackageVersionBlockRepository } from '../../repository/PackageVersionBlockRepository.js';
|
||||
import { PackageVersionDownloadRepository } from '../../repository/PackageVersionDownloadRepository.js';
|
||||
import { DistRepository } from '../../repository/DistRepository.js';
|
||||
import { isDuplicateKeyError } from '../../repository/util/ErrorUtil.js';
|
||||
import { Package } from '../entity/Package.js';
|
||||
import { PackageVersion } from '../entity/PackageVersion.js';
|
||||
import { PackageVersionBlock } from '../entity/PackageVersionBlock.js';
|
||||
import { PackageTag } from '../entity/PackageTag.js';
|
||||
import { User } from '../entity/User.js';
|
||||
import { Dist } from '../entity/Dist.js';
|
||||
import {
|
||||
PACKAGE_UNPUBLISHED,
|
||||
PACKAGE_BLOCKED,
|
||||
@@ -43,12 +49,12 @@ import {
|
||||
PACKAGE_TAG_CHANGED,
|
||||
PACKAGE_TAG_REMOVED,
|
||||
PACKAGE_META_CHANGED,
|
||||
} from '../event';
|
||||
import { BugVersionService } from './BugVersionService';
|
||||
import { BugVersion } from '../entity/BugVersion';
|
||||
import { RegistryManagerService } from './RegistryManagerService';
|
||||
import { Registry } from '../entity/Registry';
|
||||
import { PackageVersionService } from './PackageVersionService';
|
||||
} from '../event/index.js';
|
||||
import { BugVersionService } from './BugVersionService.js';
|
||||
import { BugVersion } from '../entity/BugVersion.js';
|
||||
import { RegistryManagerService } from './RegistryManagerService.js';
|
||||
import { Registry } from '../entity/Registry.js';
|
||||
import { PackageVersionService } from './PackageVersionService.js';
|
||||
|
||||
export interface PublishPackageCmd {
|
||||
// maintainer: Maintainer;
|
||||
@@ -706,8 +712,8 @@ export class PackageManagerService extends AbstractService {
|
||||
fullManifests,
|
||||
abbreviatedManifests,
|
||||
] = await Promise.all([
|
||||
await this._listPackageFullManifests(pkg),
|
||||
await this._listPackageAbbreviatedManifests(pkg),
|
||||
this._listPackageFullManifests(pkg),
|
||||
this._listPackageAbbreviatedManifests(pkg),
|
||||
]);
|
||||
await this._updatePackageManifestsToDists(pkg, fullManifests, abbreviatedManifests);
|
||||
}
|
||||
@@ -998,7 +1004,7 @@ export class PackageManagerService extends AbstractService {
|
||||
}
|
||||
const pkgVersion = await this.packageVersionService.getVersion(npa(`${fullname}@${spec}`));
|
||||
assert(pkgVersion);
|
||||
} catch (e) {
|
||||
} catch {
|
||||
throw new BadRequestError(`deps ${fullname}@${spec} not found`);
|
||||
}
|
||||
}, {
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
import { AccessLevel, Inject, SingletonProto } from '@eggjs/tegg';
|
||||
import { estypes, errors } from '@elastic/elasticsearch';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
import { AbstractService } from '../../common/AbstractService';
|
||||
import { formatAuthor, getScopeAndName } from '../../common/PackageUtil';
|
||||
import { PackageManagerService } from './PackageManagerService';
|
||||
import { SearchManifestType, SearchMappingType, SearchRepository } from '../../repository/SearchRepository';
|
||||
import { PackageVersionDownloadRepository } from '../../repository/PackageVersionDownloadRepository';
|
||||
import { PackageRepository } from '../../repository/PackageRepository';
|
||||
import { PackageVersionBlockRepository } from '../../repository/PackageVersionBlockRepository';
|
||||
import { AbstractService } from '../../common/AbstractService.js';
|
||||
import { formatAuthor, getScopeAndName } from '../../common/PackageUtil.js';
|
||||
import { PackageManagerService } from './PackageManagerService.js';
|
||||
import { SearchManifestType, SearchMappingType, SearchRepository } from '../../repository/SearchRepository.js';
|
||||
import { PackageVersionDownloadRepository } from '../../repository/PackageVersionDownloadRepository.js';
|
||||
import { PackageRepository } from '../../repository/PackageRepository.js';
|
||||
import { PackageVersionBlockRepository } from '../../repository/PackageVersionBlockRepository.js';
|
||||
|
||||
|
||||
@SingletonProto({
|
||||
@@ -58,7 +57,7 @@ export class PackageSearchService extends AbstractService {
|
||||
for (let i = 1; i <= 31; i++) {
|
||||
const day = String(i).padStart(2, '0');
|
||||
const field = `d${day}`;
|
||||
const counter = entity[field];
|
||||
const counter = entity[field as keyof typeof entity] as number;
|
||||
if (!counter) continue;
|
||||
downloadsAll += counter;
|
||||
}
|
||||
|
||||
@@ -8,30 +8,30 @@ import {
|
||||
} from '@eggjs/tegg';
|
||||
import { Pointcut } from '@eggjs/tegg/aop';
|
||||
import { EggHttpClient } from 'egg';
|
||||
import { isEqual, isEmpty } from 'lodash';
|
||||
import { isEqual, isEmpty } from 'lodash-es';
|
||||
import semver from 'semver';
|
||||
import { NPMRegistry, RegistryResponse } from '../../common/adapter/NPMRegistry';
|
||||
import { detectInstallScript, getScopeAndName } from '../../common/PackageUtil';
|
||||
import { downloadToTempfile } from '../../common/FileUtil';
|
||||
import { TaskState, TaskType } from '../../common/enum/Task';
|
||||
import { AbstractService } from '../../common/AbstractService';
|
||||
import { TaskRepository } from '../../repository/TaskRepository';
|
||||
import { PackageJSONType, PackageManifestType, PackageRepository } from '../../repository/PackageRepository';
|
||||
import { PackageVersionDownloadRepository } from '../../repository/PackageVersionDownloadRepository';
|
||||
import { UserRepository } from '../../repository/UserRepository';
|
||||
import { Task, SyncPackageTaskOptions, CreateSyncPackageTask } from '../entity/Task';
|
||||
import { Package } from '../entity/Package';
|
||||
import { UserService } from './UserService';
|
||||
import { TaskService } from './TaskService';
|
||||
import { PackageManagerService } from './PackageManagerService';
|
||||
import { CacheService } from './CacheService';
|
||||
import { User } from '../entity/User';
|
||||
import { RegistryManagerService } from './RegistryManagerService';
|
||||
import { Registry } from '../entity/Registry';
|
||||
import { BadRequestError } from 'egg-errors';
|
||||
import { ScopeManagerService } from './ScopeManagerService';
|
||||
import { EventCorkAdvice } from './EventCorkerAdvice';
|
||||
import { PresetRegistryName, SyncDeleteMode } from '../../common/constants';
|
||||
import { NPMRegistry, RegistryResponse } from '../../common/adapter/NPMRegistry.js';
|
||||
import { detectInstallScript, getScopeAndName } from '../../common/PackageUtil.js';
|
||||
import { downloadToTempfile } from '../../common/FileUtil.js';
|
||||
import { TaskState, TaskType } from '../../common/enum/Task.js';
|
||||
import { AbstractService } from '../../common/AbstractService.js';
|
||||
import { TaskRepository } from '../../repository/TaskRepository.js';
|
||||
import { PackageJSONType, PackageManifestType, PackageRepository } from '../../repository/PackageRepository.js';
|
||||
import { PackageVersionDownloadRepository } from '../../repository/PackageVersionDownloadRepository.js';
|
||||
import { UserRepository } from '../../repository/UserRepository.js';
|
||||
import { Task, SyncPackageTaskOptions, CreateSyncPackageTask } from '../entity/Task.js';
|
||||
import { Package } from '../entity/Package.js';
|
||||
import { UserService } from './UserService.js';
|
||||
import { TaskService } from './TaskService.js';
|
||||
import { PackageManagerService } from './PackageManagerService.js';
|
||||
import { CacheService } from './CacheService.js';
|
||||
import { User } from '../entity/User.js';
|
||||
import { RegistryManagerService } from './RegistryManagerService.js';
|
||||
import { Registry } from '../entity/Registry.js';
|
||||
import { ScopeManagerService } from './ScopeManagerService.js';
|
||||
import { EventCorkAdvice } from './EventCorkerAdvice.js';
|
||||
import { PresetRegistryName, SyncDeleteMode } from '../../common/constants.js';
|
||||
|
||||
type syncDeletePkgOptions = {
|
||||
task: Task,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import fs from 'node:fs/promises';
|
||||
import { join, dirname, basename } from 'node:path';
|
||||
import { randomUUID } from 'node:crypto';
|
||||
// @ts-expect-error type error
|
||||
import tar from '@fengmk2/tar';
|
||||
import {
|
||||
AccessLevel,
|
||||
@@ -9,24 +10,24 @@ import {
|
||||
} from '@eggjs/tegg';
|
||||
import { ConflictError, ForbiddenError } from 'egg-errors';
|
||||
import semver from 'semver';
|
||||
import { AbstractService } from '../../common/AbstractService';
|
||||
import { AbstractService } from '../../common/AbstractService.js';
|
||||
import {
|
||||
calculateIntegrity,
|
||||
getFullname,
|
||||
} from '../../common/PackageUtil';
|
||||
import { createTempDir, mimeLookup } from '../../common/FileUtil';
|
||||
} from '../../common/PackageUtil.js';
|
||||
import { createTempDir, mimeLookup } from '../../common/FileUtil.js';
|
||||
import {
|
||||
PackageRepository,
|
||||
} from '../../repository/PackageRepository';
|
||||
import { PackageVersionFileRepository } from '../../repository/PackageVersionFileRepository';
|
||||
import { PackageVersionRepository } from '../../repository/PackageVersionRepository';
|
||||
import { DistRepository } from '../../repository/DistRepository';
|
||||
import { isDuplicateKeyError } from '../../repository/util/ErrorUtil';
|
||||
import { PackageVersionFile } from '../entity/PackageVersionFile';
|
||||
import { PackageVersion } from '../entity/PackageVersion';
|
||||
import { Package } from '../entity/Package';
|
||||
import { PackageManagerService } from './PackageManagerService';
|
||||
import { CacheAdapter } from '../../common/adapter/CacheAdapter';
|
||||
} from '../../repository/PackageRepository.js';
|
||||
import { PackageVersionFileRepository } from '../../repository/PackageVersionFileRepository.js';
|
||||
import { PackageVersionRepository } from '../../repository/PackageVersionRepository.js';
|
||||
import { DistRepository } from '../../repository/DistRepository.js';
|
||||
import { isDuplicateKeyError } from '../../repository/util/ErrorUtil.js';
|
||||
import { PackageVersionFile } from '../entity/PackageVersionFile.js';
|
||||
import { PackageVersion } from '../entity/PackageVersion.js';
|
||||
import { Package } from '../entity/Package.js';
|
||||
import { PackageManagerService } from './PackageManagerService.js';
|
||||
import { CacheAdapter } from '../../common/adapter/CacheAdapter.js';
|
||||
|
||||
const unpkgWhiteListUrl = 'https://github.com/cnpm/unpkg-white-list';
|
||||
const CHECK_TIMEOUT = process.env.NODE_ENV === 'test' ? 1 : 60000;
|
||||
@@ -148,7 +149,7 @@ export class PackageVersionFileService extends AbstractService {
|
||||
file: tarFile,
|
||||
cwd: tmpdir,
|
||||
strip: 1,
|
||||
onentry: entry => {
|
||||
onentry: (entry: any) => {
|
||||
const filename = this.#formatTarEntryFilename(entry);
|
||||
if (!filename) return;
|
||||
if (this.#matchReadmeFilename(filename)) {
|
||||
@@ -204,7 +205,7 @@ export class PackageVersionFileService extends AbstractService {
|
||||
file: tarFile,
|
||||
cwd: tmpdir,
|
||||
strip: 1,
|
||||
onentry: entry => {
|
||||
onentry: (entry: any) => {
|
||||
const filename = this.#formatTarEntryFilename(entry);
|
||||
if (!filename) return;
|
||||
paths.push('/' + filename);
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { AccessLevel, SingletonProto, Inject } from '@eggjs/tegg';
|
||||
import semver, { Range } from 'semver';
|
||||
import { Result, AliasResult } from 'npm-package-arg';
|
||||
import { PackageVersionRepository } from '../../repository/PackageVersionRepository';
|
||||
import { getScopeAndName } from '../../common/PackageUtil';
|
||||
import { SqlRange } from '../entity/SqlRange';
|
||||
import { BugVersionService } from './BugVersionService';
|
||||
import type { PackageJSONType } from '../../repository/PackageRepository';
|
||||
import { DistRepository } from '../../repository/DistRepository';
|
||||
import { BugVersionAdvice } from '../entity/BugVersion';
|
||||
import { PackageVersionRepository } from '../../repository/PackageVersionRepository.js';
|
||||
import { getScopeAndName } from '../../common/PackageUtil.js';
|
||||
import { SqlRange } from '../entity/SqlRange.js';
|
||||
import { BugVersionService } from './BugVersionService.js';
|
||||
import type { PackageJSONType } from '../../repository/PackageRepository.js';
|
||||
import { DistRepository } from '../../repository/DistRepository.js';
|
||||
import { BugVersionAdvice } from '../entity/BugVersion.js';
|
||||
|
||||
@SingletonProto({
|
||||
accessLevel: AccessLevel.PUBLIC,
|
||||
|
||||
@@ -3,29 +3,30 @@ import { ForbiddenError } from 'egg-errors';
|
||||
import { SingletonProto, AccessLevel, Inject } from '@eggjs/tegg';
|
||||
import { BackgroundTaskHelper } from '@eggjs/tegg-background-task';
|
||||
import { valid as semverValid } from 'semver';
|
||||
import { AbstractService } from '../../common/AbstractService';
|
||||
import { TaskService } from './TaskService';
|
||||
import { CacheService } from './CacheService';
|
||||
import { RegistryManagerService } from './RegistryManagerService';
|
||||
import { NPMRegistry } from '../../common/adapter/NPMRegistry';
|
||||
import { NFSAdapter } from '../../common/adapter/NFSAdapter';
|
||||
import { ProxyCache } from '../entity/ProxyCache';
|
||||
import { Task, UpdateProxyCacheTaskOptions, CreateUpdateProxyCacheTask } from '../entity/Task';
|
||||
import { ProxyCacheRepository } from '../../repository/ProxyCacheRepository';
|
||||
import { TaskType, TaskState } from '../../common/enum/Task';
|
||||
import { calculateIntegrity } from '../../common/PackageUtil';
|
||||
import { ABBREVIATED_META_TYPE, PROXY_CACHE_DIR_NAME } from '../../common/constants';
|
||||
import { DIST_NAMES } from '../entity/Package';
|
||||
import type { AbbreviatedPackageManifestType, AbbreviatedPackageJSONType, PackageManifestType, PackageJSONType } from '../../repository/PackageRepository';
|
||||
import { AbstractService } from '../../common/AbstractService.js';
|
||||
import { TaskService } from './TaskService.js';
|
||||
import { CacheService } from './CacheService.js';
|
||||
import { RegistryManagerService } from './RegistryManagerService.js';
|
||||
import { NPMRegistry } from '../../common/adapter/NPMRegistry.js';
|
||||
import { NFSAdapter } from '../../common/adapter/NFSAdapter.js';
|
||||
import { ProxyCache } from '../entity/ProxyCache.js';
|
||||
import { Task, UpdateProxyCacheTaskOptions, CreateUpdateProxyCacheTask } from '../entity/Task.js';
|
||||
import { ProxyCacheRepository } from '../../repository/ProxyCacheRepository.js';
|
||||
import { TaskType, TaskState } from '../../common/enum/Task.js';
|
||||
import { calculateIntegrity } from '../../common/PackageUtil.js';
|
||||
import { ABBREVIATED_META_TYPE, PROXY_CACHE_DIR_NAME } from '../../common/constants.js';
|
||||
import { DIST_NAMES, isPkgManifest } from '../entity/Package.js';
|
||||
import type {
|
||||
AbbreviatedPackageManifestType,
|
||||
AbbreviatedPackageJSONType,
|
||||
PackageManifestType,
|
||||
PackageJSONType,
|
||||
} from '../../repository/PackageRepository.js';
|
||||
|
||||
function isoNow() {
|
||||
return new Date().toISOString();
|
||||
}
|
||||
|
||||
export function isPkgManifest(fileType: DIST_NAMES) {
|
||||
return fileType === DIST_NAMES.FULL_MANIFESTS || fileType === DIST_NAMES.ABBREVIATED_MANIFESTS;
|
||||
}
|
||||
|
||||
type GetSourceManifestAndCacheReturnType<T> = T extends DIST_NAMES.ABBREVIATED | DIST_NAMES.MANIFEST ? AbbreviatedPackageJSONType | PackageJSONType :
|
||||
T extends DIST_NAMES.FULL_MANIFESTS | DIST_NAMES.ABBREVIATED_MANIFESTS ? AbbreviatedPackageManifestType|PackageManifestType : never;
|
||||
|
||||
@@ -228,11 +229,11 @@ export class ProxyCacheService extends AbstractService {
|
||||
}
|
||||
|
||||
// replace tarball url
|
||||
const manifest = this.replaceTarballUrl(responseResult.data, fileType);
|
||||
const manifest = this.replaceTarballUrl(responseResult!.data, fileType);
|
||||
return manifest;
|
||||
}
|
||||
|
||||
private async storeRewrittenManifest(manifest, fullname: string, fileType: DIST_NAMES) {
|
||||
private async storeRewrittenManifest(manifest: any, fullname: string, fileType: DIST_NAMES) {
|
||||
let storeKey: string;
|
||||
if (isPkgManifest(fileType)) {
|
||||
storeKey = `/${PROXY_CACHE_DIR_NAME}/${fullname}/${fileType}`;
|
||||
|
||||
@@ -4,15 +4,15 @@ import {
|
||||
Inject,
|
||||
} from '@eggjs/tegg';
|
||||
import { E400, NotFoundError } from 'egg-errors';
|
||||
import { RegistryRepository } from '../../repository/RegistryRepository';
|
||||
import { AbstractService } from '../../common/AbstractService';
|
||||
import { Registry } from '../entity/Registry';
|
||||
import { PageOptions, PageResult } from '../util/EntityUtil';
|
||||
import { ScopeManagerService } from './ScopeManagerService';
|
||||
import { TaskService } from './TaskService';
|
||||
import { Task } from '../entity/Task';
|
||||
import { ChangesStreamMode, PresetRegistryName } from '../../common/constants';
|
||||
import { RegistryType } from '../../common/enum/Registry';
|
||||
import { RegistryRepository } from '../../repository/RegistryRepository.js';
|
||||
import { AbstractService } from '../../common/AbstractService.js';
|
||||
import { Registry } from '../entity/Registry.js';
|
||||
import { PageOptions, PageResult } from '../util/EntityUtil.js';
|
||||
import { ScopeManagerService } from './ScopeManagerService.js';
|
||||
import { TaskService } from './TaskService.js';
|
||||
import { Task } from '../entity/Task.js';
|
||||
import { ChangesStreamMode, PresetRegistryName } from '../../common/constants.js';
|
||||
import { RegistryType } from '../../common/enum/Registry.js';
|
||||
|
||||
export interface CreateRegistryCmd extends Pick<Registry, 'changeStream' | 'host' | 'userPrefix' | 'type' | 'name' | 'authToken' > {
|
||||
operatorId?: string;
|
||||
|
||||
@@ -3,10 +3,10 @@ import {
|
||||
SingletonProto,
|
||||
Inject,
|
||||
} from '@eggjs/tegg';
|
||||
import { ScopeRepository } from '../../repository/ScopeRepository';
|
||||
import { AbstractService } from '../../common/AbstractService';
|
||||
import { Scope } from '../entity/Scope';
|
||||
import { PageOptions, PageResult } from '../util/EntityUtil';
|
||||
import { ScopeRepository } from '../../repository/ScopeRepository.js';
|
||||
import { AbstractService } from '../../common/AbstractService.js';
|
||||
import { Scope } from '../entity/Scope.js';
|
||||
import { PageOptions, PageResult } from '../util/EntityUtil.js';
|
||||
|
||||
export interface CreateScopeCmd extends Pick<Scope, 'name' | 'registryId'> {
|
||||
operatorId?: string;
|
||||
|
||||
@@ -3,12 +3,12 @@ import {
|
||||
SingletonProto,
|
||||
Inject,
|
||||
} from '@eggjs/tegg';
|
||||
import { NFSAdapter } from '../../common/adapter/NFSAdapter';
|
||||
import { TaskState, TaskType } from '../../common/enum/Task';
|
||||
import { AbstractService } from '../../common/AbstractService';
|
||||
import { TaskRepository } from '../../repository/TaskRepository';
|
||||
import { Task, CreateSyncPackageTaskData } from '../entity/Task';
|
||||
import { QueueAdapter } from '../../common/typing';
|
||||
import { NFSAdapter } from '../../common/adapter/NFSAdapter.js';
|
||||
import { TaskState, TaskType } from '../../common/enum/Task.js';
|
||||
import { AbstractService } from '../../common/AbstractService.js';
|
||||
import { TaskRepository } from '../../repository/TaskRepository.js';
|
||||
import { Task, CreateSyncPackageTaskData } from '../entity/Task.js';
|
||||
import { QueueAdapter } from '../../common/typing.js';
|
||||
|
||||
@SingletonProto({
|
||||
accessLevel: AccessLevel.PUBLIC,
|
||||
@@ -144,6 +144,7 @@ export class TaskService extends AbstractService {
|
||||
this.logger.error(
|
||||
'[TaskService.retryExecuteTimeoutTasks:error] processing task, taskType: %s, targetName: %s, taskId: %s, attempts %s will retry again',
|
||||
task.type, task.targetName, task.taskId, task.attempts);
|
||||
this.logger.error(e);
|
||||
}
|
||||
}
|
||||
// try waiting timeout tasks in 30 mins
|
||||
@@ -158,6 +159,7 @@ export class TaskService extends AbstractService {
|
||||
this.logger.error(
|
||||
'[TaskService.retryExecuteTimeoutTasks:error] waiting task, taskType: %s, targetName: %s, taskId: %s, attempts %s will retry again',
|
||||
task.type, task.targetName, task.taskId, task.attempts);
|
||||
this.logger.error(e);
|
||||
}
|
||||
}
|
||||
return {
|
||||
|
||||
@@ -4,17 +4,17 @@ import {
|
||||
SingletonProto,
|
||||
Inject,
|
||||
} from '@eggjs/tegg';
|
||||
import { isEmpty } from 'lodash';
|
||||
import { AbstractService } from '../../common/AbstractService';
|
||||
import { Token, isGranularToken } from '../entity/Token';
|
||||
import { TokenPackage as TokenPackageModel } from '../../../app/repository/model/TokenPackage';
|
||||
import { Package as PackageModel } from '../../../app/repository/model/Package';
|
||||
import { ModelConvertor } from '../../../app/repository/util/ModelConvertor';
|
||||
import { Package as PackageEntity } from '../entity/Package';
|
||||
import { isEmpty } from 'lodash-es';
|
||||
import { ForbiddenError, UnauthorizedError } from 'egg-errors';
|
||||
import { getScopeAndName } from '../../../app/common/PackageUtil';
|
||||
import { sha512 } from '../../../app/common/UserUtil';
|
||||
import { UserRepository } from '../../../app/repository/UserRepository';
|
||||
import { AbstractService } from '../../common/AbstractService.js';
|
||||
import { Token, isGranularToken } from '../entity/Token.js';
|
||||
import { TokenPackage as TokenPackageModel } from '../../../app/repository/model/TokenPackage.js';
|
||||
import { Package as PackageModel } from '../../../app/repository/model/Package.js';
|
||||
import { ModelConvertor } from '../../../app/repository/util/ModelConvertor.js';
|
||||
import { Package as PackageEntity } from '../entity/Package.js';
|
||||
import { getScopeAndName } from '../../../app/common/PackageUtil.js';
|
||||
import { sha512 } from '../../../app/common/UserUtil.js';
|
||||
import { UserRepository } from '../../../app/repository/UserRepository.js';
|
||||
|
||||
@SingletonProto({
|
||||
accessLevel: AccessLevel.PUBLIC,
|
||||
@@ -73,7 +73,7 @@ export class TokenService extends AbstractService {
|
||||
|
||||
async getUserAndToken(authorization: string) {
|
||||
if (!authorization) return null;
|
||||
const matchs = /^Bearer ([\w\.]+?)$/.exec(authorization);
|
||||
const matchs = /^Bearer ([\w.]+?)$/.exec(authorization);
|
||||
if (!matchs) return null;
|
||||
const tokenValue = matchs[1];
|
||||
const tokenKey = sha512(tokenValue);
|
||||
|
||||
@@ -5,16 +5,16 @@ import {
|
||||
Inject,
|
||||
} from '@eggjs/tegg';
|
||||
import { NotFoundError, ForbiddenError } from 'egg-errors';
|
||||
import { UserRepository } from '../../repository/UserRepository';
|
||||
import { User as UserEntity } from '../entity/User';
|
||||
import { Token as TokenEntity, TokenType } from '../entity/Token';
|
||||
import { WebauthnCredential as WebauthnCredentialEntity } from '../entity/WebauthnCredential';
|
||||
import { LoginResultCode } from '../../common/enum/User';
|
||||
import { integrity, checkIntegrity, randomToken, sha512 } from '../../common/UserUtil';
|
||||
import { AbstractService } from '../../common/AbstractService';
|
||||
import { RegistryManagerService } from './RegistryManagerService';
|
||||
import { getPrefixedName } from '../../common/PackageUtil';
|
||||
import { Registry } from '../entity/Registry';
|
||||
import { UserRepository } from '../../repository/UserRepository.js';
|
||||
import { User as UserEntity } from '../entity/User.js';
|
||||
import { Token as TokenEntity, TokenType } from '../entity/Token.js';
|
||||
import { WebauthnCredential as WebauthnCredentialEntity } from '../entity/WebauthnCredential.js';
|
||||
import { LoginResultCode } from '../../common/enum/User.js';
|
||||
import { integrity, checkIntegrity, randomToken, sha512 } from '../../common/UserUtil.js';
|
||||
import { AbstractService } from '../../common/AbstractService.js';
|
||||
import { RegistryManagerService } from './RegistryManagerService.js';
|
||||
import { getPrefixedName } from '../../common/PackageUtil.js';
|
||||
import { Registry } from '../entity/Registry.js';
|
||||
|
||||
type Optional<T, K extends keyof T> = Omit < T, K > & Partial<T> ;
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import ObjectID from 'bson-objectid';
|
||||
import { E400 } from 'egg-errors';
|
||||
import { EntityData } from '../entity/Entity';
|
||||
|
||||
import { EntityData } from '../entity/Entity.js';
|
||||
|
||||
type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
||||
|
||||
@@ -29,6 +30,7 @@ export class EntityUtil {
|
||||
}
|
||||
|
||||
static createId(): string {
|
||||
// @ts-expect-error ObjectID has no construct signatures
|
||||
return new ObjectID().toHexString();
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,8 @@ import {
|
||||
} from '@eggjs/tegg';
|
||||
import { Redis } from 'ioredis';
|
||||
import { randomUUID } from 'node:crypto';
|
||||
import { AuthClient, AuthUrlResult, userResult } from '../common/typing';
|
||||
|
||||
import { AuthClient, AuthUrlResult, userResult } from '../common/typing.js';
|
||||
|
||||
const ONE_DAY = 3600 * 24;
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { Readable } from 'node:stream';
|
||||
import {
|
||||
AccessLevel,
|
||||
LifecycleInit,
|
||||
@@ -6,8 +7,8 @@ import {
|
||||
} from '@eggjs/tegg';
|
||||
import { EggAppConfig, EggLogger } from 'egg';
|
||||
import FSClient from 'fs-cnpm';
|
||||
import { AppendResult, NFSClient, UploadOptions, UploadResult, DownloadOptions } from '../common/typing';
|
||||
import { Readable } from 'node:stream';
|
||||
|
||||
import { AppendResult, NFSClient, UploadOptions, UploadResult, DownloadOptions } from '../common/typing.js';
|
||||
|
||||
@SingletonProto({
|
||||
name: 'nfsClient',
|
||||
|
||||
@@ -4,7 +4,8 @@ import {
|
||||
SingletonProto,
|
||||
} from '@eggjs/tegg';
|
||||
import { Redis } from 'ioredis';
|
||||
import { QueueAdapter } from '../common/typing';
|
||||
|
||||
import { QueueAdapter } from '../common/typing.js';
|
||||
|
||||
/**
|
||||
* Use sort set to keep queue in order and keep same value only insert once
|
||||
|
||||
@@ -4,9 +4,9 @@ import {
|
||||
SingletonProto,
|
||||
} from '@eggjs/tegg';
|
||||
import { EggAppConfig } from 'egg';
|
||||
|
||||
import { Client as ElasticsearchClient, estypes } from '@elastic/elasticsearch';
|
||||
import { SearchAdapter } from '../common/typing';
|
||||
|
||||
import { SearchAdapter } from '../common/typing.js';
|
||||
|
||||
/**
|
||||
* Use elasticsearch to search the huge npm packages.
|
||||
|
||||
@@ -2,5 +2,6 @@
|
||||
"name": "cnpmcore-infra",
|
||||
"eggModule": {
|
||||
"name": "cnpmcoreInfra"
|
||||
}
|
||||
},
|
||||
"type": "module"
|
||||
}
|
||||
|
||||
@@ -6,13 +6,14 @@ import {
|
||||
} from '@eggjs/tegg';
|
||||
import { EggAppConfig, EggLogger } from 'egg';
|
||||
import { UnauthorizedError, ForbiddenError } from 'egg-errors';
|
||||
import { PackageRepository } from '../repository/PackageRepository';
|
||||
import { Package as PackageEntity } from '../core/entity/Package';
|
||||
import { User as UserEntity } from '../core/entity/User';
|
||||
import { Token as TokenEntity } from '../core/entity/Token';
|
||||
import { getScopeAndName } from '../common/PackageUtil';
|
||||
import { RegistryManagerService } from '../core/service/RegistryManagerService';
|
||||
import { TokenService } from '../core/service/TokenService';
|
||||
|
||||
import { PackageRepository } from '../repository/PackageRepository.js';
|
||||
import { Package as PackageEntity } from '../core/entity/Package.js';
|
||||
import { User as UserEntity } from '../core/entity/User.js';
|
||||
import { Token as TokenEntity } from '../core/entity/Token.js';
|
||||
import { getScopeAndName } from '../common/PackageUtil.js';
|
||||
import { RegistryManagerService } from '../core/service/RegistryManagerService.js';
|
||||
import { TokenService } from '../core/service/TokenService.js';
|
||||
|
||||
// https://docs.npmjs.com/creating-and-viewing-access-tokens#creating-tokens-on-the-website
|
||||
export type TokenRole = 'read' | 'publish' | 'setting';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { SyncDeleteMode, SyncMode, ChangesStreamMode } from '../common/constants';
|
||||
import { DATABASE_TYPE } from '../../config/database';
|
||||
import { SyncDeleteMode, SyncMode, ChangesStreamMode } from '../common/constants.js';
|
||||
import { DATABASE_TYPE } from '../../config/database.js';
|
||||
|
||||
export { cnpmcoreConfig } from '../../config/config.default';
|
||||
export { cnpmcoreConfig } from '../../config/config.default.js';
|
||||
|
||||
export type CnpmcoreConfig = {
|
||||
name: string,
|
||||
|
||||
@@ -10,18 +10,19 @@ import {
|
||||
EggLogger,
|
||||
EggAppConfig,
|
||||
} from 'egg';
|
||||
import { MiddlewareController } from '../middleware';
|
||||
import { UserRoleManager } from '../UserRoleManager';
|
||||
import { PackageRepository } from '../../repository/PackageRepository';
|
||||
import { UserRepository } from '../../repository/UserRepository';
|
||||
import { getFullname, getScopeAndName } from '../../common/PackageUtil';
|
||||
import { Package as PackageEntity } from '../../core/entity/Package';
|
||||
import { PackageVersion as PackageVersionEntity } from '../../core/entity/PackageVersion';
|
||||
import { UserService } from '../../core/service/UserService';
|
||||
|
||||
import { MiddlewareController } from '../middleware/index.js';
|
||||
import { UserRoleManager } from '../UserRoleManager.js';
|
||||
import { PackageRepository } from '../../repository/PackageRepository.js';
|
||||
import { UserRepository } from '../../repository/UserRepository.js';
|
||||
import { getFullname, getScopeAndName } from '../../common/PackageUtil.js';
|
||||
import { Package as PackageEntity } from '../../core/entity/Package.js';
|
||||
import { PackageVersion as PackageVersionEntity } from '../../core/entity/PackageVersion.js';
|
||||
import { UserService } from '../../core/service/UserService.js';
|
||||
import {
|
||||
VersionRule,
|
||||
} from '../typebox';
|
||||
import { SyncMode } from '../../common/constants';
|
||||
} from '../typebox.js';
|
||||
import { SyncMode } from '../../common/constants.js';
|
||||
|
||||
class PackageNotFoundError extends NotFoundError {
|
||||
redirectToSourceRegistry?: string;
|
||||
|
||||
@@ -4,11 +4,12 @@ import {
|
||||
HTTPMethodEnum,
|
||||
HTTPParam,
|
||||
} from '@eggjs/tegg';
|
||||
import { AbstractController } from './AbstractController';
|
||||
import { FULLNAME_REG_STRING, getFullname, getScopeAndName } from '../../common/PackageUtil';
|
||||
import { PackageAccessLevel } from '../../common/constants';
|
||||
import { ForbiddenError, NotFoundError } from 'egg-errors';
|
||||
|
||||
import { AbstractController } from './AbstractController.js';
|
||||
import { FULLNAME_REG_STRING, getFullname, getScopeAndName } from '../../common/PackageUtil.js';
|
||||
import { PackageAccessLevel } from '../../common/constants.js';
|
||||
|
||||
@HTTPController()
|
||||
export class AccessController extends AbstractController {
|
||||
@HTTPMethod({
|
||||
|
||||
@@ -9,11 +9,12 @@ import {
|
||||
} from '@eggjs/tegg';
|
||||
import path from 'node:path';
|
||||
import { NotFoundError } from 'egg-errors';
|
||||
import { AbstractController } from './AbstractController';
|
||||
import { BinarySyncerService } from '../../core/service/BinarySyncerService';
|
||||
import { Binary } from '../../core/entity/Binary';
|
||||
import binaries, { BinaryName } from '../../../config/binaries';
|
||||
import { BinaryNameRule, BinarySubpathRule } from '../typebox';
|
||||
|
||||
import { AbstractController } from './AbstractController.js';
|
||||
import { BinarySyncerService } from '../../core/service/BinarySyncerService.js';
|
||||
import { Binary } from '../../core/entity/Binary.js';
|
||||
import binaries, { BinaryName } from '../../../config/binaries.js';
|
||||
import { BinaryNameRule, BinarySubpathRule } from '../typebox.js';
|
||||
|
||||
@HTTPController()
|
||||
export class BinarySyncController extends AbstractController {
|
||||
@@ -48,7 +49,7 @@ export class BinarySyncController extends AbstractController {
|
||||
}
|
||||
|
||||
@HTTPMethod({
|
||||
path: '/-/binary/:binaryName(@[^/]{1,220}\/[^/]{1,220}|[^@/]{1,220})/:subpath(.*)',
|
||||
path: '/-/binary/:binaryName(@[^/]{1,220}/[^/]{1,220}|[^@/]{1,220})/:subpath(.*)',
|
||||
method: HTTPMethodEnum.GET,
|
||||
})
|
||||
async showBinary(@Context() ctx: EggContext, @HTTPParam() binaryName: BinaryName, @HTTPParam() subpath: string) {
|
||||
@@ -106,14 +107,14 @@ export class BinarySyncController extends AbstractController {
|
||||
}
|
||||
|
||||
@HTTPMethod({
|
||||
path: '/-/binary/:binaryName(@[^/]{1,220}\/[^/]{1,220}|[^@/]{1,220})',
|
||||
path: '/-/binary/:binaryName(@[^/]{1,220}/[^/]{1,220}|[^@/]{1,220})',
|
||||
method: HTTPMethodEnum.GET,
|
||||
})
|
||||
async showBinaryIndex(@Context() ctx: EggContext, @HTTPParam() binaryName: BinaryName) {
|
||||
// check binaryName valid
|
||||
try {
|
||||
ctx.tValidate(BinaryNameRule, binaryName);
|
||||
} catch (e) {
|
||||
} catch {
|
||||
throw new NotFoundError(`Binary "${binaryName}" not found`);
|
||||
}
|
||||
return await this.showBinary(ctx, binaryName, '/');
|
||||
|
||||
@@ -7,9 +7,10 @@ import {
|
||||
Context,
|
||||
EggContext,
|
||||
} from '@eggjs/tegg';
|
||||
import { Type } from 'egg-typebox-validate-fengmk2/typebox';
|
||||
import { AbstractController } from './AbstractController';
|
||||
import { ChangeRepository } from '../../repository/ChangeRepository';
|
||||
import { Type } from 'egg-typebox-validate/typebox';
|
||||
|
||||
import { AbstractController } from './AbstractController.js';
|
||||
import { ChangeRepository } from '../../repository/ChangeRepository.js';
|
||||
|
||||
const ChangeRule = Type.Object({
|
||||
since: Type.Integer({ minimum: 0 }),
|
||||
|
||||
@@ -6,10 +6,11 @@ import {
|
||||
Inject,
|
||||
} from '@eggjs/tegg';
|
||||
import { UnprocessableEntityError, NotFoundError } from 'egg-errors';
|
||||
import { AbstractController } from './AbstractController';
|
||||
import { FULLNAME_REG_STRING, getScopeAndName } from '../../common/PackageUtil';
|
||||
import dayjs from '../../common/dayjs';
|
||||
import { PackageVersionDownloadRepository } from '../../repository/PackageVersionDownloadRepository';
|
||||
|
||||
import { AbstractController } from './AbstractController.js';
|
||||
import { FULLNAME_REG_STRING, getScopeAndName } from '../../common/PackageUtil.js';
|
||||
import dayjs from '../../common/dayjs.js';
|
||||
import { PackageVersionDownloadRepository } from '../../repository/PackageVersionDownloadRepository.js';
|
||||
|
||||
const DATE_FORMAT = 'YYYY-MM-DD';
|
||||
|
||||
@@ -90,7 +91,7 @@ export class DownloadController extends AbstractController {
|
||||
}
|
||||
|
||||
private checkAndGetRange(range: string) {
|
||||
const matchs = /^(\d{4}\-\d{2}\-\d{2}):(\d{4}\-\d{2}\-\d{2})$/.exec(range);
|
||||
const matchs = /^(\d{4}-\d{2}-\d{2}):(\d{4}-\d{2}-\d{2})$/.exec(range);
|
||||
if (!matchs) {
|
||||
throw new UnprocessableEntityError(`range(${range}) format invalid, must be "${DATE_FORMAT}:${DATE_FORMAT}" style`);
|
||||
}
|
||||
|
||||
@@ -7,11 +7,13 @@ import {
|
||||
EggContext,
|
||||
Inject,
|
||||
} from '@eggjs/tegg';
|
||||
import { version as EggVersion } from 'egg/package.json';
|
||||
import { AbstractController } from './AbstractController';
|
||||
import { CacheService, DownloadInfo, UpstreamRegistryInfo } from '../../core/service/CacheService';
|
||||
import { HomeService } from '../../core/service/HomeService';
|
||||
import pkg from 'egg/package.json' with { type: 'json' };
|
||||
|
||||
import { AbstractController } from './AbstractController.js';
|
||||
import { CacheService, DownloadInfo, UpstreamRegistryInfo } from '../../core/service/CacheService.js';
|
||||
import { HomeService } from '../../core/service/HomeService.js';
|
||||
|
||||
const EggVersion = pkg.version;
|
||||
const startTime = new Date();
|
||||
|
||||
// registry 站点信息数据 SiteTotalData
|
||||
|
||||
@@ -8,13 +8,14 @@ import {
|
||||
HTTPParam,
|
||||
Inject,
|
||||
} from '@eggjs/tegg';
|
||||
import { HookManageService } from '../../core/service/HookManageService';
|
||||
import { TaskService } from '../../core/service/TaskService';
|
||||
import { UserRoleManager } from '../UserRoleManager';
|
||||
import { HookType } from '../../common/enum/Hook';
|
||||
import { TriggerHookTask } from '../../core/entity/Task';
|
||||
import { HookConvertor } from './convertor/HookConvertor';
|
||||
import { CreateHookRequestRule, UpdateHookRequestRule } from '../typebox';
|
||||
|
||||
import { HookManageService } from '../../core/service/HookManageService.js';
|
||||
import { TaskService } from '../../core/service/TaskService.js';
|
||||
import { UserRoleManager } from '../UserRoleManager.js';
|
||||
import { HookType } from '../../common/enum/Hook.js';
|
||||
import { TriggerHookTask } from '../../core/entity/Task.js';
|
||||
import { HookConvertor } from './convertor/HookConvertor.js';
|
||||
import { CreateHookRequestRule, UpdateHookRequestRule } from '../typebox.js';
|
||||
|
||||
export interface CreateHookRequest {
|
||||
type: string;
|
||||
|
||||
@@ -10,12 +10,13 @@ import {
|
||||
Middleware,
|
||||
} from '@eggjs/tegg';
|
||||
import { ForbiddenError } from 'egg-errors';
|
||||
import { AbstractController } from './AbstractController';
|
||||
import { FULLNAME_REG_STRING } from '../../common/PackageUtil';
|
||||
import { PackageManagerService } from '../../core/service/PackageManagerService';
|
||||
import { PackageVersionBlockRepository } from '../../repository/PackageVersionBlockRepository';
|
||||
import { BlockPackageRule, BlockPackageType } from '../typebox';
|
||||
import { AdminAccess } from '../middleware/AdminAccess';
|
||||
|
||||
import { AbstractController } from './AbstractController.js';
|
||||
import { FULLNAME_REG_STRING } from '../../common/PackageUtil.js';
|
||||
import { PackageManagerService } from '../../core/service/PackageManagerService.js';
|
||||
import { PackageVersionBlockRepository } from '../../repository/PackageVersionBlockRepository.js';
|
||||
import { BlockPackageRule, BlockPackageType } from '../typebox.js';
|
||||
import { AdminAccess } from '../middleware/AdminAccess.js';
|
||||
|
||||
@HTTPController()
|
||||
export class PackageBlockController extends AbstractController {
|
||||
@@ -35,7 +36,7 @@ export class PackageBlockController extends AbstractController {
|
||||
ctx.tValidate(BlockPackageRule, params);
|
||||
const packageEntity = await this.getPackageEntityByFullname(params.fullname);
|
||||
if (packageEntity.isPrivate) {
|
||||
throw new ForbiddenError(`Can\'t block private package "${params.fullname}"`);
|
||||
throw new ForbiddenError(`Can't block private package "${params.fullname}"`);
|
||||
}
|
||||
|
||||
const authorized = await this.userRoleManager.getAuthorizedUserAndToken(ctx);
|
||||
@@ -60,7 +61,7 @@ export class PackageBlockController extends AbstractController {
|
||||
async unblockPackage(@Context() ctx: EggContext, @HTTPParam() fullname: string) {
|
||||
const packageEntity = await this.getPackageEntityByFullname(fullname);
|
||||
if (packageEntity.isPrivate) {
|
||||
throw new ForbiddenError(`Can\'t unblock private package "${fullname}"`);
|
||||
throw new ForbiddenError(`Can't unblock private package "${fullname}"`);
|
||||
}
|
||||
|
||||
await this.packageManagerService.unblockPackage(packageEntity);
|
||||
|
||||
@@ -11,14 +11,15 @@ import {
|
||||
BackgroundTaskHelper,
|
||||
} from '@eggjs/tegg';
|
||||
import { ForbiddenError, NotFoundError } from 'egg-errors';
|
||||
import { AbstractController } from './AbstractController';
|
||||
import { FULLNAME_REG_STRING, getScopeAndName } from '../../common/PackageUtil';
|
||||
import { Task } from '../../core/entity/Task';
|
||||
import { PackageSyncerService } from '../../core/service/PackageSyncerService';
|
||||
import { RegistryManagerService } from '../../core/service/RegistryManagerService';
|
||||
import { TaskState } from '../../common/enum/Task';
|
||||
import { SyncPackageTaskRule, SyncPackageTaskType } from '../typebox';
|
||||
import { SyncMode } from '../../common/constants';
|
||||
|
||||
import { AbstractController } from './AbstractController.js';
|
||||
import { FULLNAME_REG_STRING, getScopeAndName } from '../../common/PackageUtil.js';
|
||||
import { Task } from '../../core/entity/Task.js';
|
||||
import { PackageSyncerService } from '../../core/service/PackageSyncerService.js';
|
||||
import { RegistryManagerService } from '../../core/service/RegistryManagerService.js';
|
||||
import { TaskState } from '../../common/enum/Task.js';
|
||||
import { SyncPackageTaskRule, SyncPackageTaskType } from '../typebox.js';
|
||||
import { SyncMode } from '../../common/constants.js';
|
||||
|
||||
@HTTPController()
|
||||
export class PackageSyncController extends AbstractController {
|
||||
@@ -81,10 +82,10 @@ export class PackageSyncController extends AbstractController {
|
||||
const registry = await this.registryManagerService.findByRegistryName(data?.registryName);
|
||||
|
||||
if (!registry && data.registryName) {
|
||||
throw new ForbiddenError(`Can\'t find target registry "${data.registryName}"`);
|
||||
throw new ForbiddenError(`Can't find target registry "${data.registryName}"`);
|
||||
}
|
||||
if (packageEntity?.isPrivate && !registry) {
|
||||
throw new ForbiddenError(`Can\'t sync private package "${params.fullname}"`);
|
||||
throw new ForbiddenError(`Can't sync private package "${params.fullname}"`);
|
||||
}
|
||||
if (params.syncDownloadData && !this.packageSyncerService.allowSyncDownloadData) {
|
||||
throw new ForbiddenError('Not allow to sync package download data');
|
||||
|
||||
@@ -9,10 +9,11 @@ import {
|
||||
Inject,
|
||||
} from '@eggjs/tegg';
|
||||
import { ForbiddenError } from 'egg-errors';
|
||||
import { AbstractController } from './AbstractController';
|
||||
import { FULLNAME_REG_STRING } from '../../common/PackageUtil';
|
||||
import { PackageManagerService } from '../../core/service/PackageManagerService';
|
||||
import { TagRule, TagWithVersionRule } from '../typebox';
|
||||
|
||||
import { AbstractController } from './AbstractController.js';
|
||||
import { FULLNAME_REG_STRING } from '../../common/PackageUtil.js';
|
||||
import { PackageManagerService } from '../../core/service/PackageManagerService.js';
|
||||
import { TagRule, TagWithVersionRule } from '../typebox.js';
|
||||
|
||||
@HTTPController()
|
||||
export class PackageTagController extends AbstractController {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { join } from 'node:path';
|
||||
import {
|
||||
HTTPController,
|
||||
HTTPMethod,
|
||||
@@ -10,16 +11,16 @@ import {
|
||||
Middleware,
|
||||
} from '@eggjs/tegg';
|
||||
import { NotFoundError } from 'egg-errors';
|
||||
import { join } from 'node:path';
|
||||
import { AbstractController } from './AbstractController';
|
||||
import { AdminAccess } from '../middleware/AdminAccess';
|
||||
import { getScopeAndName, FULLNAME_REG_STRING } from '../../common/PackageUtil';
|
||||
import { PackageVersionFileService } from '../../core/service/PackageVersionFileService';
|
||||
import { PackageManagerService } from '../../core/service/PackageManagerService';
|
||||
import { PackageVersionFile } from '../../core/entity/PackageVersionFile';
|
||||
import { PackageVersion } from '../../core/entity/PackageVersion';
|
||||
import { DistRepository } from '../../repository/DistRepository';
|
||||
import { Spec } from '../typebox';
|
||||
|
||||
import { AbstractController } from './AbstractController.js';
|
||||
import { AdminAccess } from '../middleware/AdminAccess.js';
|
||||
import { getScopeAndName, FULLNAME_REG_STRING } from '../../common/PackageUtil.js';
|
||||
import { PackageVersionFileService } from '../../core/service/PackageVersionFileService.js';
|
||||
import { PackageManagerService } from '../../core/service/PackageManagerService.js';
|
||||
import { PackageVersionFile } from '../../core/entity/PackageVersionFile.js';
|
||||
import { PackageVersion } from '../../core/entity/PackageVersion.js';
|
||||
import { DistRepository } from '../../repository/DistRepository.js';
|
||||
import { Spec } from '../typebox.js';
|
||||
|
||||
type FileItem = {
|
||||
path: string,
|
||||
|
||||
@@ -9,17 +9,18 @@ import {
|
||||
EggContext,
|
||||
} from '@eggjs/tegg';
|
||||
import { ForbiddenError, NotFoundError, UnauthorizedError, NotImplementedError } from 'egg-errors';
|
||||
import { AbstractController } from './AbstractController';
|
||||
import { ProxyCacheRepository } from '../../repository/ProxyCacheRepository';
|
||||
import { Static } from 'egg-typebox-validate-fengmk2/typebox';
|
||||
import { QueryPageOptions } from '../typebox';
|
||||
import { FULLNAME_REG_STRING } from '../../common/PackageUtil';
|
||||
|
||||
import { AbstractController } from './AbstractController.js';
|
||||
import { ProxyCacheRepository } from '../../repository/ProxyCacheRepository.js';
|
||||
import { Static } from 'egg-typebox-validate/typebox';
|
||||
import { QueryPageOptions } from '../typebox.js';
|
||||
import { FULLNAME_REG_STRING } from '../../common/PackageUtil.js';
|
||||
import {
|
||||
ProxyCacheService,
|
||||
isPkgManifest,
|
||||
} from '../../core/service/ProxyCacheService';
|
||||
import { SyncMode } from '../../common/constants';
|
||||
import { CacheService } from '../../core/service/CacheService';
|
||||
} from '../../core/service/ProxyCacheService.js';
|
||||
import { SyncMode } from '../../common/constants.js';
|
||||
import { CacheService } from '../../core/service/CacheService.js';
|
||||
import { isPkgManifest } from '../../core/entity/Package.js';
|
||||
|
||||
@HTTPController()
|
||||
export class ProxyCacheController extends AbstractController {
|
||||
|
||||
@@ -11,12 +11,13 @@ import {
|
||||
Middleware,
|
||||
} from '@eggjs/tegg';
|
||||
import { NotFoundError } from 'egg-errors';
|
||||
import { AbstractController } from './AbstractController';
|
||||
import { Static } from 'egg-typebox-validate-fengmk2/typebox';
|
||||
import { RegistryManagerService, UpdateRegistryCmd } from '../../core/service/RegistryManagerService';
|
||||
import { AdminAccess } from '../middleware/AdminAccess';
|
||||
import { ScopeManagerService } from '../../core/service/ScopeManagerService';
|
||||
import { RegistryCreateOptions, QueryPageOptions, RegistryCreateSyncOptions, RegistryUpdateOptions } from '../typebox';
|
||||
import { Static } from 'egg-typebox-validate/typebox';
|
||||
|
||||
import { AbstractController } from './AbstractController.js';
|
||||
import { RegistryManagerService, UpdateRegistryCmd } from '../../core/service/RegistryManagerService.js';
|
||||
import { AdminAccess } from '../middleware/AdminAccess.js';
|
||||
import { ScopeManagerService } from '../../core/service/ScopeManagerService.js';
|
||||
import { RegistryCreateOptions, QueryPageOptions, RegistryCreateSyncOptions, RegistryUpdateOptions } from '../typebox.js';
|
||||
|
||||
@HTTPController()
|
||||
export class RegistryController extends AbstractController {
|
||||
|
||||
@@ -10,12 +10,13 @@ import {
|
||||
Middleware,
|
||||
} from '@eggjs/tegg';
|
||||
import { E400 } from 'egg-errors';
|
||||
import { AbstractController } from './AbstractController';
|
||||
import { Static } from 'egg-typebox-validate-fengmk2/typebox';
|
||||
import { AdminAccess } from '../middleware/AdminAccess';
|
||||
import { ScopeManagerService } from '../../core/service/ScopeManagerService';
|
||||
import { RegistryManagerService } from '../../core/service/RegistryManagerService';
|
||||
import { ScopeCreateOptions } from '../typebox';
|
||||
import { Static } from 'egg-typebox-validate/typebox';
|
||||
|
||||
import { AbstractController } from './AbstractController.js';
|
||||
import { AdminAccess } from '../middleware/AdminAccess.js';
|
||||
import { ScopeManagerService } from '../../core/service/ScopeManagerService.js';
|
||||
import { RegistryManagerService } from '../../core/service/RegistryManagerService.js';
|
||||
import { ScopeCreateOptions } from '../typebox.js';
|
||||
|
||||
|
||||
@HTTPController()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { ForbiddenError, UnauthorizedError } from 'egg-errors';
|
||||
import { AuthAdapter } from '../../infra/AuthAdapter';
|
||||
import {
|
||||
HTTPController,
|
||||
HTTPMethod,
|
||||
@@ -10,9 +9,11 @@ import {
|
||||
EggContext,
|
||||
Inject,
|
||||
} from '@eggjs/tegg';
|
||||
import { Static, Type } from 'egg-typebox-validate-fengmk2/typebox';
|
||||
import { AbstractController } from './AbstractController';
|
||||
import { TokenType, isGranularToken } from '../../core/entity/Token';
|
||||
import { Static, Type } from 'egg-typebox-validate/typebox';
|
||||
|
||||
import { AuthAdapter } from '../../infra/AuthAdapter.js';
|
||||
import { AbstractController } from './AbstractController.js';
|
||||
import { TokenType, isGranularToken } from '../../core/entity/Token.js';
|
||||
|
||||
// Creating and viewing access tokens
|
||||
// https://docs.npmjs.com/creating-and-viewing-access-tokens#viewing-access-tokens
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user