refactor: Simplify file tree

This commit is contained in:
Pierre Vanduynslager 2017-11-08 01:00:46 -05:00
parent 332608378a
commit 991a7b5f97
28 changed files with 31 additions and 27 deletions

View File

@ -23,6 +23,6 @@ npx is bundled with npm >= 5.4, or available via npm. More info: npm.im/npx`
}
// node 8+ from this point on
require('../src/cli')().catch(() => {
require('../cli')().catch(() => {
process.exitCode = 1;
});

View File

View File

@ -83,7 +83,9 @@
},
"files": [
"bin",
"src"
"lib",
"index.js",
"cli.js"
],
"homepage": "https://github.com/semantic-release/semantic-release#readme",
"keywords": [
@ -101,7 +103,9 @@
"main": "index.js",
"nyc": {
"include": [
"src/**/*.js"
"lib/**/*.js",
"index.js",
"cli.js"
],
"reporter": [
"json",
@ -130,7 +134,7 @@
"clean": "rimraf coverage && rimraf .nyc_output",
"cm": "git-cz",
"codecov": "codecov -f coverage/coverage-final.json",
"lint": "eslint .",
"lint": "eslint index.js cli.js lib test",
"pretest": "npm run clean && npm run lint",
"semantic-release": "./bin/semantic-release.js",
"test": "nyc ava -v"

View File

@ -19,7 +19,7 @@ test.beforeEach(t => {
// Stub the logger functions
t.context.log = stub();
t.context.error = stub();
t.context.getCommits = proxyquire('../src/lib/get-commits', {
t.context.getCommits = proxyquire('../lib/get-commits', {
'./logger': {log: t.context.log, error: t.context.error},
});
});

View File

@ -12,7 +12,7 @@ test.beforeEach(t => {
// Save the current working diretory
t.context.cwd = process.cwd();
t.context.plugins = stub().returns({});
t.context.getConfig = proxyquire('../src/lib/get-config', {'./plugins': t.context.plugins});
t.context.getConfig = proxyquire('../lib/get-config', {'./plugins': t.context.plugins});
});
test.afterEach.always(t => {

View File

@ -6,7 +6,7 @@ import SemanticReleaseError from '@semantic-release/error';
test.beforeEach(t => {
// Stub the logger functions
t.context.log = stub();
t.context.getNextVersion = proxyquire('../src/lib/get-next-version', {'./logger': {log: t.context.log}});
t.context.getNextVersion = proxyquire('../lib/get-next-version', {'./logger': {log: t.context.log}});
});
test('Increase version for patch release', t => {

View File

@ -1,6 +1,6 @@
import test from 'ava';
import {stub} from 'sinon';
const getRegistry = require('../src/lib/get-registry');
const getRegistry = require('../lib/get-registry');
test('Get registry from package.json', t => {
// Retrieve the registry with the get-registry module and verify it returns the one from the package.json in parameter

View File

@ -2,7 +2,7 @@ import test from 'ava';
import {gitRepo, gitCommits, gitHead} from './helpers/git-utils';
import nock from 'nock';
import {authenticate} from './helpers/mock-github';
import githubRelease from '../src/lib/github-release';
import githubRelease from '../lib/github-release';
test.beforeEach(t => {
// Save the current working diretory

View File

@ -59,7 +59,7 @@ test('Plugins are called with expected values', async t => {
npm,
});
const semanticRelease = proxyquire('../src/index', {
const semanticRelease = proxyquire('../index', {
'./lib/logger': logger,
'./lib/verify-auth': verifyAuth,
'./lib/get-config': getConfig,
@ -152,7 +152,7 @@ test('Dry-run skips verifyAuth, verifyConditions, publishNpm and githubRelease',
npm,
});
const semanticRelease = proxyquire('../src/index', {
const semanticRelease = proxyquire('../index', {
'./lib/logger': logger,
'./lib/verify-auth': verifyAuth,
'./lib/get-config': getConfig,
@ -243,7 +243,7 @@ test('Throw SemanticReleaseError if there is no release to be done', async t =>
npm,
});
const semanticRelease = proxyquire('../src/index', {
const semanticRelease = proxyquire('../index', {
'./lib/logger': logger,
'./lib/verify-auth': verifyAuth,
'./lib/get-config': getConfig,

View File

@ -5,7 +5,7 @@ import execa from 'execa';
import {gitRepo, gitCommits, gitHead, gitTagVersion, gitPackRefs, gitAmmendCommit} from './helpers/git-utils';
import registry from './helpers/registry';
import mockServer from './helpers/mockserver';
import semanticRelease from '../src';
import semanticRelease from '..';
// Environment variables used with cli
const env = {
@ -15,7 +15,7 @@ const env = {
NPM_EMAIL: 'integration@test.com',
};
const cli = require.resolve('../bin/semantic-release');
const noop = require.resolve('../src/lib/plugin-noop');
const noop = require.resolve('../lib/plugin-noop');
const pluginError = require.resolve('./fixtures/plugin-error-a');
const pluginInheritedError = require.resolve('./fixtures/plugin-error-inherited');

View File

@ -1,6 +1,6 @@
import test from 'ava';
import {stub, match} from 'sinon';
import logger from '../src/lib/logger';
import logger from '../lib/logger';
test.beforeEach(t => {
t.context.log = stub(console, 'log');

View File

@ -6,7 +6,7 @@ import {stub, match} from 'sinon';
test.beforeEach(t => {
// Stub the logger functions
t.context.log = stub();
t.context.plugins = proxyquire('../src/lib/plugins', {'./logger': {log: t.context.log}});
t.context.plugins = proxyquire('../lib/plugins', {'./logger': {log: t.context.log}});
});
test('Export plugins', t => {
@ -24,7 +24,7 @@ test('Export plugins', t => {
test('Pipeline - Get all results', async t => {
// Call the plugin module with a verifyRelease plugin pipeline
const pipelinePlugins = t.context.plugins({
verifyRelease: ['./src/lib/plugin-noop', './test/fixtures/plugin-result-a', './test/fixtures/plugin-result-b'],
verifyRelease: ['./lib/plugin-noop', './test/fixtures/plugin-result-a', './test/fixtures/plugin-result-b'],
});
// Call the verifyRelease pipeline
@ -33,7 +33,7 @@ test('Pipeline - Get all results', async t => {
// Verify the pipeline return the expected result for each plugin, in order
t.deepEqual(results, [undefined, 'a', 'b']);
// Verify the logger has been called with the plugins path
t.true(t.context.log.calledWith(match.string, './src/lib/plugin-noop'));
t.true(t.context.log.calledWith(match.string, './lib/plugin-noop'));
t.true(t.context.log.calledWith(match.string, './test/fixtures/plugin-result-a'));
t.true(t.context.log.calledWith(match.string, './test/fixtures/plugin-result-b'));
});
@ -60,34 +60,34 @@ test('Pipeline - Pass pluginConfig and options to each plugins', async t => {
test('Pipeline - Get first error', async t => {
// Call the plugin module with a verifyRelease plugin pipeline
const pipelinePlugins = t.context.plugins({
verifyRelease: ['./src/lib/plugin-noop', './test/fixtures/plugin-error-a', './test/fixtures/plugin-error-b'],
verifyRelease: ['./lib/plugin-noop', './test/fixtures/plugin-error-a', './test/fixtures/plugin-error-b'],
});
// Call the verifyRelease pipeline and verify it returns the error thrown by './test/fixtures/plugin-error-a'
await t.throws(pipelinePlugins.verifyRelease({}), 'a');
// Verify the logger has been called with the plugins path
t.true(t.context.log.calledWith(match.string, './src/lib/plugin-noop'));
t.true(t.context.log.calledWith(match.string, './lib/plugin-noop'));
t.true(t.context.log.calledWith(match.string, './test/fixtures/plugin-error-a'));
});
test('Normalize and load plugin from string', t => {
// Call the normalize function with a path
const plugin = t.context.plugins.normalize('./src/lib/plugin-noop');
const plugin = t.context.plugins.normalize('./lib/plugin-noop');
// Verify the plugin is loaded
t.is(typeof plugin, 'function');
// Verify the logger has been called with the plugins path
t.true(t.context.log.calledWith(match.string, './src/lib/plugin-noop'));
t.true(t.context.log.calledWith(match.string, './lib/plugin-noop'));
});
test('Normalize and load plugin from object', t => {
// Call the normalize function with an object (with path property)
const plugin = t.context.plugins.normalize({path: './src/lib/plugin-noop'});
const plugin = t.context.plugins.normalize({path: './lib/plugin-noop'});
// Verify the plugin is loaded
t.is(typeof plugin, 'function');
// Verify the logger has been called with the plugins path
t.true(t.context.log.calledWith(match.string, './src/lib/plugin-noop'));
t.true(t.context.log.calledWith(match.string, './lib/plugin-noop'));
});
test('Load from fallback', t => {
@ -116,7 +116,7 @@ test('Always pass a defined "pluginConfig" for plugin defined with path', async
test('Always pass a defined "pluginConfig" for fallback plugin', async t => {
// Call the normalize function with the path of a plugin that returns its config
const plugin = t.context.plugins.normalize(null, '../../test/fixtures/plugin-result-config');
const plugin = t.context.plugins.normalize(null, '../test/fixtures/plugin-result-config');
const pluginResult = await promisify(plugin)({});
t.deepEqual(pluginResult.pluginConfig, {});

View File

@ -1,6 +1,6 @@
import test from 'ava';
import SemanticReleaseError from '@semantic-release/error';
import verify from '../src/lib/verify-auth';
import verify from '../lib/verify-auth';
test('Verify npm and github auth', t => {
// Call the verify module with options and env

View File

@ -1,6 +1,6 @@
import test from 'ava';
import SemanticReleaseError from '@semantic-release/error';
import verify from '../src/lib/verify-pkg';
import verify from '../lib/verify-pkg';
test('Verify name and repository', t => {
// Call the verify module with package