Skip to content

Instantly share code, notes, and snippets.

@dfee
Created August 30, 2021 22:28
Show Gist options
  • Select an option

  • Save dfee/7b58ba2ac6f2499bb0dd557ebba6acdc to your computer and use it in GitHub Desktop.

Select an option

Save dfee/7b58ba2ac6f2499bb0dd557ebba6acdc to your computer and use it in GitHub Desktop.

Revisions

  1. dfee created this gist Aug 30, 2021.
    45 changes: 45 additions & 0 deletions index.ts
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,45 @@
    import startServer from "verdaccio";

    const PORT = 4873
    const STORAGE = "./storage";
    const CONFIG = {
    storage: STORAGE,
    uplinks: {
    "npmjs": {
    "url": "https://registry.npmjs.org/"
    }
    },
    packages: {
    "@demo/*": {
    "access": "$all",
    "publish": "$anonymous",
    "proxy": "npmjs"
    },
    "**": {
    "proxy": "npmjs"
    }
    },
    logs: [
    {
    "type": "stdout",
    "format": "pretty",
    "level": "http"
    }
    ]
    }


    async function onReady(webServer: any): Promise<void> {
    return new Promise(resolve => {
    console.log('verdaccio port %s', PORT);
    webServer.listen(PORT, () => {
    resolve(webServer);
    });
    });
    }

    export async function doStart(): Promise<void> {
    startServer(CONFIG, '6000', STORAGE, '1.0.0', 'verdaccio', onReady);
    }

    doStart()
    19 changes: 19 additions & 0 deletions package.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    {
    "name": "@demo/foo",
    "version": "1.0.0",
    "description": "",
    "main": "index.js",
    "scripts": {
    "start:dev": "ts-node --files src",
    "test": "echo \"Error: no test specified\" && exit 1"
    },
    "keywords": [],
    "author": "",
    "license": "ISC",
    "devDependencies": {
    "@types/node": "^16.7.8",
    "ts-node": "^10.2.1",
    "typescript": "^4.4.2",
    "verdaccio": "^5.1.3"
    }
    }
    14 changes: 14 additions & 0 deletions tsconfig.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    {
    "compilerOptions": {
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "module": "commonjs",
    "outDir": "./dist",
    "skipLibCheck": true,
    "strict": true,
    "target": "es5",
    },
    "include": [
    "./**/*.ts",
    ],
    }
    10 changes: 10 additions & 0 deletions types.d.ts
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    declare module "verdaccio" {
    export default function (
    config: any,
    cliListen: string,
    configPath: string,
    pkgVersion: string,
    pkgName: string,
    callback: Function
    ): void;
    }