1
0
mirror of https://github.com/SomboChea/ui synced 2026-01-12 06:05:43 +07:00

feat: migrating flow to typescript (#47)

This PR convert the code base to Typescript, the changes are the following:

- migrate code base to Typescript (3.4.x)
- enable `eslint` and `@typescript-eslint/eslint-plugin` (warnings still need to be addressed in future pull request
- update relevant dependencies for this PR (linting, etc)
- enable `bundlezise` (it was disabled for some reason)

* refactor: refactoring to typescript

* refactor: migrating to typescript

* refactor: applied feedbacks

* fix: fixed conflicts

* refactored: changed registry

* refactor: updated registry & removed unnecessary lib

* fix: fixed registry ur

* fix: fixed page load

* refactor: refactored footer wip

* refactor: converting to ts..wip

* refactor: converting to ts. wip

* refactor: converting to ts. wip

* refactor: converting to ts

* refactor: converting to ts

* fix: fixed load errors

* refactor: converted files to ts

* refactor: removed flow from tests

* fix: removed transpiled files

* refactor: added ts-ignore

* fix: fixed errors

* fix: fixed types

* fix: fixing jest import -.-

* fix: fixing lint errors

* fix: fixing lint errors

* fix: fixed lint errors

* refactor: removed unnecessary tsconfig's config

* fix: fixing errors

* fix: fixed warning

* fix: fixed test

* refactor: wip

* refactor: wip

* refactor: wip

* fix: fixing tests: wip

* wip

* wip

* fix: fixed search test

* wip

* fix: fixing lint errors

* fix: re-added stylelint

* refactor: updated stylelint script

* fix: fixed: 'styles.js'  were found.

* fix: fixed Search tests

* chore: enable eslint

eslint needs expecitely to know which file has to lint, by default is JS, in this case we need also ts,tsx files eslint . --ext .js,.ts

* chore: vcode eslint settings

* chore: restore eslint previous conf

* chore: clean jest config

* chore: fix eslint warnings

* chore: eslint errors cleared

chore: clean warnings

chore: remove github actions test phases

chore: remove dupe rule

* chore: update handler name

* chore: restore logo from img to url css prop

- loading images with css is more performant than using img html tags, switching this might be a breaking change
- restore no-empty-source seems the linting do not accept false
- update snapshots
- remove @material-ui/styles

* chore: update stylelint linting

* chore: update stylelint linting

* chore: fix a mistake on move tabs to a function

* chore: eanble bundlezie

* chore: use default_executor in circleci

* chore: update readme
This commit is contained in:
Priscila Oliveira
2019-06-20 14:37:28 +02:00
committed by Juan Picado @jotadeveloper
parent 7d1764458b
commit 6b5d0b7e2e
358 changed files with 4730 additions and 58431 deletions

10
types/custom.d.ts vendored Normal file
View File

@@ -0,0 +1,10 @@
// https://stackoverflow.com/questions/44717164/unable-to-import-svg-files-in-typescript
declare module '*.svg' {
const content: any;
export default content;
}
declare module '*.png' {
const content: any;
export default content;
}

View File

@@ -1,163 +0,0 @@
// @flow
import type {
IBasicAuth,
IBasicStorage,
IStorageManager,
UpLinkConf,
Callback,
Versions,
Version,
RemoteUser,
Config,
Logger,
JWTSignOptions,
PackageAccess,
StringValue as verdaccio$StringValue,
Package} from '@verdaccio/types';
import type {
IReadTarball,
} from '@verdaccio/streams';
import type {ILocalData} from '@verdaccio/local-storage';
import lunrMutable from 'lunr-mutable-indexes';
import type {NextFunction, $Request, $Response} from 'request';
export type StringValue = verdaccio$StringValue;
export type StartUpConfig = {
storage: string;
plugins?: string;
self_path: string;
}
export type MatchedPackage = PackageAccess | void;
export type JWTPayload = RemoteUser & {
password?: string;
}
export type AESPayload = {
user: string;
password: string;
}
export type AuthTokenHeader = {
scheme: string;
token: string;
}
export type BasicPayload = AESPayload | void;
export type AuthMiddlewarePayload = RemoteUser | BasicPayload;
export type ProxyList = {
[key: string]: IProxy;
}
export type CookieSessionToken = {
expires: Date;
}
export type Utils = {
ErrorCode: any;
getLatestVersion: Callback;
isObject: (value: any) => boolean;
validate_name: (value: any) => boolean;
tag_version: (value: any, version: string, tag: string) => void;
normalizeDistTags: (pkg: Package) => void;
semverSort: (keys: Array<string>) => Array<string>;
}
export type Profile = {
tfa: boolean;
name: string;
email: string;
email_verified: string;
created: string;
updated: string;
cidr_whitelist: any;
fullname: string;
}
export type $RequestExtend = $Request & {remote_user?: any}
export type $ResponseExtend = $Response & {cookies?: any}
export type $NextFunctionVer = NextFunction & mixed;
export type $SidebarPackage = Package & {latest: mixed}
export interface IAuthWebUI {
jwtEncrypt(user: RemoteUser, signOptions: JWTSignOptions): string;
aesEncrypt(buf: Buffer): Buffer;
}
interface IAuthMiddleware {
apiJWTmiddleware(): $NextFunctionVer;
webUIJWTmiddleware(): $NextFunctionVer;
}
export interface IAuth extends IBasicAuth, IAuthMiddleware, IAuthWebUI {
config: verdaccio$Config;
logger: verdaccio$Logger;
secret: string;
plugins: Array<any>;
}
export interface IWebSearch {
index: lunrMutable.index;
storage: IStorageHandler;
query(query: string): any;
add(pkg: Version): void;
remove(name: string): void;
reindex(): void;
configureStorage(storage: IStorageHandler): void;
}
export interface IProxy {
config: UpLinkConf;
failed_requests: number;
userAgent: string;
ca?: string | void;
logger: Logger;
server_id: string;
url: any;
maxage: number;
timeout: number;
max_fails: number;
fail_timeout: number;
upname: string;
fetchTarball(url: string): IReadTarball;
isUplinkValid(url: string): boolean;
getRemoteMetadata(name: string, options: any, callback: Callback): void;
}
export interface IStorage extends IBasicStorage {
config: Config;
localData: ILocalData;
logger: Logger;
}
export type IGetPackageOptions = {
callback: Callback;
name: string;
keepUpLinkData: boolean;
uplinksLook: boolean;
req: any;
}
export type ISyncUplinks = {
uplinksLook?: boolean;
etag?: string;
}
export interface IStorageHandler extends IStorageManager {
localStorage: IStorage;
uplinks: ProxyList;
_syncUplinksMetadata(name: string, packageInfo: Package, options: any, callback: Callback): void;
_updateVersionsHiddenUpLink(versions: Versions, upLink: IProxy): void;
}
/**
* @property { string | number | Styles } [ruleOrSelector]
*/
export type Styles = {
[ruleOrSelector: string]: string | number | Styles,
};

12
types/index.ts Normal file
View File

@@ -0,0 +1,12 @@
// FIXME: this should comes from @verdaccio/types
export interface VerdaccioOptions {
url_prefix: string;
base: string;
}
declare global {
interface Window {
__VERDACCIO_BASENAME_UI_OPTIONS: VerdaccioOptions;
VERDACCIO_API_URL: string;
}
}