diff --git a/package.json b/package.json index 3c0e2e4dc..844f1859c 100644 --- a/package.json +++ b/package.json @@ -78,6 +78,7 @@ "cross-env": "6.0.3", "detect-secrets": "1.0.5", "eslint": "5.16.0", + "fs-extra": "8.1.0", "get-stdin": "7.0.0", "husky": "2.7.0", "in-publish": "2.0.0", @@ -92,9 +93,9 @@ "standard-version": "7.0.0", "supertest": "4.0.2", "typescript": "3.7.1-rc", + "verdaccio": "latest", "verdaccio-auth-memory": "8.3.0", - "verdaccio-memory": "8.2.0", - "verdaccio": "latest" + "verdaccio-memory": "8.2.0" }, "keywords": [ "private", diff --git a/test/e2e-cli/config/_bootstrap_verdaccio.yaml b/test/e2e-cli/config/_bootstrap_verdaccio.yaml index d699b99c2..50fe65d73 100644 --- a/test/e2e-cli/config/_bootstrap_verdaccio.yaml +++ b/test/e2e-cli/config/_bootstrap_verdaccio.yaml @@ -1,5 +1,9 @@ storage: ./storage +#store: +# memory: +# limit: 1000 + auth: htpasswd: file: ./htpasswd @@ -14,7 +18,7 @@ uplinks: url: https://registry.npmjs.org/ logs: - - { type: stdout, format: pretty, level: info } + - { type: stdout, format: pretty, level: warn } packages: '@*/*': @@ -23,7 +27,7 @@ packages: unpublish: $authenticated proxy: npmjs 'verdaccio': - access: $authenticated + access: $all publish: $anonymous '**': access: $all diff --git a/test/e2e-cli/config/default.yaml b/test/e2e-cli/config/default.yaml new file mode 100644 index 000000000..ae05e1af1 --- /dev/null +++ b/test/e2e-cli/config/default.yaml @@ -0,0 +1,35 @@ +storage: ./storage + +#store: +# memory: +# limit: 1000 + +auth: + htpasswd: + file: ./htpasswd + max_users: -1 + +web: + enable: true + title: verdaccio-default + +uplinks: + npmjs: + url: http://localhost:4873 + +logs: + - { type: stdout, format: pretty, level: info } + +packages: + '@*/*': + access: $all + publish: $anonymous + unpublish: $authenticated + proxy: npmjs + '**': + access: $all + publish: $all + unpublish: $authenticated + proxy: npmjs + +_debug: true diff --git a/test/e2e-cli/projects/basic/package.json b/test/e2e-cli/projects/basic/package.json index 7f1dec508..59afd2e21 100644 --- a/test/e2e-cli/projects/basic/package.json +++ b/test/e2e-cli/projects/basic/package.json @@ -11,8 +11,7 @@ "sample" ], "dependencies": { - "jquery": "^3.4.1", - "lodash": "^4.17.15" + "verdaccio": "latest" }, "author": "Juan Picado ", "license": "MIT" diff --git a/test/e2e-cli/projects/scoped_basic/package.json b/test/e2e-cli/projects/scoped_basic/package.json index add49d051..bfa5b01de 100644 --- a/test/e2e-cli/projects/scoped_basic/package.json +++ b/test/e2e-cli/projects/scoped_basic/package.json @@ -8,7 +8,7 @@ }, "keywords": ["verdaccio", "sample", "scoped"], "dependencies": { - "lodash": "^4.17.15" + "verdaccio": "latest" }, "author": "Juan Picado ", "license": "MIT" diff --git a/test/e2e-cli/test/install/install.spec.ts b/test/e2e-cli/test/install/install.spec.ts index 47e0ff28e..9f9109d74 100644 --- a/test/e2e-cli/test/install/install.spec.ts +++ b/test/e2e-cli/test/install/install.spec.ts @@ -1,5 +1,8 @@ import path from 'path'; import { npm } from '../../utils/process'; +import fs from "fs"; +import * as __global from "../../utils/global"; +import {spawnRegistry} from "../../utils/registry"; function testExample() { console.log('running example'); @@ -11,19 +14,35 @@ export default async function() { } describe('npm install', ()=> { + jest.setTimeout(90000); - beforeAll(() => { + // @ts-ignore + const tempRootFolder = global.__namespace.getItem('dir-root'); + let registryProcess; + + beforeAll(async () => { + const verdaccioInstall = path.join(tempRootFolder, 'verdaccio-root'); + await npm('install', '--prefix', verdaccioInstall, 'verdaccio', '--registry' ,'http://localhost:4873', '--no-package-lock'); + const configPath = path.join(tempRootFolder, 'verdaccio.yaml'); + fs.copyFileSync(path.join(__dirname, '../../config/default.yaml'), configPath); + // @ts-ignore + global.__namespace = __global; + const pathVerdaccioModule = require.resolve('verdaccio/bin/verdaccio', { + paths: [verdaccioInstall] + }); + registryProcess = await spawnRegistry(pathVerdaccioModule, + ['-c', configPath, '-l', '9011'], + { cwd: verdaccioInstall, silent: false } + ); }); test('should install jquery', async () => { - console.log(`New directory: ${process.cwd()}`, __dirname); - process.chdir(path.join(__dirname, '../../projects/basic')); - console.log(`New directory: ${process.cwd()}`); - await npm('install', 'jquery', '--registry' ,'http://localhost:4873'); - - // @ts-ignore - // console.log('--->', global.__namespace.getItem('dir-root')); + await npm('info', 'verdaccio', '--registry' ,'http://localhost:9011'); expect(true).toBe(true); }) + + afterAll(async () => { + registryProcess.kill(); + }); }); diff --git a/test/e2e-cli/test/publish/publish.private.pkg.spec.ts b/test/e2e-cli/test/publish/publish.private.pkg.spec.ts index 58611d442..4aae6fc79 100644 --- a/test/e2e-cli/test/publish/publish.private.pkg.spec.ts +++ b/test/e2e-cli/test/publish/publish.private.pkg.spec.ts @@ -1,5 +1,5 @@ import path from 'path'; -import { npm } from '../../utils/process'; +// import { npm } from '../../utils/process'; function testExample() { console.log('running example'); @@ -10,18 +10,18 @@ export default async function() { await testExample(); } -describe('test example', ()=> { +describe.skip('test example', ()=> { beforeAll(() => { }); - test('sub example', async () => { + test('sub example', async (done) => { console.log(`New directory: ${process.cwd()}`, __dirname); process.chdir(path.join(__dirname, '../../projects/basic')); console.log(`New directory: ${process.cwd()}`); - await npm('install', '--registry' ,'http://localhost:4873'); - + // await npm('install', '--registry' ,'http://localhost:4873'); + done(); // @ts-ignore // console.log('--->', global.__namespace.getItem('dir-root')); expect(true).toBe(true); diff --git a/test/e2e-cli/utils/process.js b/test/e2e-cli/utils/process.js index 8f6aee24c..581a56375 100644 --- a/test/e2e-cli/utils/process.js +++ b/test/e2e-cli/utils/process.js @@ -48,6 +48,7 @@ export async function _exec(options, cmd, args) { return new Promise((resolve, reject) => { childProcess.on('exit', (error) => { // _processes = _processes.filter(p => p !== childProcess); + console.log("--EXIT PROCESS-->", error); if (!error) { resolve({ stdout, stderr }); diff --git a/test/e2e-cli/utils/registry.ts b/test/e2e-cli/utils/registry.ts new file mode 100644 index 000000000..6595ce546 --- /dev/null +++ b/test/e2e-cli/utils/registry.ts @@ -0,0 +1,26 @@ +import {fork} from "child_process"; + +export function prepareEnvironment(rootFolder: string, folderName: string) { + +} + +export function spawnRegistry( + verdaccioPath: string, + args: string[], + childOptions) { + return new Promise((resolve, reject) => { + let _childOptions = {silent: true, ...childOptions}; + + const childFork = fork(verdaccioPath, args, _childOptions); + + childFork.on('message', (msg) => { + if ('verdaccio_started' in msg) { + resolve(childFork); + } + }); + + childFork.on('error', (err) => reject([err])); + childFork.on('disconnect', (err) => reject([err])); + childFork.on('exit', (err) => reject([err])); + }); +} diff --git a/yarn.lock b/yarn.lock index 8acb0a9b5..8d16ca870 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3976,6 +3976,15 @@ fs-access@1.0.1: dependencies: null-check "^1.0.0" +fs-extra@8.1.0: + version "8.1.0" + resolved "https://registry.verdaccio.org/fs-extra/-/fs-extra-8.1.0.tgz#49d43c45a88cd9677668cb7be1b46efdb8d2e1c0" + integrity sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g== + dependencies: + graceful-fs "^4.2.0" + jsonfile "^4.0.0" + universalify "^0.1.0" + fs-minipass@^1.2.5: version "1.2.6" resolved "https://registry.verdaccio.org/fs-minipass/-/fs-minipass-1.2.6.tgz#2c5cc30ded81282bfe8a0d7c7c1853ddeb102c07" @@ -4218,6 +4227,11 @@ graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.1.3 resolved "https://registry.verdaccio.org/graceful-fs/-/graceful-fs-4.2.0.tgz#8d8fdc73977cb04104721cb53666c1ca64cd328b" integrity sha512-jpSvDPV4Cq/bgtpndIWbI5hmYxhQGHPC4d4cqBPb4DLniCfhJokdXhwhaDuLBGLQdvvRum/UiX6ECVIPvDXqdg== +graceful-fs@^4.1.6, graceful-fs@^4.2.0: + version "4.2.3" + resolved "https://registry.verdaccio.org/graceful-fs/-/graceful-fs-4.2.3.tgz#4a12ff1b60376ef09862c2093edd908328be8423" + integrity sha512-a30VEBm4PEdx1dRB7MFK7BejejvCvBronbLjht+sHuGYj8PHs7M/5Z+rt5lw551vZ7yfTCj4Vuyy3mSJytDWRQ== + growly@^1.3.0: version "1.3.0" resolved "https://registry.verdaccio.org/growly/-/growly-1.3.0.tgz#f10748cbe76af964b7c96c93c6bcc28af120c081" @@ -5420,6 +5434,13 @@ json5@^2.1.0: dependencies: minimist "^1.2.0" +jsonfile@^4.0.0: + version "4.0.0" + resolved "https://registry.verdaccio.org/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb" + integrity sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss= + optionalDependencies: + graceful-fs "^4.1.6" + jsonparse@^1.2.0: version "1.3.1" resolved "https://registry.verdaccio.org/jsonparse/-/jsonparse-1.3.1.tgz#3f4dae4a91fac315f71062f8521cc239f1366280" @@ -8340,6 +8361,11 @@ universal-user-agent@^4.0.0: dependencies: os-name "^3.1.0" +universalify@^0.1.0: + version "0.1.2" + resolved "https://registry.verdaccio.org/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66" + integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg== + unix-crypt-td-js@1.0.0: version "1.0.0" resolved "https://registry.verdaccio.org/unix-crypt-td-js/-/unix-crypt-td-js-1.0.0.tgz#1c0824150481bc7a01d49e98f1ec668d82412f3b"