mirror of
https://github.com/SomboChea/ui
synced 2026-01-17 08:35:47 +07:00
Compare commits
44 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
376b84f8c9 | ||
|
|
5a9bd6001a | ||
|
|
ac58730e8c | ||
|
|
97e8448098 | ||
|
|
e7d3c461cd | ||
|
|
003f879a87 | ||
|
|
d81b610e2e | ||
|
|
3d7b230c71 | ||
|
|
ce3b22579f | ||
|
|
e46020f9b0 | ||
|
|
502c0903ab | ||
|
|
542212a479 | ||
|
|
1cb9b56940 | ||
|
|
1446c8e5fb | ||
|
|
155987d837 | ||
|
|
a44e76fded | ||
|
|
2dfa7aa4d6 | ||
|
|
cfb0caf2bb | ||
|
|
62b6edc821 | ||
|
|
9b55b75f8a | ||
|
|
ade58caf41 | ||
|
|
2e9703346c | ||
|
|
ccc2cb3fa6 | ||
|
|
3746a0466f | ||
|
|
dcfda4483f | ||
|
|
d44cc7f662 | ||
|
|
4a526c92bb | ||
|
|
2049022477 | ||
|
|
40a25a2507 | ||
|
|
58cb4c7465 | ||
|
|
e1d8eafb7a | ||
|
|
cb876f936e | ||
|
|
94ca0e146d | ||
|
|
8774fd51c7 | ||
|
|
6f8d891c42 | ||
|
|
dd54aaaf94 | ||
|
|
9d7b90fc34 | ||
|
|
157addfd00 | ||
|
|
6ab3aa2885 | ||
|
|
9e0c9db78c | ||
|
|
df4e45cd6c | ||
|
|
df58d463e8 | ||
|
|
313fb33480 | ||
|
|
d468ca7c5f |
@@ -12,7 +12,9 @@
|
|||||||
"jest",
|
"jest",
|
||||||
"prettier",
|
"prettier",
|
||||||
"verdaccio",
|
"verdaccio",
|
||||||
"jsx-a11y"
|
"jsx-a11y",
|
||||||
|
"codeceptjs",
|
||||||
|
"react-hooks"
|
||||||
],
|
],
|
||||||
"settings": {
|
"settings": {
|
||||||
"react": {
|
"react": {
|
||||||
@@ -106,6 +108,8 @@
|
|||||||
2,
|
2,
|
||||||
"always"
|
"always"
|
||||||
],
|
],
|
||||||
|
"react-hooks/rules-of-hooks": "error",
|
||||||
|
"react-hooks/exhaustive-deps": "warn",
|
||||||
"verdaccio/jsx-no-style": ["warn"],
|
"verdaccio/jsx-no-style": ["warn"],
|
||||||
"verdaccio/jsx-spread": ["warn"],
|
"verdaccio/jsx-spread": ["warn"],
|
||||||
"jest/expect-expect": 0,
|
"jest/expect-expect": 0,
|
||||||
@@ -119,6 +123,7 @@
|
|||||||
},
|
},
|
||||||
"env": {
|
"env": {
|
||||||
"browser": true,
|
"browser": true,
|
||||||
"jest/globals": true
|
"jest/globals": true,
|
||||||
|
"codeceptjs/codeceptjs": true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
28
.github/workflows/nodejs.yml
vendored
Normal file
28
.github/workflows/nodejs.yml
vendored
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
name: Node CI
|
||||||
|
|
||||||
|
on: [push]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
ci:
|
||||||
|
name: Test on node ${{ matrix.node_version }} and ${{ matrix.os }}
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
node_version: [8, 10, 12]
|
||||||
|
os: [ubuntu-latest, windows-latest, macOS-latest]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
- name: Use Node.js ${{ matrix.node_version }}
|
||||||
|
uses: actions/setup-node@v1
|
||||||
|
with:
|
||||||
|
version: ${{ matrix.node_version }}
|
||||||
|
|
||||||
|
- name: Use Yarn 1.17.2
|
||||||
|
run: |
|
||||||
|
npm install -g yarn@1.17.2
|
||||||
|
- name: yarn build
|
||||||
|
run: |
|
||||||
|
yarn install
|
||||||
|
yarn lint
|
||||||
|
yarn build
|
||||||
1
.yarnrc
1
.yarnrc
@@ -1,2 +1 @@
|
|||||||
save-prefix ""
|
save-prefix ""
|
||||||
registry "http://registry.npmjs.org/"
|
|
||||||
|
|||||||
12
CHANGELOG.md
12
CHANGELOG.md
@@ -1,7 +1,17 @@
|
|||||||
# Change Log
|
# Changelog
|
||||||
|
|
||||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||||
|
|
||||||
|
### [0.2.3](https://github.com/verdaccio/ui/compare/v0.2.2...v0.2.3) (2019-08-25)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* missing headers on search endpoint with token ([#121](https://github.com/verdaccio/ui/issues/121)) ([ac58730](https://github.com/verdaccio/ui/commit/ac58730))
|
||||||
|
* refactoring version page / fix issue not found page [#100](https://github.com/verdaccio/ui/issues/100) ([#117](https://github.com/verdaccio/ui/issues/117)) ([97e8448](https://github.com/verdaccio/ui/commit/97e8448))
|
||||||
|
* remove ToReplaceByVerdaccio [#108](https://github.com/verdaccio/ui/issues/108) ([#122](https://github.com/verdaccio/ui/issues/122)) ([5a9bd60](https://github.com/verdaccio/ui/commit/5a9bd60))
|
||||||
|
* **api:** correctly handle responses with missing content-type header ([2049022](https://github.com/verdaccio/ui/commit/2049022))
|
||||||
|
|
||||||
<a name="0.2.2"></a>
|
<a name="0.2.2"></a>
|
||||||
## [0.2.2](https://github.com/verdaccio/ui/compare/v0.2.1...v0.2.2) (2019-07-29)
|
## [0.2.2](https://github.com/verdaccio/ui/compare/v0.2.1...v0.2.2) (2019-07-29)
|
||||||
|
|
||||||
|
|||||||
21
codecept.conf.js
Normal file
21
codecept.conf.js
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
exports.config = {
|
||||||
|
tests: './test/acceptance/*_test.js',
|
||||||
|
output: './test/acceptance/output',
|
||||||
|
helpers: {
|
||||||
|
Puppeteer: {
|
||||||
|
url: 'http://localhost:8080',
|
||||||
|
// "show": true,
|
||||||
|
chrome: {
|
||||||
|
// headless: false
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
include: {
|
||||||
|
I: './test/acceptance/steps_file.js',
|
||||||
|
},
|
||||||
|
smartWait: 30000,
|
||||||
|
bootstrap: null,
|
||||||
|
plugins: {},
|
||||||
|
mocha: {},
|
||||||
|
name: '@verdaccio/ui-theme',
|
||||||
|
};
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
name: 'verdaccio-ui-jest',
|
|
||||||
verbose: true,
|
|
||||||
collectCoverage: true,
|
|
||||||
testEnvironment: 'jest-environment-jsdom-global',
|
|
||||||
moduleFileExtensions: ['js', 'ts', 'tsx'],
|
|
||||||
testURL: 'http://localhost',
|
|
||||||
rootDir: '..',
|
|
||||||
setupFiles: ['<rootDir>/test/setup.js'],
|
|
||||||
transformIgnorePatterns: ['<rootDir>/node_modules/(?!react-syntax-highlighter)'],
|
|
||||||
modulePathIgnorePatterns: ['<rootDir>/coverage', '<rootDir>/scripts', '<rootDir>/.circleci', '<rootDir>/tools', '<rootDir>/build', '<rootDir>/.vscode/'],
|
|
||||||
snapshotSerializers: ['enzyme-to-json/serializer', 'jest-emotion'],
|
|
||||||
moduleNameMapper: {
|
|
||||||
'\\.(s?css)$': '<rootDir>/node_modules/identity-obj-proxy',
|
|
||||||
'github-markdown-css': '<rootDir>/node_modules/identity-obj-proxy',
|
|
||||||
'\\.(png)$': '<rootDir>/node_modules/identity-obj-proxy',
|
|
||||||
'\\.(svg)$': '<rootDir>/test/unit/empty.ts',
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
// module.exports = {
|
|
||||||
// name: 'verdaccio-unit-jest',
|
|
||||||
// verbose: true,
|
|
||||||
// collectCoverage: true,
|
|
||||||
// testEnvironment: 'jest-environment-jsdom-global',
|
|
||||||
// testURL: 'http://localhost',
|
|
||||||
// testRegex: '../src/components/CopyToClipBoard/CopyToClipBoard.test.tsx',
|
|
||||||
// setupFiles: ['./setup.ts'],
|
|
||||||
// // Some unit tests rely on data folders that look like packages. This confuses jest-hast-map
|
|
||||||
// // when it tries to scan for package.json files.
|
|
||||||
// modulePathIgnorePatterns: ['<rootDir>/coverage', '<rootDir>/scripts', '<rootDir>/.circleci', '<rootDir>/tools', '<rootDir>/build', '<rootDir>/.vscode/'],
|
|
||||||
// // testPathIgnorePatterns: ['__snapshots__', '<rootDir>/build'],
|
|
||||||
// snapshotSerializers: ['enzyme-to-json/serializer', 'jest-emotion'],
|
|
||||||
// // coveragePathIgnorePatterns: ['node_modules', 'fixtures', '<rootDir>/src/api/debug', '<rootDir>/test'],
|
|
||||||
// // transformIgnorePatterns: ['<rootDir>/node_modules/(?!react-syntax-highlighter)'],
|
|
||||||
// };
|
|
||||||
@@ -3,6 +3,7 @@ const { defaults } = require('jest-config');
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'verdaccio-ui-jest',
|
name: 'verdaccio-ui-jest',
|
||||||
verbose: true,
|
verbose: true,
|
||||||
|
automock: false,
|
||||||
collectCoverage: true,
|
collectCoverage: true,
|
||||||
testEnvironment: 'jest-environment-jsdom-global',
|
testEnvironment: 'jest-environment-jsdom-global',
|
||||||
moduleFileExtensions: [...defaults.moduleFileExtensions, 'ts', 'tsx'],
|
moduleFileExtensions: [...defaults.moduleFileExtensions, 'ts', 'tsx'],
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
import 'raf/polyfill';
|
import 'raf/polyfill';
|
||||||
import { configure } from 'enzyme';
|
import { configure } from 'enzyme';
|
||||||
import Adapter from 'enzyme-adapter-react-16';
|
import Adapter from 'enzyme-adapter-react-16';
|
||||||
|
import { GlobalWithFetchMock } from 'jest-fetch-mock';
|
||||||
|
|
||||||
// @ts-ignore : Only a void function can be called with the 'new' keyword
|
// @ts-ignore : Only a void function can be called with the 'new' keyword
|
||||||
configure({ adapter: new Adapter() });
|
configure({ adapter: new Adapter() });
|
||||||
@@ -14,6 +15,10 @@ global.__APP_VERSION__ = '1.0.0';
|
|||||||
// @ts-ignore : Property '__VERDACCIO_BASENAME_UI_OPTIONS' does not exist on type 'Global'.
|
// @ts-ignore : Property '__VERDACCIO_BASENAME_UI_OPTIONS' does not exist on type 'Global'.
|
||||||
global.__VERDACCIO_BASENAME_UI_OPTIONS = {};
|
global.__VERDACCIO_BASENAME_UI_OPTIONS = {};
|
||||||
|
|
||||||
|
const customGlobal: GlobalWithFetchMock = global as GlobalWithFetchMock;
|
||||||
|
customGlobal.fetch = require('jest-fetch-mock');
|
||||||
|
customGlobal.fetchMock = customGlobal.fetch;
|
||||||
|
|
||||||
// mocking few DOM methods
|
// mocking few DOM methods
|
||||||
// @ts-ignore : Property 'document' does not exist on type 'Global'.
|
// @ts-ignore : Property 'document' does not exist on type 'Global'.
|
||||||
if (global.document) {
|
if (global.document) {
|
||||||
|
|||||||
97
package.json
97
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@verdaccio/ui-theme",
|
"name": "@verdaccio/ui-theme",
|
||||||
"version": "0.2.2",
|
"version": "0.2.3",
|
||||||
"description": "Verdaccio User Interface",
|
"description": "Verdaccio User Interface",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Verdaccio Core Team"
|
"name": "Verdaccio Core Team"
|
||||||
@@ -11,92 +11,100 @@
|
|||||||
},
|
},
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@commitlint/cli": "8.0.0",
|
"@commitlint/cli": "8.1.0",
|
||||||
"@commitlint/config-conventional": "8.0.0",
|
"@commitlint/config-conventional": "8.1.0",
|
||||||
"@material-ui/core": "3.9.3",
|
"@material-ui/core": "3.9.3",
|
||||||
"@material-ui/icons": "3.0.2",
|
"@material-ui/icons": "3.0.2",
|
||||||
"@octokit/rest": "16.28.7",
|
"@octokit/rest": "16.28.7",
|
||||||
|
"@testing-library/react": "9.1.3",
|
||||||
"@types/enzyme": "3.10.3",
|
"@types/enzyme": "3.10.3",
|
||||||
"@types/lodash": "4.14.134",
|
"@types/jest": "24.0.18",
|
||||||
|
"@types/lodash": "4.14.137",
|
||||||
"@types/material-ui": "0.21.6",
|
"@types/material-ui": "0.21.6",
|
||||||
"@types/node": "12.6.8",
|
"@types/node": "12.7.2",
|
||||||
"@types/react": "16.8.16",
|
"@types/react": "16.9.2",
|
||||||
"@types/react-dom": "16.8.4",
|
"@types/react-dom": "16.9.0",
|
||||||
"@types/react-router-dom": "4.3.2",
|
"@types/react-router-dom": "4.3.5",
|
||||||
"@types/validator": "10.11.1",
|
"@types/validator": "10.11.3",
|
||||||
"@verdaccio/babel-preset": "2.0.0",
|
"@verdaccio/babel-preset": "2.0.0",
|
||||||
"@verdaccio/eslint-config": "2.0.0",
|
"@verdaccio/eslint-config": "2.0.0",
|
||||||
"@verdaccio/types": "7.0.0",
|
"@verdaccio/types": "8.0.0",
|
||||||
"autosuggest-highlight": "3.1.1",
|
"autosuggest-highlight": "3.1.1",
|
||||||
"babel-loader": "8.0.6",
|
"babel-loader": "8.0.6",
|
||||||
"bundlesize": "0.18.0",
|
"bundlesize": "0.18.0",
|
||||||
|
"codeceptjs": "2.2.1",
|
||||||
"codecov": "3.5.0",
|
"codecov": "3.5.0",
|
||||||
"concurrently": "4.1.0",
|
"concurrently": "4.1.2",
|
||||||
"cross-env": "5.2.0",
|
"cross-env": "5.2.0",
|
||||||
"css-loader": "0.28.10",
|
"css-loader": "3.2.0",
|
||||||
"date-fns": "1.30.1",
|
"date-fns": "1.30.1",
|
||||||
"emotion": "9.2.12",
|
"emotion": "9.2.12",
|
||||||
"enzyme": "3.10.0",
|
"enzyme": "3.10.0",
|
||||||
"enzyme-adapter-react-16": "1.14.0",
|
"enzyme-adapter-react-16": "1.14.0",
|
||||||
"enzyme-to-json": "3.3.5",
|
"enzyme-to-json": "3.4.0",
|
||||||
"eslint": "5.16.0",
|
"eslint": "5.16.0",
|
||||||
"eslint-plugin-jsx-a11y": "6.2.1",
|
"eslint-plugin-codeceptjs": "1.1.0",
|
||||||
|
"eslint-plugin-jsx-a11y": "6.2.3",
|
||||||
"eslint-plugin-prettier": "3.1.0",
|
"eslint-plugin-prettier": "3.1.0",
|
||||||
"eslint-plugin-react": "7.13.0",
|
"eslint-plugin-react": "7.14.3",
|
||||||
|
"eslint-plugin-react-hooks": "1.7.0",
|
||||||
"eslint-plugin-verdaccio": "2.0.0",
|
"eslint-plugin-verdaccio": "2.0.0",
|
||||||
"file-loader": "2.0.0",
|
"file-loader": "4.2.0",
|
||||||
"friendly-errors-webpack-plugin": "1.7.0",
|
"friendly-errors-webpack-plugin": "1.7.0",
|
||||||
"get-stdin": "6.0.0",
|
"get-stdin": "6.0.0",
|
||||||
"github-markdown-css": "2.10.0",
|
"github-markdown-css": "3.0.1",
|
||||||
"html-webpack-plugin": "3.2.0",
|
"html-webpack-plugin": "3.2.0",
|
||||||
"husky": "2.4.1",
|
"husky": "3.0.3",
|
||||||
"identity-obj-proxy": "3.0.0",
|
"identity-obj-proxy": "3.0.0",
|
||||||
"in-publish": "2.0.0",
|
"in-publish": "2.0.0",
|
||||||
"jest": "24.8.0",
|
"jest": "24.9.0",
|
||||||
"jest-emotion": "10.0.11",
|
"jest-emotion": "10.0.14",
|
||||||
"jest-environment-jsdom": "24.8.0",
|
"jest-environment-jsdom": "24.9.0",
|
||||||
"jest-environment-jsdom-global": "1.2.0",
|
"jest-environment-jsdom-global": "1.2.0",
|
||||||
"jest-environment-node": "24.8.0",
|
"jest-environment-node": "24.9.0",
|
||||||
|
"jest-fetch-mock": "2.1.2",
|
||||||
|
"js-base64": "2.5.1",
|
||||||
"js-yaml": "3.13.1",
|
"js-yaml": "3.13.1",
|
||||||
"localstorage-memory": "1.0.3",
|
"localstorage-memory": "1.0.3",
|
||||||
"mini-css-extract-plugin": "0.7.0",
|
"mini-css-extract-plugin": "0.8.0",
|
||||||
"node-mocks-http": "1.7.3",
|
"node-mocks-http": "1.7.6",
|
||||||
"normalize.css": "8.0.1",
|
"normalize.css": "8.0.1",
|
||||||
"optimize-css-assets-webpack-plugin": "5.0.1",
|
"optimize-css-assets-webpack-plugin": "5.0.3",
|
||||||
"ora": "3.4.0",
|
"ora": "3.4.0",
|
||||||
"prettier": "1.18.2",
|
"prettier": "1.18.2",
|
||||||
"prop-types": "15.7.2",
|
"prop-types": "15.7.2",
|
||||||
"puppeteer": "1.17.0",
|
"puppeteer": "1.17.0",
|
||||||
"react": "16.8.3",
|
"react": "16.9.0",
|
||||||
"react-autosuggest": "9.4.2",
|
"react-autosuggest": "9.4.3",
|
||||||
"react-dom": "16.8.3",
|
"react-dom": "16.9.0",
|
||||||
"react-emotion": "9.2.12",
|
"react-emotion": "9.2.12",
|
||||||
"react-hot-loader": "4.7.1",
|
"react-hot-loader": "4.12.11",
|
||||||
"react-router": "4.3.1",
|
"react-router": "5.0.1",
|
||||||
"react-router-dom": "4.3.1",
|
"react-router-dom": "5.0.1",
|
||||||
"resolve-url-loader": "3.0.1",
|
"resolve-url-loader": "3.1.0",
|
||||||
"rimraf": "2.6.3",
|
"rimraf": "2.6.3",
|
||||||
"source-map-loader": "0.2.4",
|
"source-map-loader": "0.2.4",
|
||||||
"standard-version": "4.4.0",
|
"standard-version": "7.0.0",
|
||||||
"style-loader": "0.23.1",
|
"style-loader": "1.0.0",
|
||||||
"stylelint": "10.1.0",
|
"stylelint": "10.1.0",
|
||||||
"stylelint-config-recommended": "2.2.0",
|
"stylelint-config-recommended": "2.2.0",
|
||||||
"stylelint-config-styled-components": "0.1.1",
|
"stylelint-config-styled-components": "0.1.1",
|
||||||
"stylelint-processor-styled-components": "1.8.0",
|
"stylelint-processor-styled-components": "1.8.0",
|
||||||
"stylelint-webpack-plugin": "0.10.5",
|
"stylelint-webpack-plugin": "0.10.5",
|
||||||
"supertest": "4.0.2",
|
"supertest": "4.0.2",
|
||||||
"typeface-roboto": "0.0.54",
|
"typeface-roboto": "0.0.75",
|
||||||
"typescript": "3.5.3",
|
"typescript": "3.5.3",
|
||||||
"url-loader": "1.1.2",
|
"uglifyjs-webpack-plugin": "2.2.0",
|
||||||
"validator": "10.11.0",
|
"url-loader": "2.1.0",
|
||||||
"verdaccio": "4.1.0",
|
"validator": "11.1.0",
|
||||||
|
"verdaccio": "4.2.1",
|
||||||
"verdaccio-auth-memory": "1.1.5",
|
"verdaccio-auth-memory": "1.1.5",
|
||||||
"verdaccio-memory": "2.0.0",
|
"verdaccio-memory": "2.0.0",
|
||||||
"webpack": "4.20.2",
|
"webpack": "4.39.2",
|
||||||
"webpack-bundle-analyzer": "3.3.2",
|
"webpack-bundle-analyzer": "3.4.1",
|
||||||
"webpack-bundle-size-analyzer": "3.0.0",
|
"webpack-bundle-size-analyzer": "3.0.0",
|
||||||
"webpack-cli": "3.3.6",
|
"webpack-cli": "3.3.7",
|
||||||
"webpack-dev-server": "3.7.2",
|
"webpack-dev-server": "3.8.0",
|
||||||
"webpack-merge": "4.2.1",
|
"webpack-merge": "4.2.1",
|
||||||
"whatwg-fetch": "3.0.0",
|
"whatwg-fetch": "3.0.0",
|
||||||
"xss": "1.0.6"
|
"xss": "1.0.6"
|
||||||
@@ -136,7 +144,10 @@
|
|||||||
"type-check": "tsc --noEmit",
|
"type-check": "tsc --noEmit",
|
||||||
"type-check:watch": "npm run type-check -- --watch",
|
"type-check:watch": "npm run type-check -- --watch",
|
||||||
"release": "standard-version -a -s",
|
"release": "standard-version -a -s",
|
||||||
"test": "cross-env NODE_ENV=test BABEL_ENV=test TZ=UTC jest --config ./jest/jest.config.js --maxWorkers 2",
|
"test:clean": "npx jest --clearCache",
|
||||||
|
"test:acceptance": "codeceptjs run --steps",
|
||||||
|
"test:acceptance:server": "concurrently --kill-others \"npm run verdaccio:server\" \"npm run test:acceptance\"",
|
||||||
|
"test": "cross-env NODE_ENV=test BABEL_ENV=test TZ=UTC jest --config ./jest/jest.config.js --maxWorkers 2 --passWithNoTests",
|
||||||
"test:size": "bundlesize",
|
"test:size": "bundlesize",
|
||||||
"lint": "npm run lint:js && npm run lint:css",
|
"lint": "npm run lint:js && npm run lint:css",
|
||||||
"lint:js": "npm run type-check && eslint . --ext .js,.ts,.tsx",
|
"lint:js": "npm run type-check && eslint . --ext .js,.ts,.tsx",
|
||||||
|
|||||||
1
partials/storage/.verdaccio-db.json
Normal file
1
partials/storage/.verdaccio-db.json
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"list":["vue","jquery"],"secret":"3bb332943c7086716a35dea44754b43b956ee655af1fe61866fbdaf38486836c"}
|
||||||
BIN
partials/storage/jquery/jquery-1.5.1.tgz
Normal file
BIN
partials/storage/jquery/jquery-1.5.1.tgz
Normal file
Binary file not shown.
4983
partials/storage/jquery/package.json
Normal file
4983
partials/storage/jquery/package.json
Normal file
File diff suppressed because it is too large
Load Diff
25169
partials/storage/vue/package.json
Normal file
25169
partials/storage/vue/package.json
Normal file
File diff suppressed because one or more lines are too long
38
src/App/AppError.tsx
Normal file
38
src/App/AppError.tsx
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
import React, { Component } from 'react';
|
||||||
|
|
||||||
|
export interface ErrorProps {
|
||||||
|
children: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ErrorAppState {
|
||||||
|
hasError: boolean;
|
||||||
|
error: any;
|
||||||
|
info: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class ErrorBoundary extends Component<ErrorProps, ErrorAppState> {
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.state = { hasError: false, error: null, info: null };
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidCatch(error, info) {
|
||||||
|
this.setState({ hasError: true, error, info });
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const { hasError, error, info } = this.state;
|
||||||
|
const { children } = this.props;
|
||||||
|
|
||||||
|
if (hasError) {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<h1>{'Something went wrong.'}</h1>
|
||||||
|
<p>{`error: ${error}`}</p>
|
||||||
|
<p>{`info: ${JSON.stringify(info)}`}</p>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return children;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,7 +19,7 @@ describe('<ActionBar /> component', () => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
jest.doMock('../../pages/version/Version', () => ({
|
jest.doMock('../../pages/Version', () => ({
|
||||||
DetailContextConsumer: component => {
|
DetailContextConsumer: component => {
|
||||||
return component.children({ packageMeta });
|
return component.children({ packageMeta });
|
||||||
},
|
},
|
||||||
@@ -35,7 +35,7 @@ describe('<ActionBar /> component', () => {
|
|||||||
latest: {},
|
latest: {},
|
||||||
};
|
};
|
||||||
|
|
||||||
jest.doMock('../../pages/version/Version', () => ({
|
jest.doMock('../../pages/Version', () => ({
|
||||||
DetailContextConsumer: component => {
|
DetailContextConsumer: component => {
|
||||||
return component.children({ packageMeta });
|
return component.children({ packageMeta });
|
||||||
},
|
},
|
||||||
@@ -57,7 +57,7 @@ describe('<ActionBar /> component', () => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
jest.doMock('../../pages/version/Version', () => ({
|
jest.doMock('../../pages/Version', () => ({
|
||||||
DetailContextConsumer: component => {
|
DetailContextConsumer: component => {
|
||||||
return component.children({ packageMeta });
|
return component.children({ packageMeta });
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import HomeIcon from '@material-ui/icons/Home';
|
|||||||
import List from '@material-ui/core/List';
|
import List from '@material-ui/core/List';
|
||||||
import Tooltip from '@material-ui/core/Tooltip';
|
import Tooltip from '@material-ui/core/Tooltip';
|
||||||
|
|
||||||
import { DetailContextConsumer, VersionPageConsumerProps } from '../../pages/version/Version';
|
import { DetailContextConsumer, VersionPageConsumerProps } from '../../pages/Version';
|
||||||
import { Fab, ActionListItem } from './styles';
|
import { Fab, ActionListItem } from './styles';
|
||||||
import { isURL, extractFileName, downloadFile } from '../../utils/url';
|
import { isURL, extractFileName, downloadFile } from '../../utils/url';
|
||||||
import api from '../../utils/api';
|
import api from '../../utils/api';
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ describe('<Author /> component', () => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
jest.doMock('../../pages/version/Version', () => ({
|
jest.doMock('../../pages/Version', () => ({
|
||||||
DetailContextConsumer: component => {
|
DetailContextConsumer: component => {
|
||||||
return component.children({ packageMeta });
|
return component.children({ packageMeta });
|
||||||
},
|
},
|
||||||
@@ -39,7 +39,7 @@ describe('<Author /> component', () => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
jest.doMock('../../pages/version/Version', () => ({
|
jest.doMock('../../pages/Version', () => ({
|
||||||
DetailContextConsumer: component => {
|
DetailContextConsumer: component => {
|
||||||
return component.children({ packageMeta });
|
return component.children({ packageMeta });
|
||||||
},
|
},
|
||||||
@@ -63,7 +63,7 @@ describe('<Author /> component', () => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
jest.doMock('../../pages/version/Version', () => ({
|
jest.doMock('../../pages/Version', () => ({
|
||||||
DetailContextConsumer: component => {
|
DetailContextConsumer: component => {
|
||||||
return component.children({ packageMeta });
|
return component.children({ packageMeta });
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import Avatar from '@material-ui/core/Avatar';
|
|||||||
import List from '@material-ui/core/List';
|
import List from '@material-ui/core/List';
|
||||||
import ListItemText from '@material-ui/core/ListItemText';
|
import ListItemText from '@material-ui/core/ListItemText';
|
||||||
|
|
||||||
import { DetailContextConsumer } from '../../pages/version/Version';
|
import { DetailContextConsumer } from '../../pages/Version';
|
||||||
import { Heading, AuthorListItem } from './styles';
|
import { Heading, AuthorListItem } from './styles';
|
||||||
import { isEmail } from '../../utils/url';
|
import { isEmail } from '../../utils/url';
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import styled from 'react-emotion';
|
import styled from 'react-emotion';
|
||||||
import ListItem from '@material-ui/core/ListItem';
|
import ListItem from '@material-ui/core/ListItem';
|
||||||
import Typography from '@material-ui/core/Typography';
|
import Typography from '@material-ui/core/Typography';
|
||||||
|
import { fontWeight } from '../../utils/styles/sizes';
|
||||||
|
|
||||||
export const Heading = styled(Typography)({
|
export const Heading = styled(Typography)({
|
||||||
'&&': {
|
'&&': {
|
||||||
fontWeight: 700,
|
fontWeight: fontWeight.bold,
|
||||||
textTransform: 'capitalize',
|
textTransform: 'capitalize',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
32
src/components/AvatarTooltip/AvatarTooltip.tsx
Normal file
32
src/components/AvatarTooltip/AvatarTooltip.tsx
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
import React, { FC } from 'react';
|
||||||
|
|
||||||
|
import Avatar from '@material-ui/core/Avatar';
|
||||||
|
import Tooltip from '@material-ui/core/Tooltip';
|
||||||
|
import { isEmail } from '../../utils/url';
|
||||||
|
|
||||||
|
export interface AvatarDeveloper {
|
||||||
|
name: string;
|
||||||
|
packageName: string;
|
||||||
|
version: string;
|
||||||
|
avatar: string;
|
||||||
|
email: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const AvatarTooltip: FC<AvatarDeveloper> = ({ name, packageName, version, avatar, email }) => {
|
||||||
|
const avatarComponent = <Avatar aria-label={name} src={avatar} />;
|
||||||
|
function renderLinkForMail(email, avatarComponent, packageName, version): JSX.Element {
|
||||||
|
if (!email || isEmail(email) === false) {
|
||||||
|
return avatarComponent;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<a href={`mailto:${email}?subject=${packageName}@${version}`} target={'_top'}>
|
||||||
|
{avatarComponent}
|
||||||
|
</a>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return <Tooltip title={name}>{renderLinkForMail(email, avatarComponent, packageName, version)}</Tooltip>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export { AvatarTooltip };
|
||||||
4
src/components/AvatarTooltip/index.ts
Normal file
4
src/components/AvatarTooltip/index.ts
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
import { AvatarTooltip } from './AvatarTooltip';
|
||||||
|
|
||||||
|
export { AvatarTooltip };
|
||||||
|
export default AvatarTooltip;
|
||||||
@@ -2,7 +2,7 @@ import React, { Component, Fragment, ReactElement } from 'react';
|
|||||||
import { withRouter, RouteComponentProps } from 'react-router-dom';
|
import { withRouter, RouteComponentProps } from 'react-router-dom';
|
||||||
import CardContent from '@material-ui/core/CardContent';
|
import CardContent from '@material-ui/core/CardContent';
|
||||||
|
|
||||||
import { DetailContextConsumer, VersionPageConsumerProps } from '../../pages/version/Version';
|
import { DetailContextConsumer, VersionPageConsumerProps } from '../../pages/Version';
|
||||||
|
|
||||||
import { CardWrap, Heading, Tags, Tag } from './styles';
|
import { CardWrap, Heading, Tags, Tag } from './styles';
|
||||||
import NoItems from '../NoItems';
|
import NoItems from '../NoItems';
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import styled from 'react-emotion';
|
|||||||
import Card from '@material-ui/core/Card';
|
import Card from '@material-ui/core/Card';
|
||||||
import Typography from '@material-ui/core/Typography';
|
import Typography from '@material-ui/core/Typography';
|
||||||
import Chip from '@material-ui/core/Chip';
|
import Chip from '@material-ui/core/Chip';
|
||||||
|
import { fontWeight } from '../../utils/styles/sizes';
|
||||||
|
|
||||||
export const CardWrap = styled(Card)({
|
export const CardWrap = styled(Card)({
|
||||||
'&&': {
|
'&&': {
|
||||||
@@ -11,7 +12,7 @@ export const CardWrap = styled(Card)({
|
|||||||
|
|
||||||
export const Heading = styled(Typography)({
|
export const Heading = styled(Typography)({
|
||||||
'&&': {
|
'&&': {
|
||||||
fontWeight: 700,
|
fontWeight: fontWeight.bold,
|
||||||
textTransform: 'capitalize',
|
textTransform: 'capitalize',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import React, { Component, ReactElement, Fragment } from 'react';
|
import React, { Component, ReactElement, Fragment } from 'react';
|
||||||
|
|
||||||
import { DetailContextConsumer, VersionPageConsumerProps } from '../../pages/version/Version';
|
import { DetailContextConsumer, VersionPageConsumerProps } from '../../pages/Version';
|
||||||
import Readme from '../Readme';
|
import Readme from '../Readme';
|
||||||
import Versions from '../Versions';
|
import Versions from '../Versions';
|
||||||
import { preventXSS } from '../../utils/sec-utils';
|
import { preventXSS } from '../../utils/sec-utils';
|
||||||
@@ -14,6 +14,11 @@ interface DetailContainerState {
|
|||||||
tabPosition: number;
|
tabPosition: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const README_LABEL = 'Readme';
|
||||||
|
export const DEPS_LABEL = 'Dependencies';
|
||||||
|
export const VERSION_LABEL = 'Versions';
|
||||||
|
export const UPLINKS_LABEL = 'Uplinks';
|
||||||
|
|
||||||
class DetailContainer<P> extends Component<P, DetailContainerState> {
|
class DetailContainer<P> extends Component<P, DetailContainerState> {
|
||||||
public state = {
|
public state = {
|
||||||
tabPosition: 0,
|
tabPosition: 0,
|
||||||
@@ -37,10 +42,10 @@ class DetailContainer<P> extends Component<P, DetailContainerState> {
|
|||||||
private renderListTabs(tabPosition: number): React.ReactElement<HTMLElement> {
|
private renderListTabs(tabPosition: number): React.ReactElement<HTMLElement> {
|
||||||
return (
|
return (
|
||||||
<Tabs indicatorColor={'primary'} onChange={this.handleChange} textColor={'primary'} value={tabPosition} variant={'fullWidth'}>
|
<Tabs indicatorColor={'primary'} onChange={this.handleChange} textColor={'primary'} value={tabPosition} variant={'fullWidth'}>
|
||||||
<Tab id={'readme-tab'} label={'Readme'} />
|
<Tab data-testid={'readme-tab'} id={'readme-tab'} label={README_LABEL} />
|
||||||
<Tab id={'dependencies-tab'} label={'Dependencies'} />
|
<Tab data-testid={'dependencies-tab'} id={'dependencies-tab'} label={DEPS_LABEL} />
|
||||||
<Tab id={'versions-tab'} label={'Versions'} />
|
<Tab data-testid={'versions-tab'} id={'versions-tab'} label={VERSION_LABEL} />
|
||||||
<Tab id={'uplinks-tab'} label={'Uplinks'} />
|
<Tab data-testid={'uplinks-tab'} id={'uplinks-tab'} label={UPLINKS_LABEL} />
|
||||||
</Tabs>
|
</Tabs>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React, { Component, ReactElement } from 'react';
|
import React, { ReactElement } from 'react';
|
||||||
|
|
||||||
import Card from '@material-ui/core/Card';
|
import Card from '@material-ui/core/Card';
|
||||||
import CardContent from '@material-ui/core/CardContent';
|
import CardContent from '@material-ui/core/CardContent';
|
||||||
@@ -12,76 +12,52 @@ import Engine from '../Engines/Engines';
|
|||||||
import Install from '../Install';
|
import Install from '../Install';
|
||||||
import Repository from '../Repository/Repository';
|
import Repository from '../Repository/Repository';
|
||||||
|
|
||||||
import { DetailContextConsumer, VersionPageConsumerProps } from '../../pages/version/Version';
|
import { DetailContext } from '../../pages/Version';
|
||||||
|
|
||||||
import { TitleListItem, TitleListItemText } from './styles';
|
import { TitleListItem, TitleListItemText } from './styles';
|
||||||
|
|
||||||
class DetailSidebar extends Component {
|
const renderCopyCLI = () => <Install />;
|
||||||
public render(): ReactElement<HTMLElement> {
|
const renderMaintainers = () => <Developers type="maintainers" />;
|
||||||
return <DetailContextConsumer>{context => this.renderSideBar(context as VersionPageConsumerProps)}</DetailContextConsumer>;
|
const renderContributors = () => <Developers type="contributors" />;
|
||||||
}
|
const renderRepository = () => <Repository />;
|
||||||
|
const renderAuthor = () => <Author />;
|
||||||
|
const renderEngine = () => <Engine />;
|
||||||
|
const renderDist = () => <Dist />;
|
||||||
|
const renderActionBar = () => <ActionBar />;
|
||||||
|
const renderTitle = (packageName, packageMeta) => {
|
||||||
|
return (
|
||||||
|
<List className="detail-info">
|
||||||
|
<TitleListItem alignItems="flex-start">
|
||||||
|
<TitleListItemText primary={<b>{packageName}</b>} secondary={packageMeta.latest.description} />
|
||||||
|
</TitleListItem>
|
||||||
|
</List>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
private renderSideBar = ({ packageName, packageMeta }): ReactElement<HTMLElement> => {
|
function renderSideBar(packageName, packageMeta): ReactElement<HTMLElement> {
|
||||||
return (
|
return (
|
||||||
<div className={'sidebar-info'}>
|
<div className={'sidebar-info'}>
|
||||||
<Card>
|
<Card>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
{this.renderTitle(packageName, packageMeta)}
|
{renderTitle(packageName, packageMeta)}
|
||||||
{this.renderActionBar()}
|
{renderActionBar()}
|
||||||
{this.renderCopyCLI()}
|
{renderCopyCLI()}
|
||||||
{this.renderRepository()}
|
{renderRepository()}
|
||||||
{this.renderEngine()}
|
{renderEngine()}
|
||||||
{this.renderDist()}
|
{renderDist()}
|
||||||
{this.renderAuthor()}
|
{renderAuthor()}
|
||||||
{this.renderMaintainers()}
|
{renderMaintainers()}
|
||||||
{this.renderContributors()}
|
{renderContributors()}
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
|
||||||
|
|
||||||
private renderTitle = (packageName, packageMeta) => {
|
|
||||||
return (
|
|
||||||
<List className="detail-info">
|
|
||||||
<TitleListItem alignItems="flex-start">
|
|
||||||
<TitleListItemText primary={<b>{packageName}</b>} secondary={packageMeta.latest.description} />
|
|
||||||
</TitleListItem>
|
|
||||||
</List>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
private renderCopyCLI = () => {
|
|
||||||
return <Install />;
|
|
||||||
};
|
|
||||||
|
|
||||||
private renderMaintainers = () => {
|
|
||||||
return <Developers type="maintainers" />;
|
|
||||||
};
|
|
||||||
|
|
||||||
private renderContributors = () => {
|
|
||||||
return <Developers type="contributors" />;
|
|
||||||
};
|
|
||||||
|
|
||||||
private renderRepository = () => {
|
|
||||||
return <Repository />;
|
|
||||||
};
|
|
||||||
|
|
||||||
private renderAuthor = () => {
|
|
||||||
return <Author />;
|
|
||||||
};
|
|
||||||
|
|
||||||
private renderEngine = () => {
|
|
||||||
return <Engine />;
|
|
||||||
};
|
|
||||||
|
|
||||||
private renderDist = () => {
|
|
||||||
return <Dist />;
|
|
||||||
};
|
|
||||||
|
|
||||||
private renderActionBar = () => {
|
|
||||||
return <ActionBar />;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const DetailSidebar = () => {
|
||||||
|
const { packageName, packageMeta } = React.useContext(DetailContext);
|
||||||
|
|
||||||
|
return renderSideBar(packageName, packageMeta);
|
||||||
|
};
|
||||||
|
|
||||||
export default DetailSidebar;
|
export default DetailSidebar;
|
||||||
|
|||||||
104
src/components/Developers/Developers.test.tsx
Normal file
104
src/components/Developers/Developers.test.tsx
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { mount } from 'enzyme';
|
||||||
|
import Developers, { DevelopersType } from './Developers';
|
||||||
|
import { Fab } from './styles';
|
||||||
|
import { DetailContextProvider } from '../../pages/Version';
|
||||||
|
|
||||||
|
describe('test Developers', () => {
|
||||||
|
const packageMeta = {
|
||||||
|
latest: {
|
||||||
|
packageName: 'foo',
|
||||||
|
version: '1.0.0',
|
||||||
|
maintainers: [
|
||||||
|
{
|
||||||
|
name: 'dmethvin',
|
||||||
|
email: 'dave.methvin@gmail.com',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'mgol',
|
||||||
|
email: 'm.goleb@gmail.com',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
contributors: [
|
||||||
|
{
|
||||||
|
name: 'dmethvin',
|
||||||
|
email: 'dave.methvin@gmail.com',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'mgol',
|
||||||
|
email: 'm.goleb@gmail.com',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
test('should render the component with no items', () => {
|
||||||
|
const type: DevelopersType = 'maintainers';
|
||||||
|
const packageMeta = {
|
||||||
|
latest: {},
|
||||||
|
};
|
||||||
|
const wrapper = mount(
|
||||||
|
// @ts-ignore
|
||||||
|
<DetailContextProvider value={{ packageMeta }}>
|
||||||
|
<Developers type={type} />
|
||||||
|
</DetailContextProvider>
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(wrapper).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should render the component for maintainers with items', () => {
|
||||||
|
const type: DevelopersType = 'maintainers';
|
||||||
|
const wrapper = mount(
|
||||||
|
// @ts-ignore
|
||||||
|
<DetailContextProvider value={{ packageMeta }}>
|
||||||
|
<Developers type={type} />
|
||||||
|
</DetailContextProvider>
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(wrapper).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should render the component for contributors with items', () => {
|
||||||
|
const type: DevelopersType = 'contributors';
|
||||||
|
const wrapper = mount(
|
||||||
|
// @ts-ignore
|
||||||
|
<DetailContextProvider value={{ packageMeta }}>
|
||||||
|
<Developers type={type} />
|
||||||
|
</DetailContextProvider>
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(wrapper).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should test onClick the component avatar', () => {
|
||||||
|
const type: DevelopersType = 'contributors';
|
||||||
|
const packageMeta = {
|
||||||
|
latest: {
|
||||||
|
packageName: 'foo',
|
||||||
|
version: '1.0.0',
|
||||||
|
contributors: [
|
||||||
|
{
|
||||||
|
name: 'dmethvin',
|
||||||
|
email: 'dave.methvin@gmail.com',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'dmethvin2',
|
||||||
|
email: 'dave2.methvin@gmail.com',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const wrapper = mount(
|
||||||
|
// @ts-ignore
|
||||||
|
<DetailContextProvider value={{ packageMeta }}>
|
||||||
|
<Developers type={type} visibleMax={1} />
|
||||||
|
</DetailContextProvider>
|
||||||
|
);
|
||||||
|
|
||||||
|
const item2 = wrapper.find(Fab);
|
||||||
|
// TODO: I am not sure here how to verify the method inside the component was called.
|
||||||
|
item2.simulate('click');
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -1,79 +1,59 @@
|
|||||||
import React, { Component } from 'react';
|
import React, { FC, Fragment } from 'react';
|
||||||
|
|
||||||
import Avatar from '@material-ui/core/Avatar';
|
|
||||||
import Add from '@material-ui/icons/Add';
|
import Add from '@material-ui/icons/Add';
|
||||||
import Tooltip from '@material-ui/core/Tooltip';
|
|
||||||
|
|
||||||
import { DetailContextConsumer } from '../../pages/version/Version';
|
import { DetailContext } from '../../pages/Version';
|
||||||
|
import { AvatarTooltip } from '../AvatarTooltip';
|
||||||
import { Details, Heading, Content, Fab } from './styles';
|
import { Details, Heading, Content, Fab } from './styles';
|
||||||
import { isEmail } from '../../utils/url';
|
|
||||||
|
export type DevelopersType = 'contributors' | 'maintainers';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
type: 'contributors' | 'maintainers';
|
type: DevelopersType;
|
||||||
}
|
visibleMax?: number;
|
||||||
interface State {
|
|
||||||
visibleDevs: number;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class Developers extends Component<Props, State> {
|
export const VISIBLE_MAX = 6;
|
||||||
public state = {
|
|
||||||
visibleDevs: 6,
|
const Developers: FC<Props> = ({ type, visibleMax }) => {
|
||||||
|
const [visibleDevs, setVisibleDevs] = React.useState<number>(visibleMax || VISIBLE_MAX);
|
||||||
|
const { packageMeta } = React.useContext(DetailContext);
|
||||||
|
|
||||||
|
const handleLoadMore = () => {
|
||||||
|
setVisibleDevs(visibleDevs + VISIBLE_MAX);
|
||||||
};
|
};
|
||||||
|
|
||||||
public render(): JSX.Element {
|
const renderDeveloperDetails = ({ name, avatar, email }, packageMeta) => {
|
||||||
return (
|
const { name: packageName, version } = packageMeta.latest;
|
||||||
<DetailContextConsumer>
|
|
||||||
{({ packageMeta }) => {
|
|
||||||
const { type } = this.props;
|
|
||||||
const developerType = packageMeta && packageMeta.latest[type];
|
|
||||||
if (!developerType || developerType.length === 0) return null;
|
|
||||||
return this.renderDevelopers(developerType, packageMeta);
|
|
||||||
}}
|
|
||||||
</DetailContextConsumer>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public handleLoadMore = () => {
|
return <AvatarTooltip avatar={avatar} email={email} name={name} packageName={packageName} version={version} />;
|
||||||
this.setState(prev => ({ visibleDevs: prev.visibleDevs + 6 }));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
private renderDevelopers = (developers, packageMeta) => {
|
const renderDevelopers = (developers, packageMeta) => {
|
||||||
const { type } = this.props;
|
const listVisibleDevelopers = developers.slice(0, visibleDevs);
|
||||||
const { visibleDevs } = this.state;
|
|
||||||
return (
|
return (
|
||||||
<>
|
<Fragment>
|
||||||
<Heading variant={'subheading'}>{type}</Heading>
|
<Heading variant={'subheading'}>{type}</Heading>
|
||||||
<Content>
|
<Content>
|
||||||
{developers.slice(0, visibleDevs).map(developer => (
|
{listVisibleDevelopers.map(developer => (
|
||||||
<Details key={developer.email}>{this.renderDeveloperDetails(developer, packageMeta)}</Details>
|
<Details key={developer.email}>{renderDeveloperDetails(developer, packageMeta)}</Details>
|
||||||
))}
|
))}
|
||||||
{visibleDevs < developers.length && (
|
{visibleDevs < developers.length && (
|
||||||
<Fab onClick={this.handleLoadMore} size="small">
|
<Fab onClick={handleLoadMore} size="small">
|
||||||
<Add />
|
<Add />
|
||||||
</Fab>
|
</Fab>
|
||||||
)}
|
)}
|
||||||
</Content>
|
</Content>
|
||||||
</>
|
</Fragment>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
private renderLinkForMail(email, avatarComponent, packageName, version): JSX.Element {
|
const developerList = packageMeta && packageMeta.latest[type];
|
||||||
if (!email || isEmail(email) === false) {
|
if (!developerList || developerList.length === 0) {
|
||||||
return avatarComponent;
|
return null;
|
||||||
}
|
|
||||||
return (
|
|
||||||
<a href={`mailto:${email}?subject=${packageName}@${version}`} target={'_top'}>
|
|
||||||
{avatarComponent}
|
|
||||||
</a>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private renderDeveloperDetails = ({ name, avatar, email }, packageMeta) => {
|
return renderDevelopers(developerList, packageMeta);
|
||||||
const { name: packageName, version } = packageMeta.latest;
|
};
|
||||||
|
|
||||||
const avatarComponent = <Avatar aria-label={name} src={avatar} />;
|
|
||||||
return <Tooltip title={name}>{this.renderLinkForMail(email, avatarComponent, packageName, version)}</Tooltip>;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export default Developers;
|
export default Developers;
|
||||||
|
|||||||
2737
src/components/Developers/__snapshots__/Developers.test.tsx.snap
Normal file
2737
src/components/Developers/__snapshots__/Developers.test.tsx.snap
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,9 @@
|
|||||||
import styled from 'react-emotion';
|
import styled from 'react-emotion';
|
||||||
import Typography from '@material-ui/core/Typography';
|
import Typography from '@material-ui/core/Typography';
|
||||||
import { default as MuiFab } from '@material-ui/core/Fab';
|
import { default as MuiFab } from '@material-ui/core/Fab';
|
||||||
|
|
||||||
import colors from '../../utils/styles/colors';
|
import colors from '../../utils/styles/colors';
|
||||||
|
import { fontWeight } from '../../utils/styles/sizes';
|
||||||
|
|
||||||
export const Details = styled('span')({
|
export const Details = styled('span')({
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
@@ -20,7 +22,7 @@ export const Content = styled('div')({
|
|||||||
|
|
||||||
export const Heading = styled(Typography)({
|
export const Heading = styled(Typography)({
|
||||||
'&&': {
|
'&&': {
|
||||||
fontWeight: 700,
|
fontWeight: fontWeight.bold,
|
||||||
marginBottom: '10px',
|
marginBottom: '10px',
|
||||||
textTransform: 'capitalize',
|
textTransform: 'capitalize',
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ describe('<Dist /> component', () => {
|
|||||||
license: '',
|
license: '',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
jest.doMock('../../pages/version/Version', () => ({
|
jest.doMock('../../pages/Version', () => ({
|
||||||
DetailContextConsumer: component => {
|
DetailContextConsumer: component => {
|
||||||
return component.children({ packageMeta });
|
return component.children({ packageMeta });
|
||||||
},
|
},
|
||||||
@@ -41,7 +41,7 @@ describe('<Dist /> component', () => {
|
|||||||
license: 'MIT',
|
license: 'MIT',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
jest.doMock('../../pages/version/Version', () => ({
|
jest.doMock('../../pages/Version', () => ({
|
||||||
DetailContextConsumer: component => {
|
DetailContextConsumer: component => {
|
||||||
return component.children({ packageMeta });
|
return component.children({ packageMeta });
|
||||||
},
|
},
|
||||||
@@ -67,7 +67,7 @@ describe('<Dist /> component', () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
jest.doMock('../../pages/version/Version', () => ({
|
jest.doMock('../../pages/Version', () => ({
|
||||||
DetailContextConsumer: component => {
|
DetailContextConsumer: component => {
|
||||||
return component.children({ packageMeta });
|
return component.children({ packageMeta });
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import React, { Component } from 'react';
|
|||||||
|
|
||||||
import List from '@material-ui/core/List';
|
import List from '@material-ui/core/List';
|
||||||
|
|
||||||
import { DetailContextConsumer, VersionPageConsumerProps } from '../../pages/version/Version';
|
import { VersionPageConsumerProps, DetailContextConsumer } from '../../pages/Version';
|
||||||
import { Heading, DistListItem, DistChips } from './styles';
|
import { Heading, DistListItem, DistChips } from './styles';
|
||||||
import fileSizeSI from '../../utils/file-size';
|
import fileSizeSI from '../../utils/file-size';
|
||||||
import { PackageMetaInterface } from 'types/packageMeta';
|
import { PackageMetaInterface } from 'types/packageMeta';
|
||||||
|
|||||||
@@ -5,10 +5,11 @@ import ListItem from '@material-ui/core/ListItem';
|
|||||||
import Typography from '@material-ui/core/Typography';
|
import Typography from '@material-ui/core/Typography';
|
||||||
|
|
||||||
import colors from '../../utils/styles/colors';
|
import colors from '../../utils/styles/colors';
|
||||||
|
import { fontWeight } from '../../utils/styles/sizes';
|
||||||
|
|
||||||
export const Heading = styled(Typography)({
|
export const Heading = styled(Typography)({
|
||||||
'&&': {
|
'&&': {
|
||||||
fontWeight: 700,
|
fontWeight: fontWeight.bold,
|
||||||
textTransform: 'capitalize',
|
textTransform: 'capitalize',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ describe('<Engines /> component', () => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
jest.doMock('../../pages/version/Version', () => ({
|
jest.doMock('../../pages/Version', () => ({
|
||||||
DetailContextConsumer: component => {
|
DetailContextConsumer: component => {
|
||||||
return component.children({ packageMeta });
|
return component.children({ packageMeta });
|
||||||
},
|
},
|
||||||
@@ -35,7 +35,7 @@ describe('<Engines /> component', () => {
|
|||||||
latest: {},
|
latest: {},
|
||||||
};
|
};
|
||||||
|
|
||||||
jest.doMock('../../pages/version/Version', () => ({
|
jest.doMock('../../pages/Version', () => ({
|
||||||
DetailContextConsumer: component => {
|
DetailContextConsumer: component => {
|
||||||
return component.children({ packageMeta });
|
return component.children({ packageMeta });
|
||||||
},
|
},
|
||||||
@@ -53,7 +53,7 @@ describe('<Engines /> component', () => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
jest.doMock('../../pages/version/Version', () => ({
|
jest.doMock('../../pages/Version', () => ({
|
||||||
DetailContextConsumer: component => {
|
DetailContextConsumer: component => {
|
||||||
return component.children({ packageMeta });
|
return component.children({ packageMeta });
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import Grid from '@material-ui/core/Grid';
|
|||||||
import List from '@material-ui/core/List';
|
import List from '@material-ui/core/List';
|
||||||
import ListItemText from '@material-ui/core/ListItemText';
|
import ListItemText from '@material-ui/core/ListItemText';
|
||||||
|
|
||||||
import { DetailContextConsumer, VersionPageConsumerProps } from '../../pages/version/Version';
|
import { VersionPageConsumerProps, DetailContextConsumer } from '../../pages/Version';
|
||||||
import { Heading, EngineListItem } from './styles';
|
import { Heading, EngineListItem } from './styles';
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import node from './img/node.png';
|
import node from './img/node.png';
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import styled from 'react-emotion';
|
import styled from 'react-emotion';
|
||||||
import ListItem from '@material-ui/core/ListItem';
|
import ListItem from '@material-ui/core/ListItem';
|
||||||
import Typography from '@material-ui/core/Typography';
|
import Typography from '@material-ui/core/Typography';
|
||||||
|
import { fontWeight } from '../../utils/styles/sizes';
|
||||||
|
|
||||||
export const Heading = styled(Typography)({
|
export const Heading = styled(Typography)({
|
||||||
'&&': {
|
'&&': {
|
||||||
fontWeight: 700,
|
fontWeight: fontWeight.bold,
|
||||||
textTransform: 'capitalize',
|
textTransform: 'capitalize',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
exports[`<Footer /> component should load the initial state of Footer component 1`] = `"<div class=\\"css-i0nj2g ezbsl480\\"><div class=\\"css-hzfs9b ezbsl481\\"><div class=\\"css-d8nsp7 ezbsl482\\"> Made with<span class=\\"css-1so4oe0 ezbsl487\\">♥</span>on<span class=\\"css-1ie354y ezbsl484\\"><svg class=\\"ezbsl485 css-1kgp95j ek145dl0\\"><title>Earth</title><use xlink:href=\\"[object Object]#earth\\"></use></svg><span class=\\"css-8631ip ezbsl486\\"><svg class=\\"ezbsl488 css-f1ndto ek145dl0\\"><title>Spain</title><use xlink:href=\\"[object Object]#spain\\"></use></svg><svg class=\\"ezbsl488 css-f1ndto ek145dl0\\"><title>Nicaragua</title><use xlink:href=\\"[object Object]#nicaragua\\"></use></svg><svg class=\\"ezbsl488 css-f1ndto ek145dl0\\"><title>India</title><use xlink:href=\\"[object Object]#india\\"></use></svg><svg class=\\"ezbsl488 css-f1ndto ek145dl0\\"><title>Brazil</title><use xlink:href=\\"[object Object]#brazil\\"></use></svg><svg class=\\"ezbsl488 css-f1ndto ek145dl0\\"><title>China</title><use xlink:href=\\"[object Object]#china\\"></use></svg><svg class=\\"ezbsl488 css-f1ndto ek145dl0\\"><title>Austria</title><use xlink:href=\\"[object Object]#austria\\"></use></svg></span></span></div><div class=\\"css-1wbzdyy ezbsl483\\">Powered by<span class=\\"ezbsl488 css-i15wza ek145dl1\\" name=\\"verdaccio\\" title=\\"Verdaccio\\"><img alt=\\"Verdaccio\\" src=\\"[object Object]\\" class=\\"css-1ncdhax ek145dl2\\"></span>/ v.1.0.0</div></div></div>"`;
|
exports[`<Footer /> component should load the initial state of Footer component 1`] = `"<div class=\\"css-i0nj2g ezbsl480\\"><div class=\\"css-hzfs9b ezbsl481\\"><div class=\\"css-d8nsp7 ezbsl482\\"> Made with<span class=\\"css-1so4oe0 ezbsl487\\">♥</span>on<span class=\\"css-1ie354y ezbsl484\\"><svg class=\\"ezbsl485 css-tsfgle ek145dl0\\"><title>Earth</title><use xlink:href=\\"[object Object]#earth\\"></use></svg><span class=\\"css-8631ip ezbsl486\\"><svg class=\\"ezbsl488 css-13b76ay ek145dl0\\"><title>Spain</title><use xlink:href=\\"[object Object]#spain\\"></use></svg><svg class=\\"ezbsl488 css-13b76ay ek145dl0\\"><title>Nicaragua</title><use xlink:href=\\"[object Object]#nicaragua\\"></use></svg><svg class=\\"ezbsl488 css-13b76ay ek145dl0\\"><title>India</title><use xlink:href=\\"[object Object]#india\\"></use></svg><svg class=\\"ezbsl488 css-13b76ay ek145dl0\\"><title>Brazil</title><use xlink:href=\\"[object Object]#brazil\\"></use></svg><svg class=\\"ezbsl488 css-13b76ay ek145dl0\\"><title>China</title><use xlink:href=\\"[object Object]#china\\"></use></svg><svg class=\\"ezbsl488 css-13b76ay ek145dl0\\"><title>Austria</title><use xlink:href=\\"[object Object]#austria\\"></use></svg></span></span></div><div class=\\"css-1wbzdyy ezbsl483\\">Powered by<span class=\\"ezbsl488 css-i15wza ek145dl1\\" name=\\"verdaccio\\" title=\\"Verdaccio\\"><img alt=\\"Verdaccio\\" src=\\"[object Object]\\" class=\\"css-1ncdhax ek145dl2\\"></span>/ v.1.0.0</div></div></div>"`;
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ export const InnerMobileNavBar = styled('div')({
|
|||||||
backgroundColor: colors.greyLight,
|
backgroundColor: colors.greyLight,
|
||||||
color: colors.white,
|
color: colors.white,
|
||||||
width: '100%',
|
width: '100%',
|
||||||
padding: '0px 5px',
|
padding: '0 5px',
|
||||||
margin: '0 10px 0 0',
|
margin: '0 10px 0 0',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
exports[`<Icon /> component should render the component in default state 1`] = `"<svg class=\\"css-3skwlp ek145dl0\\"><title>Austria</title><use xlink:href=\\"[object Object]#austria\\"></use></svg>"`;
|
exports[`<Icon /> component should render the component in default state 1`] = `"<svg class=\\"css-snirlv ek145dl0\\"><title>Austria</title><use xlink:href=\\"[object Object]#austria\\"></use></svg>"`;
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ const getSize = (size: Breakpoint): string => {
|
|||||||
const commonStyle = ({ size = 'sm' as Breakpoint, pointer, modifiers = null }): string => css`
|
const commonStyle = ({ size = 'sm' as Breakpoint, pointer, modifiers = null }): string => css`
|
||||||
&& {
|
&& {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
cursor: ${pointer ? 'pointer' : 'default'};
|
cursor: ${pointer ? 'pointer' : 'Developers'};
|
||||||
${getSize(size)};
|
${getSize(size)};
|
||||||
${modifiers && modifiers};
|
${modifiers && modifiers};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ import List from '@material-ui/core/List';
|
|||||||
import ListItemText from '@material-ui/core/ListItemText';
|
import ListItemText from '@material-ui/core/ListItemText';
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
|
|
||||||
// @ts-ignore
|
import { DetailContextConsumer, VersionPageConsumerProps } from '../../pages/Version';
|
||||||
import { DetailContextConsumer, VersionPageConsumerProps } from '../../pages/version/Version';
|
|
||||||
import CopyToClipBoard from '../CopyToClipBoard';
|
import CopyToClipBoard from '../CopyToClipBoard';
|
||||||
|
|
||||||
// logos of package managers
|
// logos of package managers
|
||||||
|
|||||||
@@ -2,10 +2,11 @@ import Avatar from '@material-ui/core/Avatar';
|
|||||||
import ListItem from '@material-ui/core/ListItem';
|
import ListItem from '@material-ui/core/ListItem';
|
||||||
import Typography from '@material-ui/core/Typography';
|
import Typography from '@material-ui/core/Typography';
|
||||||
import styled from 'react-emotion';
|
import styled from 'react-emotion';
|
||||||
|
import { fontWeight } from '../../utils/styles/sizes';
|
||||||
|
|
||||||
export const Heading = styled(Typography)({
|
export const Heading = styled(Typography)({
|
||||||
'&&': {
|
'&&': {
|
||||||
fontWeight: 700,
|
fontWeight: fontWeight.bold,
|
||||||
textTransform: 'capitalize',
|
textTransform: 'capitalize',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
import styled, { css } from 'react-emotion';
|
import styled, { css } from 'react-emotion';
|
||||||
|
import colors from '../../utils/styles/colors';
|
||||||
|
|
||||||
export const Content = styled('div')({
|
export const Content = styled('div')({
|
||||||
'&&': {
|
'&&': {
|
||||||
backgroundColor: '#ffffff',
|
backgroundColor: colors.white,
|
||||||
flex: 1,
|
flex: 1,
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
position: 'relative',
|
position: 'relative',
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import Spinner from '../Spinner';
|
|||||||
import { Wrapper, Badge } from './styles';
|
import { Wrapper, Badge } from './styles';
|
||||||
|
|
||||||
const Loading: React.FC = () => (
|
const Loading: React.FC = () => (
|
||||||
<Wrapper>
|
<Wrapper data-testid="loading">
|
||||||
<Badge>
|
<Badge>
|
||||||
<Logo size={Size.Big} />
|
<Logo size={Size.Big} />
|
||||||
</Badge>
|
</Badge>
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
exports[`<Loading /> component should render the component in default state 1`] = `"<div class=\\"css-1221txa eimgwje0\\"><div class=\\"css-bxochs eimgwje1\\"><div class=\\"css-ge0nak em793ed0\\"></div></div><div class=\\"css-vqrgi e1ag4h8b0\\"><div class=\\"MuiCircularProgress-root-1 MuiCircularProgress-colorPrimary-4 MuiCircularProgress-indeterminate-3 css-15gl0ho e1ag4h8b1\\" style=\\"width:50px;height:50px\\" role=\\"progressbar\\"><svg class=\\"MuiCircularProgress-svg-6\\" viewBox=\\"22 22 44 44\\"><circle class=\\"MuiCircularProgress-circle-7 MuiCircularProgress-circleIndeterminate-9\\" cx=\\"44\\" cy=\\"44\\" r=\\"20.2\\" fill=\\"none\\" stroke-width=\\"3.6\\"></circle></svg></div></div></div>"`;
|
exports[`<Loading /> component should render the component in default state 1`] = `"<div data-testid=\\"loading\\" class=\\"css-1221txa eimgwje0\\"><div class=\\"css-bxochs eimgwje1\\"><div class=\\"css-ge0nak em793ed0\\"></div></div><div class=\\"css-vqrgi e1ag4h8b0\\"><div class=\\"MuiCircularProgress-root-1 MuiCircularProgress-colorPrimary-4 MuiCircularProgress-indeterminate-3 css-15gl0ho e1ag4h8b1\\" style=\\"width:50px;height:50px\\" role=\\"progressbar\\"><svg class=\\"MuiCircularProgress-svg-6\\" viewBox=\\"22 22 44 44\\"><circle class=\\"MuiCircularProgress-circle-7 MuiCircularProgress-circleIndeterminate-9\\" cx=\\"44\\" cy=\\"44\\" r=\\"20.2\\" fill=\\"none\\" stroke-width=\\"3.6\\"></circle></svg></div></div></div>"`;
|
||||||
|
|||||||
@@ -1,46 +1,43 @@
|
|||||||
import ListItem from '@material-ui/core/ListItem';
|
import ListItem from '@material-ui/core/ListItem';
|
||||||
import Typography from '@material-ui/core/Typography';
|
import Typography from '@material-ui/core/Typography';
|
||||||
import withWidth, { isWidthUp } from '@material-ui/core/withWidth';
|
import withWidth, { isWidthUp } from '@material-ui/core/withWidth';
|
||||||
import React from 'react';
|
import React, { useCallback } from 'react';
|
||||||
import { RouteComponentProps, withRouter } from 'react-router-dom';
|
import { RouteComponentProps, withRouter } from 'react-router-dom';
|
||||||
|
|
||||||
import PackageImg from './img/package.svg';
|
import PackageImg from './img/package.svg';
|
||||||
import { Card, EmptyPackage, Heading, Inner, List, Wrapper } from './styles';
|
import { Card, EmptyPackage, Heading, Inner, List, Wrapper } from './styles';
|
||||||
import { Breakpoint } from '@material-ui/core/styles/createBreakpoints';
|
import { Breakpoint } from '@material-ui/core/styles/createBreakpoints';
|
||||||
|
|
||||||
export const NOT_FOUND_TEXT = "Sorry, we couldn't find it...";
|
export const NOT_FOUND_TEXT = `Sorry, we couldn't find it...`;
|
||||||
|
export const LABEL_NOT_FOUND = `The page you're looking for doesn't exist.`;
|
||||||
|
export const LABEL_FOOTER_NOT_FOUND = 'Perhaps these links will help find what you are looking for:';
|
||||||
|
|
||||||
export type NotFoundProps = RouteComponentProps & { width: Breakpoint; history };
|
export type NotFoundProps = RouteComponentProps & { width: Breakpoint; history };
|
||||||
|
|
||||||
const NotFound: React.FC<NotFoundProps> = ({ history, width }) => {
|
const HOME_LABEL = 'Home';
|
||||||
const handleGoTo = (to: string): (() => void | undefined) => () => {
|
|
||||||
history.push(to);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleGoBack = (): ((e: React.MouseEvent<HTMLElement, MouseEvent>) => void | undefined) => () => {
|
const renderSubTitle = (): JSX.Element => (
|
||||||
history.goBack();
|
<Typography variant="subtitle1">
|
||||||
};
|
<div>{LABEL_NOT_FOUND}</div>
|
||||||
|
<div>{LABEL_FOOTER_NOT_FOUND}</div>
|
||||||
|
</Typography>
|
||||||
|
);
|
||||||
|
|
||||||
|
const NotFound: React.FC<NotFoundProps> = ({ history, width }) => {
|
||||||
|
const handleGomHome = useCallback(() => {
|
||||||
|
history.push('/');
|
||||||
|
}, [history]);
|
||||||
|
|
||||||
const renderList = (): JSX.Element => (
|
const renderList = (): JSX.Element => (
|
||||||
<List>
|
<List>
|
||||||
<ListItem button={true} divider={true} onClick={handleGoTo('/')}>
|
<ListItem button={true} divider={true} onClick={handleGomHome}>
|
||||||
{'Home'}
|
{HOME_LABEL}
|
||||||
</ListItem>
|
|
||||||
<ListItem button={true} divider={true} onClick={handleGoBack()}>
|
|
||||||
{'Back'}
|
|
||||||
</ListItem>
|
</ListItem>
|
||||||
</List>
|
</List>
|
||||||
);
|
);
|
||||||
|
|
||||||
const renderSubTitle = (): JSX.Element => (
|
|
||||||
<Typography variant="subtitle1">
|
|
||||||
<div>{"The page you're looking for doesn't exist."}</div>
|
|
||||||
<div>{'Perhaps these links will help find what you are looking for:'}</div>
|
|
||||||
</Typography>
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Wrapper>
|
<Wrapper data-testid="404">
|
||||||
<Inner>
|
<Inner>
|
||||||
<EmptyPackage alt="404 - Page not found" src={PackageImg} />
|
<EmptyPackage alt="404 - Page not found" src={PackageImg} />
|
||||||
<Heading className="not-found-text" variant={isWidthUp('sm', width) ? 'h2' : 'h4'}>
|
<Heading className="not-found-text" variant={isWidthUp('sm', width) ? 'h2' : 'h4'}>
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import { breakpoints } from '../../utils/styles/media';
|
|||||||
import Ico from '../Icon';
|
import Ico from '../Icon';
|
||||||
import Label from '../Label';
|
import Label from '../Label';
|
||||||
import colors from '../../utils/styles/colors';
|
import colors from '../../utils/styles/colors';
|
||||||
|
import { fontWeight } from '../../utils/styles/sizes';
|
||||||
|
|
||||||
export const OverviewItem = styled('span')`
|
export const OverviewItem = styled('span')`
|
||||||
&& {
|
&& {
|
||||||
@@ -36,7 +37,7 @@ export const OverviewItem = styled('span')`
|
|||||||
|
|
||||||
export const Icon = styled(Ico)({
|
export const Icon = styled(Ico)({
|
||||||
'&&': {
|
'&&': {
|
||||||
margin: '2px 10px 0px 0',
|
margin: '2px 10px 0 0',
|
||||||
fill: colors.greyLight2,
|
fill: colors.greyLight2,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -44,7 +45,7 @@ export const Icon = styled(Ico)({
|
|||||||
export const Published = styled('span')({
|
export const Published = styled('span')({
|
||||||
'&&': {
|
'&&': {
|
||||||
color: colors.greyLight2,
|
color: colors.greyLight2,
|
||||||
margin: '0px 5px 0px 0px',
|
margin: '0 5px 0 0',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -52,7 +53,7 @@ export const Published = styled('span')({
|
|||||||
export const Text = styled(Label)({
|
export const Text = styled(Label)({
|
||||||
'&&': {
|
'&&': {
|
||||||
fontSize: '12px',
|
fontSize: '12px',
|
||||||
fontWeight: 500,
|
fontWeight: fontWeight.semiBold,
|
||||||
color: colors.greyLight2,
|
color: colors.greyLight2,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,11 +1,68 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { shallow } from 'enzyme';
|
import { shallow } from 'enzyme';
|
||||||
|
|
||||||
import Repository from './Repository';
|
jest.mock('./img/git.png', () => '');
|
||||||
|
|
||||||
describe('<Repository /> component', () => {
|
describe('<Repository /> component', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
jest.resetModules();
|
||||||
|
});
|
||||||
|
|
||||||
test('should render the component in default state', () => {
|
test('should render the component in default state', () => {
|
||||||
|
const packageMeta = {
|
||||||
|
latest: {
|
||||||
|
repository: {
|
||||||
|
type: 'git',
|
||||||
|
url: 'git+https://github.com/verdaccio/ui.git',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
jest.doMock('../../pages/Version', () => ({
|
||||||
|
DetailContextConsumer: component => {
|
||||||
|
return component.children({ packageMeta });
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
const Repository = require('./Repository').default;
|
||||||
const wrapper = shallow(<Repository />);
|
const wrapper = shallow(<Repository />);
|
||||||
expect(wrapper.html()).toMatchSnapshot();
|
expect(wrapper.html()).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should render the component in with no repository data', () => {
|
||||||
|
const packageMeta = {
|
||||||
|
latest: {},
|
||||||
|
};
|
||||||
|
|
||||||
|
jest.doMock('../../pages/Version', () => ({
|
||||||
|
DetailContextConsumer: component => {
|
||||||
|
return component.children({ packageMeta });
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
const Repository = require('./Repository').default;
|
||||||
|
const wrapper = shallow(<Repository />);
|
||||||
|
expect(wrapper.html()).toEqual('');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should render the component in with invalid url', () => {
|
||||||
|
const packageMeta = {
|
||||||
|
latest: {
|
||||||
|
repository: {
|
||||||
|
type: 'git',
|
||||||
|
url: 'git://github.com/verdaccio/ui.git',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
jest.doMock('../../pages/Version', () => ({
|
||||||
|
DetailContextConsumer: component => {
|
||||||
|
return component.children({ packageMeta });
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
const Repository = require('./Repository').default;
|
||||||
|
const wrapper = shallow(<Repository />);
|
||||||
|
expect(wrapper.html()).toEqual('');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import Avatar from '@material-ui/core/Avatar';
|
|||||||
import List from '@material-ui/core/List';
|
import List from '@material-ui/core/List';
|
||||||
import ListItemText from '@material-ui/core/ListItemText';
|
import ListItemText from '@material-ui/core/ListItemText';
|
||||||
|
|
||||||
import { DetailContextConsumer } from '../../pages/version/Version';
|
import { DetailContextConsumer } from '../../pages/Version';
|
||||||
import CopyToClipBoard from '../CopyToClipBoard';
|
import CopyToClipBoard from '../CopyToClipBoard';
|
||||||
|
|
||||||
import { Heading, GithubLink, RepositoryListItem } from './styles';
|
import { Heading, GithubLink, RepositoryListItem } from './styles';
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
exports[`<Repository /> component should render the component in default state 1`] = `""`;
|
exports[`<Repository /> component should render the component in default state 1`] = `"<ul class=\\"MuiList-root-1 MuiList-dense-3 MuiList-padding-2 MuiList-subheader-4\\"><h3 class=\\"MuiTypography-root-5 MuiTypography-subheading-12 css-hyrz44 e1wmjxnh0\\">Repository</h3><li class=\\"MuiListItem-root-41 MuiListItem-default-44 MuiListItem-dense-45 MuiListItem-gutters-49 css-z8a2h0 e1wmjxnh4\\"><div class=\\"MuiAvatar-root-53 MuiAvatar-colorDefault-54\\"></div><div class=\\"MuiListItemText-root-56 MuiListItemText-dense-58\\"><span class=\\"MuiTypography-root-5 MuiTypography-subheading-12 MuiListItemText-primary-59 MuiListItemText-textDense-61\\"><div class=\\"css-1mta3t8 eb8w2fo0\\"><span class=\\"css-1m8aenu eb8w2fo1\\"><a href=\\"git+https://github.com/verdaccio/ui.git\\" target=\\"_blank\\" class=\\"css-15gl0ho e1wmjxnh2\\">git+https://github.com/verdaccio/ui.git</a></span><button class=\\"MuiButtonBase-root-76 MuiIconButton-root-70 css-56v3u0 eb8w2fo2\\" tabindex=\\"0\\" type=\\"button\\" title=\\"Copy to Clipboard\\"><span class=\\"MuiIconButton-label-75\\"><svg class=\\"MuiSvgIcon-root-79\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path fill=\\"none\\" d=\\"M0 0h24v24H0z\\"></path><path d=\\"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm-1 4l6 6v10c0 1.1-.9 2-2 2H7.99C6.89 23 6 22.1 6 21l.01-14c0-1.1.89-2 1.99-2h7zm-1 7h5.5L14 6.5V12z\\"></path></svg></span></button></div></span></div></li></ul>"`;
|
||||||
|
|||||||
@@ -5,10 +5,11 @@ import Typography from '@material-ui/core/Typography';
|
|||||||
|
|
||||||
import Github from '../../icons/GitHub';
|
import Github from '../../icons/GitHub';
|
||||||
import colors from '../../utils/styles/colors';
|
import colors from '../../utils/styles/colors';
|
||||||
|
import { fontWeight } from '../../utils/styles/sizes';
|
||||||
|
|
||||||
export const Heading = styled(Typography)({
|
export const Heading = styled(Typography)({
|
||||||
'&&': {
|
'&&': {
|
||||||
fontWeight: 700,
|
fontWeight: fontWeight.bold,
|
||||||
textTransform: 'capitalize',
|
textTransform: 'capitalize',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { BrowserRouter } from 'react-router-dom';
|
|||||||
import Search from './Search';
|
import Search from './Search';
|
||||||
|
|
||||||
const SEARCH_FILE_PATH = './Search';
|
const SEARCH_FILE_PATH = './Search';
|
||||||
const API_FILE_PATH = '../../utils/api';
|
const API_FILE_PATH = '../../utils/calls';
|
||||||
const URL_FILE_PATH = '../../utils/url';
|
const URL_FILE_PATH = '../../utils/url';
|
||||||
|
|
||||||
// Global mocks
|
// Global mocks
|
||||||
@@ -165,8 +165,7 @@ describe('<Search /> component test', () => {
|
|||||||
const suggestions = [{ name: 'verdaccio' }, { name: 'verdaccio-htpasswd' }];
|
const suggestions = [{ name: 'verdaccio' }, { name: 'verdaccio-htpasswd' }];
|
||||||
|
|
||||||
jest.doMock(API_FILE_PATH, () => ({
|
jest.doMock(API_FILE_PATH, () => ({
|
||||||
request(url: string) {
|
callSearch(url: string) {
|
||||||
expect(url).toEqual('search/verdaccio');
|
|
||||||
return Promise.resolve(apiResponse);
|
return Promise.resolve(apiResponse);
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
@@ -194,7 +193,7 @@ describe('<Search /> component test', () => {
|
|||||||
test('handleFetchPackages: when browser cancel a request', async () => {
|
test('handleFetchPackages: when browser cancel a request', async () => {
|
||||||
const apiResponse = { name: 'AbortError' };
|
const apiResponse = { name: 'AbortError' };
|
||||||
|
|
||||||
jest.doMock(API_FILE_PATH, () => ({ request: jest.fn(() => Promise.reject(apiResponse)) }));
|
jest.doMock(API_FILE_PATH, () => ({ callSearch: jest.fn(() => Promise.reject(apiResponse)) }));
|
||||||
|
|
||||||
const Search = require(SEARCH_FILE_PATH).Search;
|
const Search = require(SEARCH_FILE_PATH).Search;
|
||||||
|
|
||||||
@@ -219,8 +218,7 @@ describe('<Search /> component test', () => {
|
|||||||
const apiResponse = { name: 'BAD_REQUEST' };
|
const apiResponse = { name: 'BAD_REQUEST' };
|
||||||
|
|
||||||
jest.doMock(API_FILE_PATH, () => ({
|
jest.doMock(API_FILE_PATH, () => ({
|
||||||
request(url) {
|
callSearch(url) {
|
||||||
expect(url).toEqual('search/verdaccio');
|
|
||||||
return Promise.reject(apiResponse);
|
return Promise.reject(apiResponse);
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ import { default as IconSearch } from '@material-ui/icons/Search';
|
|||||||
import InputAdornment from '@material-ui/core/InputAdornment';
|
import InputAdornment from '@material-ui/core/InputAdornment';
|
||||||
import debounce from 'lodash/debounce';
|
import debounce from 'lodash/debounce';
|
||||||
|
|
||||||
import API from '../../utils/api';
|
|
||||||
import AutoComplete from '../AutoComplete';
|
import AutoComplete from '../AutoComplete';
|
||||||
import colors from '../../utils/styles/colors';
|
import colors from '../../utils/styles/colors';
|
||||||
|
import { callSearch } from '../../utils/calls';
|
||||||
|
|
||||||
export interface State {
|
export interface State {
|
||||||
search: string;
|
search: string;
|
||||||
@@ -148,7 +148,7 @@ export class Search extends Component<RouteComponentProps<{}>, State> {
|
|||||||
const signal = controller.signal;
|
const signal = controller.signal;
|
||||||
// Keep track of search requests.
|
// Keep track of search requests.
|
||||||
this.requestList.push(controller);
|
this.requestList.push(controller);
|
||||||
const suggestions = await API.request(`search/${encodeURIComponent(value)}`, 'GET', { signal });
|
const suggestions = await callSearch(value, signal);
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
this.setState({
|
this.setState({
|
||||||
suggestions,
|
suggestions,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import React, { ReactElement } from 'react';
|
|||||||
import List from '@material-ui/core/List';
|
import List from '@material-ui/core/List';
|
||||||
import ListItem from '@material-ui/core/ListItem';
|
import ListItem from '@material-ui/core/ListItem';
|
||||||
|
|
||||||
import { DetailContextConsumer } from '../../pages/version/Version';
|
import { DetailContextConsumer } from '../../pages/Version';
|
||||||
import NoItems from '../NoItems';
|
import NoItems from '../NoItems';
|
||||||
import { formatDateDistance } from '../../utils/package';
|
import { formatDateDistance } from '../../utils/package';
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import styled from 'react-emotion';
|
import styled from 'react-emotion';
|
||||||
import Typography from '@material-ui/core/Typography';
|
import Typography from '@material-ui/core/Typography';
|
||||||
import { default as MuiListItemText } from '@material-ui/core/ListItemText';
|
import { default as MuiListItemText } from '@material-ui/core/ListItemText';
|
||||||
|
import { fontWeight } from '../../utils/styles/sizes';
|
||||||
|
|
||||||
export const Heading = styled(Typography)({
|
export const Heading = styled(Typography)({
|
||||||
'&&': {
|
'&&': {
|
||||||
fontWeight: 700,
|
fontWeight: fontWeight.bold,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,42 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { shallow } from 'enzyme';
|
import { shallow } from 'enzyme';
|
||||||
|
|
||||||
import Versions from './Versions';
|
describe('<Version /> component', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
jest.resetModules();
|
||||||
|
});
|
||||||
|
|
||||||
describe('<Versions /> component', () => {
|
|
||||||
test('should render the component in default state', () => {
|
test('should render the component in default state', () => {
|
||||||
const wrapper = shallow(<Versions />);
|
const packageMeta = {
|
||||||
|
versions: {
|
||||||
|
'1.0.0': {
|
||||||
|
version: '1.0.0',
|
||||||
|
},
|
||||||
|
'2.0.0': {
|
||||||
|
version: '2.0.0',
|
||||||
|
},
|
||||||
|
'3.0.0': {
|
||||||
|
version: '3.0.0',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
time: {
|
||||||
|
'1.0.0': '2016-08-26T22:36:41.762Z',
|
||||||
|
'2.0.0': '2017-08-26T22:36:41.762Z',
|
||||||
|
'3.0.0': '2018-02-07T06:43:22.801Z',
|
||||||
|
},
|
||||||
|
'dist-tags': {
|
||||||
|
latest: '3.0.0',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
jest.doMock('../../pages/Version', () => ({
|
||||||
|
DetailContextConsumer: component => {
|
||||||
|
return component.children({ packageMeta });
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
const Version = require('./Versions').default;
|
||||||
|
const wrapper = shallow(<Version />);
|
||||||
expect(wrapper.html()).toMatchSnapshot();
|
expect(wrapper.html()).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import { DetailContextConsumer } from '../../pages/version/Version';
|
import React, { ReactElement } from 'react';
|
||||||
import { formatDateDistance } from '../../utils/package';
|
|
||||||
import { Heading, Spacer, ListItemText } from './styles';
|
|
||||||
import List from '@material-ui/core/List';
|
import List from '@material-ui/core/List';
|
||||||
import ListItem from '@material-ui/core/ListItem';
|
import ListItem from '@material-ui/core/ListItem';
|
||||||
import React, { ReactElement } from 'react';
|
|
||||||
|
import { DetailContextConsumer } from '../../pages/Version';
|
||||||
|
import { formatDateDistance } from '../../utils/package';
|
||||||
import { DIST_TAGS } from '../../../lib/constants';
|
import { DIST_TAGS } from '../../../lib/constants';
|
||||||
|
import { Heading, Spacer, ListItemText } from './styles';
|
||||||
|
|
||||||
const NOT_AVAILABLE = 'Not available';
|
const NOT_AVAILABLE = 'Not available';
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
exports[`<Versions /> component should render the component in default state 1`] = `""`;
|
exports[`<Version /> component should render the component in default state 1`] = `"<h3 class=\\"MuiTypography-root-1 MuiTypography-subheading-8 css-1ikpjfo e1h4if9v0\\">Current Tags</h3><ul class=\\"MuiList-root-37 MuiList-padding-38\\"><li class=\\"MuiListItem-root-41 MuiListItem-default-44 MuiListItem-gutters-49 version-item\\"><div class=\\"MuiListItemText-root-53 css-5tz9yo e1h4if9v2\\"><span class=\\"MuiTypography-root-1 MuiTypography-subheading-8 MuiListItemText-primary-56\\">latest</span></div><div class=\\"css-1l1cv61 e1h4if9v1\\"></div><div class=\\"MuiListItemText-root-53 css-5tz9yo e1h4if9v2\\"><span class=\\"MuiTypography-root-1 MuiTypography-subheading-8 MuiListItemText-primary-56\\">3.0.0</span></div></li></ul><h3 class=\\"MuiTypography-root-1 MuiTypography-subheading-8 css-1ikpjfo e1h4if9v0\\">Version History</h3><ul class=\\"MuiList-root-37 MuiList-padding-38\\"><li class=\\"MuiListItem-root-41 MuiListItem-default-44 MuiListItem-gutters-49 version-item\\"><div class=\\"MuiListItemText-root-53 css-5tz9yo e1h4if9v2\\"><span class=\\"MuiTypography-root-1 MuiTypography-subheading-8 MuiListItemText-primary-56\\">3.0.0</span></div><div class=\\"css-1l1cv61 e1h4if9v1\\"></div><div class=\\"MuiListItemText-root-53 css-5tz9yo e1h4if9v2\\"><span class=\\"MuiTypography-root-1 MuiTypography-subheading-8 MuiListItemText-primary-56\\">over 1 year ago</span></div></li><li class=\\"MuiListItem-root-41 MuiListItem-default-44 MuiListItem-gutters-49 version-item\\"><div class=\\"MuiListItemText-root-53 css-5tz9yo e1h4if9v2\\"><span class=\\"MuiTypography-root-1 MuiTypography-subheading-8 MuiListItemText-primary-56\\">2.0.0</span></div><div class=\\"css-1l1cv61 e1h4if9v1\\"></div><div class=\\"MuiListItemText-root-53 css-5tz9yo e1h4if9v2\\"><span class=\\"MuiTypography-root-1 MuiTypography-subheading-8 MuiListItemText-primary-56\\">almost 2 years ago</span></div></li><li class=\\"MuiListItem-root-41 MuiListItem-default-44 MuiListItem-gutters-49 version-item\\"><div class=\\"MuiListItemText-root-53 css-5tz9yo e1h4if9v2\\"><span class=\\"MuiTypography-root-1 MuiTypography-subheading-8 MuiListItemText-primary-56\\">1.0.0</span></div><div class=\\"css-1l1cv61 e1h4if9v1\\"></div><div class=\\"MuiListItemText-root-53 css-5tz9yo e1h4if9v2\\"><span class=\\"MuiTypography-root-1 MuiTypography-subheading-8 MuiListItemText-primary-56\\">almost 3 years ago</span></div></li></ul>"`;
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import styled from 'react-emotion';
|
import styled from 'react-emotion';
|
||||||
import Typography from '@material-ui/core/Typography';
|
import Typography from '@material-ui/core/Typography';
|
||||||
import { default as MuiListItemText } from '@material-ui/core/ListItemText';
|
import { default as MuiListItemText } from '@material-ui/core/ListItemText';
|
||||||
|
import { fontWeight } from '../../utils/styles/sizes';
|
||||||
|
|
||||||
export const Heading = styled(Typography)({
|
export const Heading = styled(Typography)({
|
||||||
'&&': {
|
'&&': {
|
||||||
fontWeight: 700,
|
fontWeight: fontWeight.bold,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
27
src/pages/Version/Layout.tsx
Normal file
27
src/pages/Version/Layout.tsx
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
import React, { FC, ReactElement } from 'react';
|
||||||
|
import Grid from '@material-ui/core/Grid';
|
||||||
|
import DetailContainer from '../../components/DetailContainer';
|
||||||
|
import DetailSidebar from '../../components/DetailSidebar';
|
||||||
|
|
||||||
|
function renderDetail(): ReactElement<HTMLElement> {
|
||||||
|
return <DetailContainer />;
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderSidebar(): ReactElement<HTMLElement> {
|
||||||
|
return <DetailSidebar />;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Layout: FC<{}> = () => {
|
||||||
|
return (
|
||||||
|
<Grid className={'container content'} container={true} data-testid="version-layout" spacing={0}>
|
||||||
|
<Grid item={true} xs={8}>
|
||||||
|
{renderDetail()}
|
||||||
|
</Grid>
|
||||||
|
<Grid item={true} xs={4}>
|
||||||
|
{renderSidebar()}
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export { Layout };
|
||||||
97
src/pages/Version/Version.test.tsx
Normal file
97
src/pages/Version/Version.test.tsx
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { render, cleanup } from '@testing-library/react';
|
||||||
|
|
||||||
|
import { MemoryRouter } from 'react-router';
|
||||||
|
|
||||||
|
import vueMetadata from '../../../test/fixtures/metadata/vue.json';
|
||||||
|
|
||||||
|
import Version from './Version';
|
||||||
|
import { waitForElement } from '@testing-library/dom';
|
||||||
|
import ErrorBoundary from '../../App/AppError';
|
||||||
|
import { LABEL_NOT_FOUND } from '../../components/NotFound/NotFound';
|
||||||
|
|
||||||
|
// :-) we mock this otherways fails on render, some weird issue on material-ui
|
||||||
|
jest.mock('@material-ui/core/Avatar');
|
||||||
|
|
||||||
|
describe('test Version page', () => {
|
||||||
|
beforeAll(() => {
|
||||||
|
// FIXME: a better way to mock this
|
||||||
|
// @ts-ignore
|
||||||
|
global.window.VERDACCIO_API_URL = 'http://test';
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
cleanup();
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
jest.resetAllMocks();
|
||||||
|
// @ts-ignore
|
||||||
|
fetch.resetMocks();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should render the version page', async () => {
|
||||||
|
const readmeText = 'test';
|
||||||
|
// @ts-ignore
|
||||||
|
fetch.mockResponses(
|
||||||
|
[[JSON.stringify(vueMetadata)], { status: 200, headers: { 'content-type': 'application/json' } }],
|
||||||
|
[[`<p align="center">${readmeText}</p>`], { status: 200, headers: { 'content-type': 'text/html' } }]
|
||||||
|
);
|
||||||
|
|
||||||
|
const { getByTestId, getByText } = render(
|
||||||
|
<ErrorBoundary>
|
||||||
|
<MemoryRouter>
|
||||||
|
<Version match={{ params: { ['package']: 'vue' } }}></Version>
|
||||||
|
</MemoryRouter>
|
||||||
|
</ErrorBoundary>
|
||||||
|
);
|
||||||
|
|
||||||
|
// first it display loading
|
||||||
|
const hasLoading = getByTestId('loading');
|
||||||
|
expect(hasLoading).toBeTruthy();
|
||||||
|
|
||||||
|
// we wait fetch response (mocked above)
|
||||||
|
await waitForElement(() => getByTestId('version-layout'));
|
||||||
|
|
||||||
|
// check whether readme was loaded
|
||||||
|
const hasReadme = getByText(readmeText);
|
||||||
|
|
||||||
|
expect(hasReadme).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should render 404 page if the resources are not found', async () => {
|
||||||
|
// @ts-ignore
|
||||||
|
fetch.mockResponses(
|
||||||
|
[[JSON.stringify({})], { status: 404, headers: { 'content-type': 'application/json' } }],
|
||||||
|
[[``], { status: 404, headers: { 'content-type': 'text/html' } }]
|
||||||
|
);
|
||||||
|
|
||||||
|
const { getByTestId, getByText } = render(
|
||||||
|
<ErrorBoundary>
|
||||||
|
<MemoryRouter>
|
||||||
|
<Version match={{ params: { ['package']: 'vue' } }}></Version>
|
||||||
|
</MemoryRouter>
|
||||||
|
</ErrorBoundary>
|
||||||
|
);
|
||||||
|
|
||||||
|
// first it display loading
|
||||||
|
const hasLoading = getByTestId('loading');
|
||||||
|
expect(hasLoading).toBeTruthy();
|
||||||
|
|
||||||
|
// we wait fetch response (mocked above)
|
||||||
|
await waitForElement(() => getByTestId('404'));
|
||||||
|
|
||||||
|
// check whether readme was loaded
|
||||||
|
const hasReadme = getByText(LABEL_NOT_FOUND);
|
||||||
|
|
||||||
|
expect(hasReadme).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Wanna contribute? Here we some scenarios we need to test
|
||||||
|
|
||||||
|
test.todo('should test click on tabs');
|
||||||
|
test.todo('should check what is rendered int he sidebar is correct');
|
||||||
|
test.todo('should test click back home on 404');
|
||||||
|
test.todo('should test click on elements in the sidebar');
|
||||||
|
test.todo('should test other not consider scenarios');
|
||||||
|
});
|
||||||
69
src/pages/Version/Version.tsx
Normal file
69
src/pages/Version/Version.tsx
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
import React, { useEffect, useState } from 'react';
|
||||||
|
|
||||||
|
import { callDetailPage, callReadme } from '../../utils/calls';
|
||||||
|
import { buildScopePackage } from '../../utils/package';
|
||||||
|
import Loading from '../../components/Loading/Loading';
|
||||||
|
import NotFound from '../../components/NotFound';
|
||||||
|
|
||||||
|
import { Layout } from './Layout';
|
||||||
|
import { DetailContextProvider } from './context';
|
||||||
|
import { StateInterface } from './types';
|
||||||
|
|
||||||
|
export function getRouterPackageName(params): string {
|
||||||
|
const packageName = params.package;
|
||||||
|
const { scope } = params;
|
||||||
|
if (scope) {
|
||||||
|
return buildScopePackage(scope, packageName);
|
||||||
|
}
|
||||||
|
|
||||||
|
return packageName;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Version = ({ match: { params } }) => {
|
||||||
|
const pkgName = getRouterPackageName(params);
|
||||||
|
const [readMe, setReadme] = useState();
|
||||||
|
const [packageName, setPackageName] = useState(pkgName);
|
||||||
|
const [packageMeta, setPackageMeta] = useState();
|
||||||
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
|
const [notFound, setNotFound] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
(async () => {
|
||||||
|
try {
|
||||||
|
const packageMeta = (await callDetailPage(packageName)) as Partial<StateInterface>;
|
||||||
|
const readMe = (await callReadme(packageName)) as Partial<StateInterface>;
|
||||||
|
setReadme(readMe);
|
||||||
|
setPackageMeta(packageMeta);
|
||||||
|
setIsLoading(false);
|
||||||
|
} catch (error) {
|
||||||
|
setNotFound(true);
|
||||||
|
setIsLoading(false);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
}, [packageName]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
document.title = `Verdaccio - ${packageName}`;
|
||||||
|
}, [packageName]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const pkgName = getRouterPackageName(params);
|
||||||
|
|
||||||
|
setPackageName(pkgName);
|
||||||
|
}, [params]);
|
||||||
|
|
||||||
|
const isNotFound = notFound || typeof packageMeta === 'undefined' || typeof packageName === 'undefined' || typeof readMe === 'undefined';
|
||||||
|
const renderContent = (): React.ReactElement<HTMLElement> => {
|
||||||
|
if (isLoading) {
|
||||||
|
return <Loading />;
|
||||||
|
} else if (isNotFound) {
|
||||||
|
return <NotFound />;
|
||||||
|
} else {
|
||||||
|
return <Layout />;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return <DetailContextProvider value={{ packageMeta, readMe, packageName, enableLoading: setIsLoading }}>{renderContent()}</DetailContextProvider>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Version;
|
||||||
7
src/pages/Version/context.ts
Normal file
7
src/pages/Version/context.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
import React, { Consumer, Provider } from 'react';
|
||||||
|
import { DetailContextProps, VersionPageConsumerProps } from './types';
|
||||||
|
|
||||||
|
export const DetailContext = React.createContext<Partial<DetailContextProps>>({});
|
||||||
|
|
||||||
|
export const DetailContextProvider: Provider<Partial<VersionPageConsumerProps>> = DetailContext.Provider;
|
||||||
|
export const DetailContextConsumer: Consumer<Partial<VersionPageConsumerProps>> = DetailContext.Consumer;
|
||||||
3
src/pages/Version/index.ts
Normal file
3
src/pages/Version/index.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
export { DetailContextProps, VersionPageConsumerProps } from './types';
|
||||||
|
export { DetailContext, DetailContextConsumer, DetailContextProvider } from './context';
|
||||||
|
export { default } from './Version';
|
||||||
28
src/pages/Version/types.ts
Normal file
28
src/pages/Version/types.ts
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
import { PackageMetaInterface } from '../../../types/packageMeta';
|
||||||
|
|
||||||
|
export interface DetailContextProps {
|
||||||
|
packageMeta: PackageMetaInterface;
|
||||||
|
readMe: string;
|
||||||
|
packageName: string;
|
||||||
|
enableLoading: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface VersionPageConsumerProps {
|
||||||
|
packageMeta: PackageMetaInterface;
|
||||||
|
readMe: string;
|
||||||
|
packageName: string;
|
||||||
|
// FIXME: looking for the appropiated type here
|
||||||
|
enableLoading: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PropsInterface {
|
||||||
|
match: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface StateInterface {
|
||||||
|
readMe: string;
|
||||||
|
packageName: string;
|
||||||
|
packageMeta?: PackageMetaInterface;
|
||||||
|
isLoading: boolean;
|
||||||
|
notFound: boolean;
|
||||||
|
}
|
||||||
@@ -1,160 +0,0 @@
|
|||||||
import React, { Component, ReactElement, Consumer, Provider } from 'react';
|
|
||||||
import Grid from '@material-ui/core/Grid';
|
|
||||||
import Loading from '../../components/Loading/Loading';
|
|
||||||
import DetailContainer from '../../components/DetailContainer/DetailContainer';
|
|
||||||
import DetailSidebar from '../../components/DetailSidebar/DetailSidebar';
|
|
||||||
import { callDetailPage } from '../../utils/calls';
|
|
||||||
import { getRouterPackageName } from '../../utils/package';
|
|
||||||
import NotFound from '../../components/NotFound';
|
|
||||||
import { PackageMetaInterface } from '../../../types/packageMeta';
|
|
||||||
|
|
||||||
export interface DetailContextProps {
|
|
||||||
packageMeta: PackageMetaInterface;
|
|
||||||
readMe: string;
|
|
||||||
packageName: string;
|
|
||||||
enableLoading: () => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const DetailContext = React.createContext<Partial<DetailContextProps>>({});
|
|
||||||
|
|
||||||
export interface VersionPageConsumerProps {
|
|
||||||
packageMeta: PackageMetaInterface;
|
|
||||||
readMe: string;
|
|
||||||
packageName: string;
|
|
||||||
enableLoading: () => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const DetailContextProvider: Provider<Partial<VersionPageConsumerProps>> = DetailContext.Provider;
|
|
||||||
export const DetailContextConsumer: Consumer<Partial<VersionPageConsumerProps>> = DetailContext.Consumer;
|
|
||||||
|
|
||||||
interface PropsInterface {
|
|
||||||
match: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface StateInterface {
|
|
||||||
readMe: string;
|
|
||||||
packageName: string;
|
|
||||||
packageMeta: PackageMetaInterface | null;
|
|
||||||
isLoading: boolean;
|
|
||||||
notFound: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
class VersionPage extends Component<PropsInterface, Partial<StateInterface>> {
|
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
|
|
||||||
this.state = {
|
|
||||||
readMe: '',
|
|
||||||
packageName: getRouterPackageName(props.match),
|
|
||||||
packageMeta: null,
|
|
||||||
isLoading: true,
|
|
||||||
notFound: false,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public static getDerivedStateFromProps(nextProps, prevState): { packageName?: string; isLoading: boolean; notFound?: boolean } | null {
|
|
||||||
const { match } = nextProps;
|
|
||||||
const packageName = getRouterPackageName(match);
|
|
||||||
|
|
||||||
if (packageName !== prevState.packageName) {
|
|
||||||
try {
|
|
||||||
return {
|
|
||||||
packageName,
|
|
||||||
isLoading: false,
|
|
||||||
};
|
|
||||||
} catch (err) {
|
|
||||||
return {
|
|
||||||
notFound: true,
|
|
||||||
isLoading: false,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async componentDidMount(): Promise<void> {
|
|
||||||
await this.loadPackageInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* eslint no-unused-vars: 0 */
|
|
||||||
public async componentDidUpdate(nextProps, prevState: StateInterface): Promise<void> {
|
|
||||||
const { packageName } = this.state;
|
|
||||||
if (packageName !== prevState.packageName) {
|
|
||||||
const { readMe, packageMeta } = (await callDetailPage(packageName)) as Partial<StateInterface>;
|
|
||||||
this.setState({
|
|
||||||
readMe,
|
|
||||||
packageMeta,
|
|
||||||
packageName,
|
|
||||||
notFound: false,
|
|
||||||
isLoading: false,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public render(): ReactElement<HTMLElement> {
|
|
||||||
const { isLoading, packageMeta, readMe, packageName } = this.state;
|
|
||||||
|
|
||||||
if (isLoading) {
|
|
||||||
return <Loading />;
|
|
||||||
} else if (!packageMeta) {
|
|
||||||
return <NotFound />;
|
|
||||||
} else {
|
|
||||||
return (
|
|
||||||
<DetailContextProvider value={{ packageMeta, readMe, packageName, enableLoading: this.enableLoading }}>
|
|
||||||
<Grid className={'container content'} container={true} spacing={0}>
|
|
||||||
<Grid item={true} xs={8}>
|
|
||||||
{this.renderDetail()}
|
|
||||||
</Grid>
|
|
||||||
<Grid item={true} xs={4}>
|
|
||||||
{this.renderSidebar()}
|
|
||||||
</Grid>
|
|
||||||
</Grid>
|
|
||||||
</DetailContextProvider>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async loadPackageInfo(): Promise<void> {
|
|
||||||
const { packageName } = this.state;
|
|
||||||
// FIXME: use utility
|
|
||||||
document.title = `Verdaccio - ${packageName}`;
|
|
||||||
|
|
||||||
this.setState({
|
|
||||||
readMe: '',
|
|
||||||
});
|
|
||||||
|
|
||||||
try {
|
|
||||||
const { readMe, packageMeta } = (await callDetailPage(packageName)) as Partial<StateInterface>;
|
|
||||||
this.setState({
|
|
||||||
readMe,
|
|
||||||
packageMeta,
|
|
||||||
packageName,
|
|
||||||
notFound: false,
|
|
||||||
isLoading: false,
|
|
||||||
});
|
|
||||||
} catch (err) {
|
|
||||||
this.setState({
|
|
||||||
notFound: true,
|
|
||||||
packageName,
|
|
||||||
isLoading: false,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public enableLoading = () => {
|
|
||||||
this.setState({
|
|
||||||
isLoading: true,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
public renderDetail(): ReactElement<HTMLElement> {
|
|
||||||
return <DetailContainer />;
|
|
||||||
}
|
|
||||||
|
|
||||||
public renderSidebar(): ReactElement<HTMLElement> {
|
|
||||||
return <DetailSidebar />;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default VersionPage;
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
export { default, DetailContextProps } from './Version';
|
|
||||||
@@ -13,7 +13,7 @@ const history = createBrowserHistory({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const NotFound = asyncComponent(() => import('./components/NotFound'));
|
const NotFound = asyncComponent(() => import('./components/NotFound'));
|
||||||
const VersionPackage = asyncComponent(() => import('./pages/version/Version'));
|
const VersionPackage = asyncComponent(() => import('./pages/Version'));
|
||||||
const HomePage = asyncComponent(() => import('./pages/home'));
|
const HomePage = asyncComponent(() => import('./pages/home'));
|
||||||
|
|
||||||
interface RouterAppProps {
|
interface RouterAppProps {
|
||||||
|
|||||||
@@ -11,6 +11,22 @@ describe('api', () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
describe('handleResponseType', () => {
|
describe('handleResponseType', () => {
|
||||||
|
test('should handle missing Content-Type', async () => {
|
||||||
|
const response: Response = {
|
||||||
|
url: 'http://localhost:8080/-/packages',
|
||||||
|
ok: false,
|
||||||
|
// @ts-ignore
|
||||||
|
headers: {
|
||||||
|
get: () => null,
|
||||||
|
} as Headers,
|
||||||
|
} as Response;
|
||||||
|
|
||||||
|
const handled = await handleResponseType(response);
|
||||||
|
|
||||||
|
// Should this actually return [false, null] ?
|
||||||
|
expect(handled).toBeUndefined();
|
||||||
|
});
|
||||||
|
|
||||||
test('should test tgz scenario', async () => {
|
test('should test tgz scenario', async () => {
|
||||||
const blob = new Blob(['foo']);
|
const blob = new Blob(['foo']);
|
||||||
const blobPromise = Promise.resolve<Blob>(blob);
|
const blobPromise = Promise.resolve<Blob>(blob);
|
||||||
|
|||||||
@@ -8,20 +8,20 @@ import '../../types';
|
|||||||
*/
|
*/
|
||||||
export function handleResponseType(response: Response): Promise<[boolean, Blob | string]> | Promise<void> {
|
export function handleResponseType(response: Response): Promise<[boolean, Blob | string]> | Promise<void> {
|
||||||
if (response.headers) {
|
if (response.headers) {
|
||||||
const contentType = response.headers.get('Content-Type') as string;
|
const contentType = response.headers.get('Content-Type');
|
||||||
if (contentType.includes('application/pdf')) {
|
if (contentType && contentType.includes('application/pdf')) {
|
||||||
return Promise.all([response.ok, response.blob()]);
|
return Promise.all([response.ok, response.blob()]);
|
||||||
}
|
}
|
||||||
if (contentType.includes('application/json')) {
|
if (contentType && contentType.includes('application/json')) {
|
||||||
return Promise.all([response.ok, response.json()]);
|
return Promise.all([response.ok, response.json()]);
|
||||||
}
|
}
|
||||||
// it includes all text types
|
// it includes all text types
|
||||||
if (contentType.includes('text/')) {
|
if (contentType && contentType.includes('text/')) {
|
||||||
return Promise.all([response.ok, response.text()]);
|
return Promise.all([response.ok, response.text()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// unfortunatelly on download files there is no header available
|
// unfortunatelly on download files there is no header available
|
||||||
if (response.url && response.url.endsWith('.tgz') !== null) {
|
if (response.url && response.url.endsWith('.tgz') === true) {
|
||||||
return Promise.all([response.ok, response.blob()]);
|
return Promise.all([response.ok, response.blob()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,18 @@
|
|||||||
import API from './api';
|
import API from './api';
|
||||||
import { PackageMetaInterface } from 'types/packageMeta';
|
import { PackageMetaInterface } from 'types/packageMeta';
|
||||||
|
|
||||||
export interface DetailPage {
|
export async function callReadme(packageName): Promise<string | {}> {
|
||||||
readMe: string | {};
|
return await API.request<string | {}>(`package/readme/${packageName}`, 'GET');
|
||||||
packageMeta: PackageMetaInterface | {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function callDetailPage(packageName): Promise<DetailPage> {
|
export async function callDetailPage(packageName): Promise<PackageMetaInterface | {}> {
|
||||||
const readMe = await API.request<string | {}>(`package/readme/${packageName}`, 'GET');
|
|
||||||
const packageMeta = await API.request<PackageMetaInterface | {}>(`sidebar/${packageName}`, 'GET');
|
const packageMeta = await API.request<PackageMetaInterface | {}>(`sidebar/${packageName}`, 'GET');
|
||||||
|
|
||||||
return { readMe, packageMeta };
|
return packageMeta;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function callSearch(value: string, signal: any) {
|
||||||
|
// https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API#Browser_compatibility
|
||||||
|
// FUTURE: signal is not well supported for IE and Samsung Browser
|
||||||
|
return API.request(`search/${encodeURIComponent(value)}`, 'GET', { signal, headers: {} });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,14 +56,8 @@ export function formatDateDistance(lastUpdate): string {
|
|||||||
return distanceInWordsToNow(new Date(lastUpdate));
|
return distanceInWordsToNow(new Date(lastUpdate));
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getRouterPackageName(match): string {
|
export function buildScopePackage(scope: string, packageName: string) {
|
||||||
const packageName = match.params.package;
|
return `@${scope}/${packageName}`;
|
||||||
const scope = match.params.scope;
|
|
||||||
if (scope) {
|
|
||||||
return `@${scope}/${packageName}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
return packageName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
6
test/acceptance/.eslintrc
Normal file
6
test/acceptance/.eslintrc
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"rules": {
|
||||||
|
"new-cap": 0,
|
||||||
|
"prettier/prettier": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
1
test/acceptance/.gitignore
vendored
Normal file
1
test/acceptance/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
output
|
||||||
9
test/acceptance/Menu_test.js
Normal file
9
test/acceptance/Menu_test.js
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
Feature('Menu');
|
||||||
|
|
||||||
|
Scenario('check if we find the npm commands to set the registry', (I) => {
|
||||||
|
I.amOnPage('http://localhost:8080');
|
||||||
|
I.waitForElement('#header--button-registryInfo', 5);
|
||||||
|
I.click('#header--button-registryInfo');
|
||||||
|
I.waitForElement('#registryInfo--dialog-container');
|
||||||
|
I.see('npm set registry http://localhost:8080');
|
||||||
|
});
|
||||||
10
test/acceptance/SearchResult_test.js
Normal file
10
test/acceptance/SearchResult_test.js
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
Feature('SearchResult');
|
||||||
|
|
||||||
|
Scenario('check if we get the "no results found" text', (I) => {
|
||||||
|
I.amOnPage('http://localhost:8080');
|
||||||
|
I.seeElement('header .react-autosuggest__input input');
|
||||||
|
I.fillField('header .react-autosuggest__input input', 'test');
|
||||||
|
I.waitForElement('header .react-autosuggest__suggestions-container');
|
||||||
|
I.wait(1);
|
||||||
|
I.see('No results found.', 'header .react-autosuggest__suggestions-container');
|
||||||
|
});
|
||||||
8
test/acceptance/steps_file.js
Normal file
8
test/acceptance/steps_file.js
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
// in this file you can append custom step methods to 'I' object
|
||||||
|
|
||||||
|
module.exports = function() {
|
||||||
|
return actor({
|
||||||
|
// Define custom steps here, use 'this' to access default methods of I.
|
||||||
|
// It is recommended to place a general 'login' function here.
|
||||||
|
});
|
||||||
|
};
|
||||||
24204
test/fixtures/metadata/vue.json
vendored
Normal file
24204
test/fixtures/metadata/vue.json
vendored
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
|||||||
web:
|
web:
|
||||||
title: Verdaccio
|
title: Verdaccio Local Dev
|
||||||
# gravatar: false
|
sort_packages: asc
|
||||||
# sort_packages: asc
|
primary_color: #CCC
|
||||||
|
|
||||||
plugins: ../
|
plugins: ../
|
||||||
|
|
||||||
@@ -14,22 +14,15 @@ auth:
|
|||||||
bar:
|
bar:
|
||||||
name: bar
|
name: bar
|
||||||
password: test
|
password: test
|
||||||
store:
|
|
||||||
memory:
|
|
||||||
limit: 1000
|
|
||||||
|
|
||||||
# theme:
|
|
||||||
|
|
||||||
|
|
||||||
security:
|
security:
|
||||||
api:
|
api:
|
||||||
jwt:
|
jwt:
|
||||||
sign:
|
sign:
|
||||||
expiresIn: 60d
|
expiresIn: 120d
|
||||||
notBefore: 1
|
notBefore: 1
|
||||||
web:
|
web:
|
||||||
sign:
|
sign:
|
||||||
expiresIn: 7d
|
expiresIn: 100d
|
||||||
notBefore: 1
|
notBefore: 1
|
||||||
|
|
||||||
uplinks:
|
uplinks:
|
||||||
@@ -41,12 +34,18 @@ packages:
|
|||||||
access: $all
|
access: $all
|
||||||
publish: $authenticated
|
publish: $authenticated
|
||||||
unpublish: $authenticated
|
unpublish: $authenticated
|
||||||
|
'vue':
|
||||||
|
access: foo
|
||||||
|
publish: foo
|
||||||
|
unpublish: foo
|
||||||
|
'jquery':
|
||||||
|
access: $all
|
||||||
|
publish: bar
|
||||||
|
unpublish: bar
|
||||||
'**':
|
'**':
|
||||||
access: $all
|
access: $all
|
||||||
publish: $authenticated
|
publish: $authenticated
|
||||||
unpublish: $authenticated
|
unpublish: $authenticated
|
||||||
|
|
||||||
middlewares:
|
middlewares:
|
||||||
audit:
|
audit:
|
||||||
enabled: true
|
enabled: true
|
||||||
@@ -1,19 +1,26 @@
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const startServer = require('verdaccio').default;
|
const startServer = require('verdaccio').default;
|
||||||
const yalm = require('js-yaml');
|
const yalm = require('js-yaml');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
const configJsonFormat = yalm.safeLoad(fs.readFileSync('./tools/_config.yaml', 'utf8'));
|
const storageLocation = path.join(__dirname, '../partials/storage');
|
||||||
|
const pluginsLocation = path.join(__dirname, '../partials/plugins');
|
||||||
|
const configJsonFormat = Object.assign({}, yalm.safeLoad(fs.readFileSync('./tools/_verdaccio.config.yaml', 'utf8')), {
|
||||||
|
storage: storageLocation,
|
||||||
|
plugins: pluginsLocation,
|
||||||
|
});
|
||||||
|
|
||||||
const handler = function(webServer, addr, pkgName, pkgVersion) {
|
const serverHandler = function(webServer, addr, pkgName, pkgVersion) {
|
||||||
webServer.listen(addr.port || addr.path, addr.host, () => {
|
webServer.listen(addr.port || addr.path, addr.host, () => {
|
||||||
console.log(`${pkgName}:${pkgVersion} running ${addr.proto}://${addr.host}:${addr.port}`);
|
console.log(`${pkgName}:${pkgVersion} running ${addr.proto}://${addr.host}:${addr.port}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
process.on('SIGTERM', () => {
|
process.on('SIGTERM', () => {
|
||||||
webServer.close(() => {
|
webServer.close(() => {
|
||||||
console.log('Process terminated');
|
console.log('verdaccio server has been shutdown');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
startServer(configJsonFormat, 8080, '', '1.0.0', 'verdaccio', handler);
|
// https://verdaccio.org/docs/en/node-api
|
||||||
|
startServer(configJsonFormat, 8080, '', '1.0.0', 'verdaccio', serverHandler);
|
||||||
|
|||||||
@@ -7,8 +7,7 @@ module.exports = {
|
|||||||
output: {
|
output: {
|
||||||
path: `${env.APP_ROOT}/static/`,
|
path: `${env.APP_ROOT}/static/`,
|
||||||
filename: '[name].[hash].js',
|
filename: '[name].[hash].js',
|
||||||
// FIXME: do we need this?
|
publicPath: '/-/static',
|
||||||
publicPath: 'ToReplaceByVerdaccio/-/static',
|
|
||||||
},
|
},
|
||||||
|
|
||||||
resolve: {
|
resolve: {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
"allowSyntheticDefaultImports": true,
|
"allowSyntheticDefaultImports": true,
|
||||||
"jsx": "react",
|
"jsx": "react",
|
||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
|
"resolveJsonModule": true,
|
||||||
"checkJs": false,
|
"checkJs": false,
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"baseUrl": ".",
|
"baseUrl": ".",
|
||||||
@@ -18,6 +19,6 @@
|
|||||||
"types/*.d.ts", "scripts/lib", "node_modules/config"
|
"types/*.d.ts", "scripts/lib", "node_modules/config"
|
||||||
],
|
],
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"node_modules",
|
"node_modules"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user