Skip to content

Commit

Permalink
refactor: remove YAML stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
pkerschbaum committed Nov 19, 2022
1 parent 0f59697 commit 6e3060b
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 16 deletions.
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,10 @@
"@rollup/plugin-typescript": "^8.5.0",
"@size-limit/preset-small-lib": "^8.1.0",
"@types/jest": "^29.1.1",
"@types/js-yaml": "^4.0.5",
"@types/rollup": "^0.54.0",
"@verdaccio/types": "^10.7.0",
"expect-type": "^0.14.2",
"jest": "^29.1.2",
"js-yaml": "^4.1.0",
"prettier": "^2.7.1",
"rimraf": "^3.0.2",
"rollup": "^2.79.1",
Expand Down
37 changes: 30 additions & 7 deletions test-lib-consumption/global-setup-teardown.mts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { Config } from '@verdaccio/types';
import YAML from 'js-yaml';
import fs from 'node:fs';
import * as verdaccio from 'verdaccio';
import { $ } from 'zx';
Expand Down Expand Up @@ -50,17 +49,41 @@ async function startVerdaccioServer(portToStartOn: number): Promise<VerdaccioSer
// Remove .verdaccio folder (could be present from a previous run)
await cleanupVerdaccioDirectory();

// Verdaccio initialization with its Node.js API is based on https://verdaccio.org/docs/verdaccio-programmatically#using-the-module-api
const verdaccioConfigFile = await fs.promises.readFile(PATHS.VERDACCIO_CONFIG, 'utf8');
const verdaccioConfig = YAML.load(verdaccioConfigFile) as Config;
/**
* Verdaccio initialization with its Node.js API is based on https://verdaccio.org/docs/verdaccio-programmatically#using-the-module-api.
* The type "Config" has some properties defined as required which are'nt in reality, so omit them.
*/
const cache = PATHS.VERDACCIO_TEMP_FOLDER_CACHE;
const config: Config = {
...verdaccioConfig,
const config: Omit<
Config,
'server_id' | 'secret' | 'checkSecretKey' | 'getMatchedPackagesSpec' | 'security'
> = {
uplinks: {
npmjs: {
url: 'https://registry.npmjs.org/',
},
},
packages: {
'tiny-invariant': {
access: ['$all'],
publish: ['$all'],
},
'@*/*': {
access: ['$all'],
publish: ['$all'],
proxy: ['npmjs'],
},
'**': {
access: ['$all'],
publish: ['$all'],
proxy: ['npmjs'],
},
},
storage: PATHS.VERDACCIO_TEMP_FOLDER_STORAGE,
self_path: cache,
};

const app = await verdaccio.runServer(config);
const app = await verdaccio.runServer(config as Config);
await new Promise<void>((resolve, reject) => {
console.info(`[Verdaccio] starting server on port ${portToStartOn}`);
app.listen(portToStartOn, function listeningListener() {
Expand Down
1 change: 0 additions & 1 deletion test-lib-consumption/helpers/constants.mts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const __dirname = url.fileURLToPath(new URL('.', import.meta.url));

export const PATHS = {
PACKAGE_ROOT_DIRECTORY: path.join(__dirname, '..', '..'),
VERDACCIO_CONFIG: path.join(__dirname, '..', 'verdaccio-config.yaml'),
VERDACCIO_TEMP_FOLDER: path.join(__dirname, '..', '.verdaccio'),
VERDACCIO_TEMP_FOLDER_CACHE: path.join(__dirname, '..', '.verdaccio', 'cache'),
VERDACCIO_TEMP_FOLDER_STORAGE: path.join(__dirname, '..', '.verdaccio', 'storage'),
Expand Down
7 changes: 1 addition & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -793,11 +793,6 @@
expect "^29.0.0"
pretty-format "^29.0.0"

"@types/js-yaml@^4.0.5":
version "4.0.5"
resolved "https://registry.yarnpkg.com/@types/js-yaml/-/js-yaml-4.0.5.tgz#738dd390a6ecc5442f35e7f03fa1431353f7e138"
integrity sha512-FhpRzf927MNQdRZP0J5DLIdTXhjLYzeUTmLAu69mnVksLH9CJY3IuSeEgbKUki7GQZm0WqDkGzyxju2EZGD2wA==

"@types/minimist@^1.2.2":
version "1.2.2"
resolved "https://registry.yarnpkg.com/@types/minimist/-/minimist-1.2.2.tgz#ee771e2ba4b3dc5b372935d549fd9617bf345b8c"
Expand Down Expand Up @@ -3125,7 +3120,7 @@ js-tokens@^4.0.0:
resolved "https://packages.atlassian.com/api/npm/npm-remote/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==

js-yaml@4.1.0, js-yaml@^4.1.0:
js-yaml@4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.0.tgz#c1fb65f8f5017901cdd2c951864ba18458a10602"
integrity sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==
Expand Down

0 comments on commit 6e3060b

Please sign in to comment.