0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-30 22:34:10 -05:00

chore: consume previous registry installed

This commit is contained in:
Juan Picado @jotadeveloper 2019-12-15 12:07:29 +01:00
parent 3bf2196388
commit e1685d205b
No known key found for this signature in database
GPG key ID: 15AA875EF3768142
10 changed files with 105 additions and 20 deletions

View file

@ -78,6 +78,7 @@
"cross-env": "6.0.3", "cross-env": "6.0.3",
"detect-secrets": "1.0.5", "detect-secrets": "1.0.5",
"eslint": "5.16.0", "eslint": "5.16.0",
"fs-extra": "8.1.0",
"get-stdin": "7.0.0", "get-stdin": "7.0.0",
"husky": "2.7.0", "husky": "2.7.0",
"in-publish": "2.0.0", "in-publish": "2.0.0",
@ -92,9 +93,9 @@
"standard-version": "7.0.0", "standard-version": "7.0.0",
"supertest": "4.0.2", "supertest": "4.0.2",
"typescript": "3.7.1-rc", "typescript": "3.7.1-rc",
"verdaccio": "latest",
"verdaccio-auth-memory": "8.3.0", "verdaccio-auth-memory": "8.3.0",
"verdaccio-memory": "8.2.0", "verdaccio-memory": "8.2.0"
"verdaccio": "latest"
}, },
"keywords": [ "keywords": [
"private", "private",

View file

@ -1,5 +1,9 @@
storage: ./storage storage: ./storage
#store:
# memory:
# limit: 1000
auth: auth:
htpasswd: htpasswd:
file: ./htpasswd file: ./htpasswd
@ -14,7 +18,7 @@ uplinks:
url: https://registry.npmjs.org/ url: https://registry.npmjs.org/
logs: logs:
- { type: stdout, format: pretty, level: info } - { type: stdout, format: pretty, level: warn }
packages: packages:
'@*/*': '@*/*':
@ -23,7 +27,7 @@ packages:
unpublish: $authenticated unpublish: $authenticated
proxy: npmjs proxy: npmjs
'verdaccio': 'verdaccio':
access: $authenticated access: $all
publish: $anonymous publish: $anonymous
'**': '**':
access: $all access: $all

View file

@ -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

View file

@ -11,8 +11,7 @@
"sample" "sample"
], ],
"dependencies": { "dependencies": {
"jquery": "^3.4.1", "verdaccio": "latest"
"lodash": "^4.17.15"
}, },
"author": "Juan Picado <juanpicado19@gmail.com>", "author": "Juan Picado <juanpicado19@gmail.com>",
"license": "MIT" "license": "MIT"

View file

@ -8,7 +8,7 @@
}, },
"keywords": ["verdaccio", "sample", "scoped"], "keywords": ["verdaccio", "sample", "scoped"],
"dependencies": { "dependencies": {
"lodash": "^4.17.15" "verdaccio": "latest"
}, },
"author": "Juan Picado <juanpicado19@gmail.com>", "author": "Juan Picado <juanpicado19@gmail.com>",
"license": "MIT" "license": "MIT"

View file

@ -1,5 +1,8 @@
import path from 'path'; import path from 'path';
import { npm } from '../../utils/process'; import { npm } from '../../utils/process';
import fs from "fs";
import * as __global from "../../utils/global";
import {spawnRegistry} from "../../utils/registry";
function testExample() { function testExample() {
console.log('running example'); console.log('running example');
@ -11,19 +14,35 @@ export default async function() {
} }
describe('npm install', ()=> { 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 () => { test('should install jquery', async () => {
console.log(`New directory: ${process.cwd()}`, __dirname); await npm('info', 'verdaccio', '--registry' ,'http://localhost:9011');
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'));
expect(true).toBe(true); expect(true).toBe(true);
}) })
afterAll(async () => {
registryProcess.kill();
});
}); });

View file

@ -1,5 +1,5 @@
import path from 'path'; import path from 'path';
import { npm } from '../../utils/process'; // import { npm } from '../../utils/process';
function testExample() { function testExample() {
console.log('running example'); console.log('running example');
@ -10,18 +10,18 @@ export default async function() {
await testExample(); await testExample();
} }
describe('test example', ()=> { describe.skip('test example', ()=> {
beforeAll(() => { beforeAll(() => {
}); });
test('sub example', async () => { test('sub example', async (done) => {
console.log(`New directory: ${process.cwd()}`, __dirname); console.log(`New directory: ${process.cwd()}`, __dirname);
process.chdir(path.join(__dirname, '../../projects/basic')); process.chdir(path.join(__dirname, '../../projects/basic'));
console.log(`New directory: ${process.cwd()}`); console.log(`New directory: ${process.cwd()}`);
await npm('install', '--registry' ,'http://localhost:4873'); // await npm('install', '--registry' ,'http://localhost:4873');
done();
// @ts-ignore // @ts-ignore
// console.log('--->', global.__namespace.getItem('dir-root')); // console.log('--->', global.__namespace.getItem('dir-root'));
expect(true).toBe(true); expect(true).toBe(true);

View file

@ -48,6 +48,7 @@ export async function _exec(options, cmd, args) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
childProcess.on('exit', (error) => { childProcess.on('exit', (error) => {
// _processes = _processes.filter(p => p !== childProcess); // _processes = _processes.filter(p => p !== childProcess);
console.log("--EXIT PROCESS-->", error);
if (!error) { if (!error) {
resolve({ stdout, stderr }); resolve({ stdout, stderr });

View file

@ -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]));
});
}

BIN
yarn.lock

Binary file not shown.