From 9ed932e5895fc18e471cae9ecd825955bbb963a5 Mon Sep 17 00:00:00 2001 From: "Juan Picado @jotadeveloper" Date: Thu, 13 Aug 2020 23:36:23 +0200 Subject: [PATCH] chore: extend lint rules to root --- .eslintrc | 1 - debug/bootstrap.js | 2 +- jest/config.js | 7 +--- package.json | 2 +- .../api/__mocks__/@verdaccio/logger/index.js | 20 +++++----- packages/api/types/custom.d.ts | 2 +- packages/loaders/jest.config.js | 1 - packages/logger-prettify/jest.config.js | 1 - packages/logger/jest.config.js | 1 - packages/middleware/jest.config.js | 3 +- packages/middleware/types/custom.d.ts | 4 +- packages/mock/jest.config.js | 3 +- packages/node-api/jest.config.js | 3 +- packages/proxy/jest.config.js | 3 +- packages/server/jest.config.js | 3 +- packages/server/types/custom.d.ts | 2 +- packages/store/jest.config.js | 3 +- packages/types/custom.d.ts | 2 +- packages/types/index.ts | 17 ++++----- packages/verdaccio/debug/bootstrap.js | 2 +- packages/verdaccio/jest.config.js | 14 ++----- packages/web/jest.config.js | 1 - packages/web/types/custom.d.ts | 2 +- scripts/run-verdaccio.js | 2 +- scripts/trigger-release.js | 4 +- test/e2e-cli/.eslintrc | 1 + test/e2e-cli/env_babel.js | 2 +- test/e2e-cli/env_setup.js | 2 +- test/e2e-cli/env_teardown.js | 2 +- test/e2e-cli/jest.config.e2e.cli.js | 2 +- test/e2e-cli/projects/basic/index.js | 4 +- test/e2e-cli/projects/scoped_basic/index.js | 4 +- test/e2e-cli/setup/setup.ts | 37 +++++-------------- test/e2e-cli/setup/test_environment.ts | 2 +- test/e2e-cli/test/__partials/npm_commands.ts | 11 +----- test/e2e-cli/test/core/info.spec.ts | 14 +++---- test/e2e-cli/test/core/listen.spec.ts | 7 +--- test/e2e-cli/test/install/install.spec.ts | 28 ++++---------- test/e2e-cli/utils/global.js | 12 +++--- test/e2e-cli/utils/process.ts | 9 +---- test/e2e-cli/utils/web.ts | 2 +- 41 files changed, 84 insertions(+), 160 deletions(-) diff --git a/.eslintrc b/.eslintrc index cf4e9c60b..9b481ed08 100644 --- a/.eslintrc +++ b/.eslintrc @@ -109,7 +109,6 @@ "@typescript-eslint/ban-ts-ignore": 0, "@typescript-eslint/no-var-requires": 0, "@typescript-eslint/no-inferrable-types": 0, - "@typescript-eslint/interface-name-prefix": 0, "@typescript-eslint/no-empty-function": 0, "@typescript-eslint/no-this-alias": 0, "@typescript-eslint/no-use-before-define": 0, diff --git a/debug/bootstrap.js b/debug/bootstrap.js index 1bcb31f89..3f05abbed 100644 --- a/debug/bootstrap.js +++ b/debug/bootstrap.js @@ -1,6 +1,6 @@ // this file aims to help local debugging with hot transpilation // it requires BABEL_ENV=registry set as env variable require('@babel/register')({ - extensions: [".ts", ".js"] + extensions: ['.ts', '.js'], }); require('../packages/cli/src/index'); diff --git a/jest/config.js b/jest/config.js index 1ebcdc1c8..712aaf4ba 100644 --- a/jest/config.js +++ b/jest/config.js @@ -5,11 +5,6 @@ module.exports = { }, verbose: false, collectCoverage: true, - collectCoverageFrom: [ - "src/**/*.ts", - "!**/node_modules/**", - "!**/partials/**", - "!**/fixture/**", - ], + collectCoverageFrom: ['src/**/*.ts', '!**/node_modules/**', '!**/partials/**', '!**/fixture/**'], coveragePathIgnorePatterns: ['node_modules', 'fixtures'], }; diff --git a/package.json b/package.json index 3cb2b60f7..f941da3af 100644 --- a/package.json +++ b/package.json @@ -101,7 +101,7 @@ "clean": "pnpm recursive run clean", "build": "pnpm recursive run build", "docker": "docker build -t verdaccio/verdaccio:local . --no-cache", - "lint": "eslint \"packages/**/@(src|tests|test)/**\"", + "lint": "eslint . --ext .js,.ts,.tsx,.jsx", "test": "pnpm recursive test", "test:e2e:cli": "cross-env NODE_ENV=test jest --config ./test/e2e-cli/jest.config.e2e.cli.js --passWithNoTests", "website:lint": "cd website && yarn lint", diff --git a/packages/api/__mocks__/@verdaccio/logger/index.js b/packages/api/__mocks__/@verdaccio/logger/index.js index 722dd194c..c42519fa9 100644 --- a/packages/api/__mocks__/@verdaccio/logger/index.js +++ b/packages/api/__mocks__/@verdaccio/logger/index.js @@ -1,19 +1,19 @@ const setup = jest.fn(); -const logger = { +const logger = { child: jest.fn(() => ({ debug: jest.fn(), - trace: jest.fn(), - warn: jest.fn(), - info: jest.fn(), - error: jest.fn(), + trace: jest.fn(), + warn: jest.fn(), + info: jest.fn(), + error: jest.fn(), fatal: jest.fn(), })), debug: jest.fn(), - trace: jest.fn(), - warn: jest.fn(), - info: jest.fn(), - error: jest.fn(), + trace: jest.fn(), + warn: jest.fn(), + info: jest.fn(), + error: jest.fn(), fatal: jest.fn(), }; -export { setup, logger } +export { setup, logger }; diff --git a/packages/api/types/custom.d.ts b/packages/api/types/custom.d.ts index 9c7e201cc..dfc4ffcdd 100644 --- a/packages/api/types/custom.d.ts +++ b/packages/api/types/custom.d.ts @@ -1,4 +1,4 @@ -import { Logger, RemoteUser } from "@verdaccio/types"; +import { Logger, RemoteUser } from '@verdaccio/types'; declare global { namespace Express { diff --git a/packages/loaders/jest.config.js b/packages/loaders/jest.config.js index ae0866389..7da7d2da8 100644 --- a/packages/loaders/jest.config.js +++ b/packages/loaders/jest.config.js @@ -1,4 +1,3 @@ const config = require('../../jest/config'); module.exports = Object.assign({}, config, {}); - diff --git a/packages/logger-prettify/jest.config.js b/packages/logger-prettify/jest.config.js index ae0866389..7da7d2da8 100644 --- a/packages/logger-prettify/jest.config.js +++ b/packages/logger-prettify/jest.config.js @@ -1,4 +1,3 @@ const config = require('../../jest/config'); module.exports = Object.assign({}, config, {}); - diff --git a/packages/logger/jest.config.js b/packages/logger/jest.config.js index 911a886b0..11b4810ea 100644 --- a/packages/logger/jest.config.js +++ b/packages/logger/jest.config.js @@ -3,4 +3,3 @@ const config = require('../../jest/config'); module.exports = Object.assign({}, config, { verbose: true, }); - diff --git a/packages/middleware/jest.config.js b/packages/middleware/jest.config.js index 535d72654..52d660399 100644 --- a/packages/middleware/jest.config.js +++ b/packages/middleware/jest.config.js @@ -1,6 +1,5 @@ const config = require('../../jest/config'); module.exports = Object.assign({}, config, { - collectCoverage: true + collectCoverage: true, }); - diff --git a/packages/middleware/types/custom.d.ts b/packages/middleware/types/custom.d.ts index fa554d09c..c9f461f5b 100644 --- a/packages/middleware/types/custom.d.ts +++ b/packages/middleware/types/custom.d.ts @@ -1,7 +1,7 @@ // -import { Logger, RemoteUser } from "@verdaccio/types"; -import * as http from "http"; +import * as http from 'http'; +import { Logger, RemoteUser } from '@verdaccio/types'; declare global { namespace Express { diff --git a/packages/mock/jest.config.js b/packages/mock/jest.config.js index 535d72654..52d660399 100644 --- a/packages/mock/jest.config.js +++ b/packages/mock/jest.config.js @@ -1,6 +1,5 @@ const config = require('../../jest/config'); module.exports = Object.assign({}, config, { - collectCoverage: true + collectCoverage: true, }); - diff --git a/packages/node-api/jest.config.js b/packages/node-api/jest.config.js index 535d72654..52d660399 100644 --- a/packages/node-api/jest.config.js +++ b/packages/node-api/jest.config.js @@ -1,6 +1,5 @@ const config = require('../../jest/config'); module.exports = Object.assign({}, config, { - collectCoverage: true + collectCoverage: true, }); - diff --git a/packages/proxy/jest.config.js b/packages/proxy/jest.config.js index 535d72654..52d660399 100644 --- a/packages/proxy/jest.config.js +++ b/packages/proxy/jest.config.js @@ -1,6 +1,5 @@ const config = require('../../jest/config'); module.exports = Object.assign({}, config, { - collectCoverage: true + collectCoverage: true, }); - diff --git a/packages/server/jest.config.js b/packages/server/jest.config.js index 898e22759..ece34f19d 100644 --- a/packages/server/jest.config.js +++ b/packages/server/jest.config.js @@ -1,6 +1,5 @@ const config = require('../../jest/config'); module.exports = Object.assign({}, config, { - setupFilesAfterEnv: ['./jest.setup.js'] + setupFilesAfterEnv: ['./jest.setup.js'], }); - diff --git a/packages/server/types/custom.d.ts b/packages/server/types/custom.d.ts index 9c7e201cc..dfc4ffcdd 100644 --- a/packages/server/types/custom.d.ts +++ b/packages/server/types/custom.d.ts @@ -1,4 +1,4 @@ -import { Logger, RemoteUser } from "@verdaccio/types"; +import { Logger, RemoteUser } from '@verdaccio/types'; declare global { namespace Express { diff --git a/packages/store/jest.config.js b/packages/store/jest.config.js index d09544575..76c7ffa3f 100644 --- a/packages/store/jest.config.js +++ b/packages/store/jest.config.js @@ -2,6 +2,5 @@ const config = require('../../jest/config'); module.exports = Object.assign({}, config, { // FIXME: coverage fails here - collectCoverage: true + collectCoverage: true, }); - diff --git a/packages/types/custom.d.ts b/packages/types/custom.d.ts index 733e88c70..cdc69ee5c 100644 --- a/packages/types/custom.d.ts +++ b/packages/types/custom.d.ts @@ -1,4 +1,4 @@ -import { Logger, RemoteUser } from "@verdaccio/types"; +import { Logger, RemoteUser } from '@verdaccio/types'; declare global { namespace Express { diff --git a/packages/types/index.ts b/packages/types/index.ts index d8a18b634..fc3046e6c 100644 --- a/packages/types/index.ts +++ b/packages/types/index.ts @@ -17,13 +17,13 @@ import { Package, IPluginStorageFilter, Author, - AuthPluginPackage, + AuthPluginPackage, Token, ITokenActions, - TokenFilter + TokenFilter, } from '@verdaccio/types'; import lunrMutable from 'lunr-mutable-indexes'; -import {NextFunction, Request, Response} from 'express'; +import { NextFunction, Request, Response } from 'express'; export type StringValue = verdaccio$StringValue; @@ -42,13 +42,13 @@ export interface LegacyPackageList { export type PackageAccessAddOn = PackageAccess & { // FIXME: should be published on @verdaccio/types unpublish?: string[]; -} +}; export type MatchedPackage = PackageAccess | void; export type JWTPayload = RemoteUser & { password?: string; -} +}; export interface AESPayload { user: string; @@ -92,10 +92,10 @@ export interface Profile { fullname: string; } -export type $RequestExtend = Request & {remote_user?: any; log: Logger} -export type $ResponseExtend = Response & {cookies?: any} +export type $RequestExtend = Request & { remote_user?: any; log: Logger }; +export type $ResponseExtend = Response & { cookies?: any }; export type $NextFunctionVer = NextFunction & any; -export type $SidebarPackage = Package & {latest: any} +export type $SidebarPackage = Package & { latest: any }; export interface IAuthWebUI { jwtEncrypt(user: RemoteUser, signOptions: JWTSignOptions): Promise; @@ -194,4 +194,3 @@ export interface Styles { } export type AuthorAvatar = Author & { avatar?: string }; - diff --git a/packages/verdaccio/debug/bootstrap.js b/packages/verdaccio/debug/bootstrap.js index 8d16cc02a..14b86e839 100644 --- a/packages/verdaccio/debug/bootstrap.js +++ b/packages/verdaccio/debug/bootstrap.js @@ -1,6 +1,6 @@ // this file aims to help local debugging with hot transpilation // it requires BABEL_ENV=registry set as env variable require('@babel/register')({ - extensions: [".ts"] + extensions: ['.ts'], }); require('@verdaccio/cli'); diff --git a/packages/verdaccio/jest.config.js b/packages/verdaccio/jest.config.js index d122efaf7..c755212b1 100644 --- a/packages/verdaccio/jest.config.js +++ b/packages/verdaccio/jest.config.js @@ -10,7 +10,7 @@ module.exports = { // 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. transform: { - '^.+\\.[t|j]sx?$': 'babel-jest' + '^.+\\.[t|j]sx?$': 'babel-jest', }, modulePathIgnorePatterns: [ '/test/unit/partials/mock-store/.*/package.json', @@ -28,14 +28,6 @@ module.exports = { '/build', '/.vscode/', ], - testPathIgnorePatterns: [ - '__snapshots__', - '/build', - ], - coveragePathIgnorePatterns: [ - 'node_modules', - 'fixtures', - '/src/api/debug', - '/test', - ] + testPathIgnorePatterns: ['__snapshots__', '/build'], + coveragePathIgnorePatterns: ['node_modules', 'fixtures', '/src/api/debug', '/test'], }; diff --git a/packages/web/jest.config.js b/packages/web/jest.config.js index ae0866389..7da7d2da8 100644 --- a/packages/web/jest.config.js +++ b/packages/web/jest.config.js @@ -1,4 +1,3 @@ const config = require('../../jest/config'); module.exports = Object.assign({}, config, {}); - diff --git a/packages/web/types/custom.d.ts b/packages/web/types/custom.d.ts index 9c7e201cc..dfc4ffcdd 100644 --- a/packages/web/types/custom.d.ts +++ b/packages/web/types/custom.d.ts @@ -1,4 +1,4 @@ -import { Logger, RemoteUser } from "@verdaccio/types"; +import { Logger, RemoteUser } from '@verdaccio/types'; declare global { namespace Express { diff --git a/scripts/run-verdaccio.js b/scripts/run-verdaccio.js index 739f5d5be..ad796ffa4 100644 --- a/scripts/run-verdaccio.js +++ b/scripts/run-verdaccio.js @@ -3,6 +3,6 @@ // this file aims to help local debugging with hot transpilation // it requires BABEL_ENV=registry set as env variable require('@babel/register')({ - extensions: [".ts", ".js"] + extensions: ['.ts', '.js'], }); require('../src/lib/cli'); diff --git a/scripts/trigger-release.js b/scripts/trigger-release.js index a4ef35e3f..136bddeea 100644 --- a/scripts/trigger-release.js +++ b/scripts/trigger-release.js @@ -15,7 +15,7 @@ const octokit = new Octokit({ const [repoOwner, repoName] = process.env.GITHUB_REPOSITORY.split('/'); getStdin() - .then(changelog => + .then((changelog) => octokit.repos.createRelease({ owner: repoOwner, repo: repoName, @@ -24,7 +24,7 @@ getStdin() draft: false, }) ) - .catch(err => { + .catch((err) => { // eslint-disable-next-line no-console console.error(err); process.exit(1); diff --git a/test/e2e-cli/.eslintrc b/test/e2e-cli/.eslintrc index cbfb89d2f..eb2ac4c85 100644 --- a/test/e2e-cli/.eslintrc +++ b/test/e2e-cli/.eslintrc @@ -1,5 +1,6 @@ { "rules": { + "no-console": 0, "@typescript-eslint/no-var-requires": 0, "@typescript-eslint/explicit-member-accessibility": 0 } diff --git a/test/e2e-cli/env_babel.js b/test/e2e-cli/env_babel.js index eddce9aa3..93ed7b81a 100644 --- a/test/e2e-cli/env_babel.js +++ b/test/e2e-cli/env_babel.js @@ -1,4 +1,4 @@ require('@babel/register')({ - extensions: [".ts", ".js"] + extensions: ['.ts', '.js'], }); module.exports = require('./setup/test_environment'); diff --git a/test/e2e-cli/env_setup.js b/test/e2e-cli/env_setup.js index 222f7183e..dc96b42dc 100644 --- a/test/e2e-cli/env_setup.js +++ b/test/e2e-cli/env_setup.js @@ -1,4 +1,4 @@ require('@babel/register')({ - extensions: [".ts", ".js"] + extensions: ['.ts', '.js'], }); module.exports = require('./setup/setup'); diff --git a/test/e2e-cli/env_teardown.js b/test/e2e-cli/env_teardown.js index 75165a7c7..07f353212 100644 --- a/test/e2e-cli/env_teardown.js +++ b/test/e2e-cli/env_teardown.js @@ -1,4 +1,4 @@ require('@babel/register')({ - extensions: [".ts", ".js"] + extensions: ['.ts', '.js'], }); module.exports = require('./setup/teardown'); diff --git a/test/e2e-cli/jest.config.e2e.cli.js b/test/e2e-cli/jest.config.e2e.cli.js index 5cec14386..aa679f747 100644 --- a/test/e2e-cli/jest.config.e2e.cli.js +++ b/test/e2e-cli/jest.config.e2e.cli.js @@ -8,5 +8,5 @@ module.exports = { testEnvironment: './env_babel.js', globalSetup: './env_setup.js', globalTeardown: './env_teardown.js', - testRegex: '(/test/e2e.*\\.spec)\\.ts' + testRegex: '(/test/e2e.*\\.spec)\\.ts', }; diff --git a/test/e2e-cli/projects/basic/index.js b/test/e2e-cli/projects/basic/index.js index 474a5966c..43a03bd37 100644 --- a/test/e2e-cli/projects/basic/index.js +++ b/test/e2e-cli/projects/basic/index.js @@ -1,5 +1,5 @@ -module.exports = function() { - const message = "this is a basic project"; +module.exports = function () { + const message = 'this is a basic project'; console.log(message); return message; diff --git a/test/e2e-cli/projects/scoped_basic/index.js b/test/e2e-cli/projects/scoped_basic/index.js index 76e3f217a..c0f82b163 100644 --- a/test/e2e-cli/projects/scoped_basic/index.js +++ b/test/e2e-cli/projects/scoped_basic/index.js @@ -1,5 +1,5 @@ -module.exports = function() { - const message = "this is a scoped basic project"; +module.exports = function () { + const message = 'this is a scoped basic project'; console.log(message); return message; diff --git a/test/e2e-cli/setup/setup.ts b/test/e2e-cli/setup/setup.ts index 1cc7b6f20..64ad8a518 100644 --- a/test/e2e-cli/setup/setup.ts +++ b/test/e2e-cli/setup/setup.ts @@ -1,44 +1,27 @@ import fs from 'fs'; import path from 'path'; import os from 'os'; -import { green } from 'kleur'; import { spawn } from 'child_process'; +import { yellow } from 'kleur'; import { npm } from '../utils/process'; import * as __global from '../utils/global.js'; module.exports = async () => { const tempRoot = fs.mkdtempSync(path.join(fs.realpathSync(os.tmpdir()), 'verdaccio-cli-e2e-')); - const tempConfigFile = path.join(tempRoot, 'verdaccio.yaml'); __global.addItem('dir-root', tempRoot); - console.log(green(`Global temp root folder: ${tempRoot}`)); - fs.copyFileSync(path.join(__dirname, '../config/_bootstrap_verdaccio.yaml'), tempConfigFile); - console.log(green(`global temp root conf: ${tempConfigFile}`)); + console.log(yellow(`Add temp root folder: ${tempRoot}`)); + fs.copyFileSync(path.join(__dirname, '../config/_bootstrap_verdaccio.yaml'), path.join(tempRoot, 'verdaccio.yaml')); // @ts-ignore global.__namespace = __global; console.log(`current directory: ${process.cwd()}`); - const rootVerdaccio = path.resolve('./bin/verdaccio'); - console.log(green(`verdaccio root path: ${rootVerdaccio}`)); // @ts-ignore - global.registryProcess = spawn('node', [path.resolve('./bin/verdaccio'), '-c', './verdaccio.yaml'], { - cwd: tempRoot, - // stdio: 'pipe' - }); - - // @ts-ignore - global.registryProcess.stdout.on('data', (data) => { - console.log(`stdout: ${data}`); - }); - - // @ts-ignore - global.registryProcess.stderr.on('data', (data) => { - console.log(`stderr: ${data}`); - }); - - // @ts-ignore - global.registryProcess.on('close', (code) => { - console.log(`child process exited with code ${code}`); - }); + global.registryProcess = spawn( + 'node', + [require.resolve('verdaccio/bin/verdaccio'), '-c', './verdaccio.yaml'], + // @ts-ignore + { cwd: tempRoot, silence: true } + ); // publish current build version on local registry - await npm('publish', '--registry', 'http://localhost:4873', '--verbose'); + await npm('publish', '--registry', 'http://localhost:4873'); }; diff --git a/test/e2e-cli/setup/test_environment.ts b/test/e2e-cli/setup/test_environment.ts index f56963737..afa5dbe3f 100644 --- a/test/e2e-cli/setup/test_environment.ts +++ b/test/e2e-cli/setup/test_environment.ts @@ -1,7 +1,7 @@ -const fs = require('fs'); import os from 'os'; import path from 'path'; import NodeEnvironment from 'jest-environment-node'; +const fs = require('fs'); const __global = require('../utils/global'); class E2ECliTestEnvironment extends NodeEnvironment { diff --git a/test/e2e-cli/test/__partials/npm_commands.ts b/test/e2e-cli/test/__partials/npm_commands.ts index 19c221c0e..964ee6640 100644 --- a/test/e2e-cli/test/__partials/npm_commands.ts +++ b/test/e2e-cli/test/__partials/npm_commands.ts @@ -1,14 +1,5 @@ import { silentNpm } from '../../utils/process'; export function installVerdaccio(verdaccioInstall) { - return silentNpm( - 'install', - '--prefix', - verdaccioInstall, - 'verdaccio', - '--registry', - 'http://localhost:4873', - '--no-package-lock', - '--verbose' - ); + return silentNpm('install', '--prefix', verdaccioInstall, 'verdaccio', '--registry', 'http://localhost:4873', '--no-package-lock'); } diff --git a/test/e2e-cli/test/core/info.spec.ts b/test/e2e-cli/test/core/info.spec.ts index deb91d9c9..86854dd5d 100644 --- a/test/e2e-cli/test/core/info.spec.ts +++ b/test/e2e-cli/test/core/info.spec.ts @@ -3,6 +3,7 @@ import { runVerdaccio } from '../../utils/process'; import { installVerdaccio } from '../__partials/npm_commands'; describe('verdaccio info', () => { + jest.setTimeout(90000); // @ts-ignore const tempRootFolder = global.__namespace.getItem('dir-root'); const verdaccioInstall = path.join(tempRootFolder, 'verdaccio-root-info'); @@ -10,21 +11,16 @@ describe('verdaccio info', () => { beforeAll(async () => { await installVerdaccio(verdaccioInstall); - }, 30000); + }); test('should run verdaccio info command', async () => { const pathVerdaccioModule = require.resolve('verdaccio/bin/verdaccio', { - paths: [verdaccioInstall] + paths: [verdaccioInstall], }); - const hasMatch = await runVerdaccio( - pathVerdaccioModule, - verdaccioInstall, - ['--info'], - /Environment/ - ); + const hasMatch = await runVerdaccio(pathVerdaccioModule, verdaccioInstall, ['--info'], /Environment/); expect(hasMatch.ok).toBeTruthy(); - }, 20000); + }); afterAll(() => { registryProcess.kill(); diff --git a/test/e2e-cli/test/core/listen.spec.ts b/test/e2e-cli/test/core/listen.spec.ts index 322795f41..e8c9e5dc1 100644 --- a/test/e2e-cli/test/core/listen.spec.ts +++ b/test/e2e-cli/test/core/listen.spec.ts @@ -21,13 +21,10 @@ describe('npm install', () => { test('should match the listing port and load metadata', async () => { const pathVerdaccioModule = require.resolve('verdaccio/bin/verdaccio', { - paths: [verdaccioInstall] + paths: [verdaccioInstall], }); - registryProcess = await spawnRegistry(pathVerdaccioModule, ['-c', configPath, '-l', port], { - cwd: verdaccioInstall, - silent: false - }); + registryProcess = await spawnRegistry(pathVerdaccioModule, ['-c', configPath, '-l', port], { cwd: verdaccioInstall, silent: true }); const body = await callRegistry(`http://localhost:${port}/verdaccio`); const parsedBody = JSON.parse(body); diff --git a/test/e2e-cli/test/install/install.spec.ts b/test/e2e-cli/test/install/install.spec.ts index 8767d1d93..cefd0008d 100644 --- a/test/e2e-cli/test/install/install.spec.ts +++ b/test/e2e-cli/test/install/install.spec.ts @@ -23,39 +23,25 @@ describe('npm install', () => { // @ts-ignore global.__namespace = __global; const pathVerdaccioModule = require.resolve('verdaccio/bin/verdaccio', { - paths: [verdaccioInstall] - }); - registryProcess = await spawnRegistry(pathVerdaccioModule, ['-c', configPath, '-l', port], { - cwd: verdaccioInstall, - silent: true + paths: [verdaccioInstall], }); + registryProcess = await spawnRegistry(pathVerdaccioModule, ['-c', configPath, '-l', port], { cwd: verdaccioInstall, silent: true }); }); test('should match on npm info verdaccio', async () => { // FIXME: not the best match, looking for a better way to match the terminal output - const output = await execAndWaitForOutputToMatch( - 'npm', - ['info', 'verdaccio', '--registry'], - /A lightweight private npm proxy registry/ - ); + const output = await execAndWaitForOutputToMatch('npm', ['info', 'verdaccio', '--registry'], /A lightweight private npm proxy registry/); expect(output.ok).toBeTruthy(); }); test('should install jquery', async () => { const testCwd = path.join(tempRootFolder, '_jquery_'); - await execAndWaitForOutputToMatch( - 'npm', - ['install', '--prefix', testCwd, 'jquery', '--registry', `http://localhost:${port}`], - /''/, - { - cwd: verdaccioInstall - } - ); + await execAndWaitForOutputToMatch('npm', ['install', '--prefix', testCwd, 'jquery', '--registry', `http://localhost:${port}`], /''/, { + cwd: verdaccioInstall, + }); - const exist = await expectFileToExist( - path.join(testCwd, 'node_modules', 'jquery', 'package.json') - ); + const exist = await expectFileToExist(path.join(testCwd, 'node_modules', 'jquery', 'package.json')); expect(exist).toBeTruthy(); }); diff --git a/test/e2e-cli/utils/global.js b/test/e2e-cli/utils/global.js index fe593662c..8cff9d73f 100644 --- a/test/e2e-cli/utils/global.js +++ b/test/e2e-cli/utils/global.js @@ -1,14 +1,14 @@ const namespace = Object.create(null); -exports.addItem = function(name, value) { +exports.addItem = function (name, value) { namespace[name] = value; -} +}; -exports.getItem = function(name) { - console.log("get-item", name, namespace); +exports.getItem = function (name) { + console.log('get-item', name, namespace); if (!(name in namespace)) { - throw new Error("The item ".concat(name, " does exist in the namespace")); + throw new Error('The item '.concat(name, ' does exist in the namespace')); } return namespace[name]; -} +}; diff --git a/test/e2e-cli/utils/process.ts b/test/e2e-cli/utils/process.ts index c617ee19f..edbf228b9 100644 --- a/test/e2e-cli/utils/process.ts +++ b/test/e2e-cli/utils/process.ts @@ -12,7 +12,7 @@ export async function _exec(options, cmd, args) { console.log(`ENV: ${JSON.stringify(env)}`); const spawnOptions = { cwd, - ...(env ? { env } : {}) + ...(env ? { env } : {}), }; if (process.platform.startsWith('win')) { @@ -76,12 +76,7 @@ export async function _exec(options, cmd, args) { }); } -export function execAndWaitForOutputToMatch( - cmd: string, - args: string[], - match: RegExp, - spawnOptions: SpawnOptions = {} -): any { +export function execAndWaitForOutputToMatch(cmd: string, args: string[], match: RegExp, spawnOptions: SpawnOptions = {}): any { return _exec({ waitForMatch: match, ...spawnOptions, silence: true }, cmd, args); } diff --git a/test/e2e-cli/utils/web.ts b/test/e2e-cli/utils/web.ts index 3d300e5fe..272e0cc46 100644 --- a/test/e2e-cli/utils/web.ts +++ b/test/e2e-cli/utils/web.ts @@ -5,7 +5,7 @@ export function callRegistry(url: string): Promise { return new Promise((resolve, reject) => { let options = { url: url, - headers: { Accept: 'application/json' } + headers: { Accept: 'application/json' }, }; // @ts-ignore request(options, (error: any, response: IncomingMessage, body: string) => {