2021-03-14 08:42:46 +01:00
|
|
|
import fs from 'fs';
|
|
|
|
import path from 'path';
|
|
|
|
import os from 'os';
|
|
|
|
import { spawn } from 'child_process';
|
2020-08-13 23:36:23 +02:00
|
|
|
import { yellow } from 'kleur';
|
2019-12-15 08:52:55 +01:00
|
|
|
import { npm } from '../utils/process';
|
|
|
|
import * as __global from '../utils/global.js';
|
|
|
|
|
|
|
|
module.exports = async () => {
|
2021-03-14 08:42:46 +01:00
|
|
|
const tempRoot = fs.mkdtempSync(path.join(fs.realpathSync(os.tmpdir()), 'verdaccio-cli-e2e-'));
|
|
|
|
__global.addItem('dir-root', tempRoot);
|
2020-08-13 23:36:23 +02:00
|
|
|
console.log(yellow(`Add temp root folder: ${tempRoot}`));
|
|
|
|
fs.copyFileSync(path.join(__dirname, '../config/_bootstrap_verdaccio.yaml'), path.join(tempRoot, 'verdaccio.yaml'));
|
2021-03-14 08:42:46 +01:00
|
|
|
// @ts-ignore
|
|
|
|
global.__namespace = __global;
|
|
|
|
console.log(`current directory: ${process.cwd()}`);
|
|
|
|
// @ts-ignore
|
2020-08-13 23:36:23 +02:00
|
|
|
global.registryProcess = spawn(
|
|
|
|
'node',
|
|
|
|
[require.resolve('verdaccio/bin/verdaccio'), '-c', './verdaccio.yaml'],
|
|
|
|
// @ts-ignore
|
|
|
|
{ cwd: tempRoot, silence: true }
|
|
|
|
);
|
2019-12-15 08:52:55 +01:00
|
|
|
|
2021-03-14 08:42:46 +01:00
|
|
|
// publish current build version on local registry
|
2020-08-13 23:36:23 +02:00
|
|
|
await npm('publish', '--registry', 'http://localhost:4873');
|
2021-03-14 08:42:46 +01:00
|
|
|
};
|