Skip to content

Commit

Permalink
refactor: removes warnings for deprecated CLI options
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Support for the following CLI options has been dropped: -c, -q/--silent, -l/--level, -b/--sandbox, --hooksData, -t/--timestamp. Please refer to the documentation for more detail.
  • Loading branch information
artem-zakharchenko committed Apr 29, 2019
1 parent efad372 commit 913f49a
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 284 deletions.
51 changes: 0 additions & 51 deletions lib/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,28 +56,11 @@ function coerceRemovedOptions(config = {}) {
const warnings = [];

if (config.options) {
if (config.options.c != null) {
warnings.push('DEPRECATED: Dredd does not support '
+ '-c anymore, use --color/--no-color instead');
config.options.color = coerceToBoolean(config.options.c);
delete config.options.c;
}
if (typeof config.options.color === 'string') {
warnings.push('DEPRECATED: Dredd does not support '
+ `--color=${config.options.color} anymore, use --color/--no-color instead`);
config.options.color = coerceToBoolean(config.options.color);
}
if (config.options.level) {
warnings.push('DEPRECATED: Dredd does not support '
+ '--level anymore, use --loglevel instead');
}
if (config.options.level || config.options.l) {
const level = config.options.level || config.options.l;
if (!['silent', 'error', 'warning', 'debug'].includes(level)) {
warnings.push('DEPRECATED: Dredd does not support '
+ `'${level}' log level anymore, use 'silent', 'error', `
+ "'warning', or 'debug' instead");
}
let loglevel;
if (['silly', 'debug', 'verbose'].includes(level)) {
loglevel = 'debug';
Expand All @@ -92,40 +75,6 @@ function coerceRemovedOptions(config = {}) {
config.options.l = loglevel;
delete config.options.level;
}
if (config.options.timestamp || config.options.t) {
warnings.push('DEPRECATED: Dredd does not support '
+ '--timestamp anymore, use --loglevel=debug instead');
config.options.loglevel = 'debug';
config.options.l = 'debug';
delete config.options.timestamp;
delete config.options.t;
}
if (config.options.silent || config.options.q) {
warnings.push('DEPRECATED: Dredd does not support '
+ '-q/--silent anymore, use --loglevel=silent instead');
config.options.loglevel = 'silent';
config.options.l = 'silent';
delete config.options.silent;
delete config.options.q;
}
if (config.options.sandbox || config.options.b) {
errors.push('REMOVED: Dredd does not support '
+ 'sandboxed JS hooks anymore, use standard JS hooks instead');
delete config.options.sandbox;
delete config.options.b;
}
}
if (config.hooksData) {
errors.push('REMOVED: Dredd does not support '
+ 'sandboxed JS hooks anymore, use standard JS hooks instead');
delete config.hooksData;
}
if (config.blueprintPath) {
warnings.push('DEPRECATED: Dredd does not support '
+ "the 'blueprintPath' option anymore, use 'path' instead");
config.options = config.options || {};
config.options.path = [].concat([config.blueprintPath], coerceToArray(config.options.path));
delete config.blueprintPath;
}
if (config.data) {
warnings.push("DEPRECATED: The 'data' configuration property is deprecated "
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"dredd": "bin/dredd"
},
"engines": {
"node": "^6.9 || >=8"
"node": ">=8"
},
"scripts": {
"docs:lint": "sphinx-build -nW -b linkcheck ./docs ./docs/_build",
Expand Down
232 changes: 0 additions & 232 deletions test/unit/configuration-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,82 +170,6 @@ describe('configuration.applyLoggingOptions()', () => {


describe('configuration._coerceRemovedOptions()', () => {
describe("with -c set to string 'true'", () => {
const config = { options: { c: 'true' } };
let coerceResult;

before(() => {
coerceResult = configuration._coerceRemovedOptions(config);
});

it('gets coerced to color set to boolean true', () => {
assert.deepEqual(config, { options: { color: true } });
});
it('produces no errors', () => {
assert.deepEqual(coerceResult.errors, []);
});
it('produces one warning', () => {
assert.lengthOf(coerceResult.warnings, 1);
});
});

describe("with -c set to string 'false'", () => {
const config = { options: { c: 'false' } };
let coerceResult;

before(() => {
coerceResult = configuration._coerceRemovedOptions(config);
});

it('gets coerced to color set to boolean false', () => {
assert.deepEqual(config, { options: { color: false } });
});
it('produces no errors', () => {
assert.deepEqual(coerceResult.errors, []);
});
it('produces one warning', () => {
assert.lengthOf(coerceResult.warnings, 1);
});
});

describe('with -c set to true', () => {
const config = { options: { c: true } };
let coerceResult;

before(() => {
coerceResult = configuration._coerceRemovedOptions(config);
});

it('gets coerced to color set to boolean true', () => {
assert.deepEqual(config, { options: { color: true } });
});
it('produces no errors', () => {
assert.deepEqual(coerceResult.errors, []);
});
it('produces one warning', () => {
assert.lengthOf(coerceResult.warnings, 1);
});
});

describe('with -c set to false', () => {
const config = { options: { c: false } };
let coerceResult;

before(() => {
coerceResult = configuration._coerceRemovedOptions(config);
});

it('gets coerced to color set to boolean false', () => {
assert.deepEqual(config, { options: { color: false } });
});
it('produces no errors', () => {
assert.deepEqual(coerceResult.errors, []);
});
it('produces one warning', () => {
assert.lengthOf(coerceResult.warnings, 1);
});
});

describe("with --color set to string 'true'", () => {
const config = { options: { color: 'true' } };
let coerceResult;
Expand All @@ -260,9 +184,6 @@ describe('configuration._coerceRemovedOptions()', () => {
it('produces no errors', () => {
assert.deepEqual(coerceResult.errors, []);
});
it('produces one warning', () => {
assert.lengthOf(coerceResult.warnings, 1);
});
});

describe("with --color set to string 'false'", () => {
Expand All @@ -279,9 +200,6 @@ describe('configuration._coerceRemovedOptions()', () => {
it('produces no errors', () => {
assert.deepEqual(coerceResult.errors, []);
});
it('produces one warning', () => {
assert.lengthOf(coerceResult.warnings, 1);
});
});

describe('with --color set to true', () => {
Expand Down Expand Up @@ -338,9 +256,6 @@ describe('configuration._coerceRemovedOptions()', () => {
it('produces no errors', () => {
assert.deepEqual(coerceResult.errors, []);
});
it('produces one warning', () => {
assert.lengthOf(coerceResult.warnings, 1);
});
});

describe('with --level/-l set to a consolidated value', () => {
Expand All @@ -359,9 +274,6 @@ describe('configuration._coerceRemovedOptions()', () => {
it('produces no errors', () => {
assert.deepEqual(coerceResult.errors, []);
});
it('produces two warnings', () => {
assert.lengthOf(coerceResult.warnings, 2);
});
});

describe('with --level/-l set to a removed value', () => {
Expand All @@ -380,9 +292,6 @@ describe('configuration._coerceRemovedOptions()', () => {
it('produces no errors', () => {
assert.deepEqual(coerceResult.errors, []);
});
it('produces two warnings', () => {
assert.lengthOf(coerceResult.warnings, 2);
});
});

describe("with -l set to 'silent'", () => {
Expand All @@ -406,147 +315,6 @@ describe('configuration._coerceRemovedOptions()', () => {
});
});

describe('with --timestamp/-t set', () => {
const config = { options: { timestamp: true, t: true } };
let coerceResult;

before(() => {
coerceResult = configuration._coerceRemovedOptions(config);
});

it('gets coerced to loglevel set to debug', () => {
assert.deepEqual(config, {
options: { l: 'debug', loglevel: 'debug' },
});
});
it('produces no errors', () => {
assert.deepEqual(coerceResult.errors, []);
});
it('produces one warning', () => {
assert.lengthOf(coerceResult.warnings, 1);
});
});

describe('with --silent/-q set', () => {
const config = { options: { silent: true, q: true } };
let coerceResult;

before(() => {
coerceResult = configuration._coerceRemovedOptions(config);
});

it('gets coerced to loglevel set to silent', () => {
assert.deepEqual(config, {
options: { l: 'silent', loglevel: 'silent' },
});
});
it('produces no errors', () => {
assert.deepEqual(coerceResult.errors, []);
});
it('produces one warning', () => {
assert.lengthOf(coerceResult.warnings, 1);
});
});

describe('with --sandbox/-b set', () => {
const config = { options: { sandbox: true, b: true } };
let coerceResult;

before(() => {
coerceResult = configuration._coerceRemovedOptions(config);
});

it('gets removed', () => {
assert.deepEqual(config, { options: {} });
});
it('produces one error', () => {
assert.lengthOf(coerceResult.errors, 1);
});
it('produces no warnings', () => {
assert.deepEqual(coerceResult.warnings, []);
});
});

describe('with hooksData set', () => {
const config = { hooksData: {} };
let coerceResult;

before(() => {
coerceResult = configuration._coerceRemovedOptions(config);
});

it('gets removed', () => {
assert.deepEqual(config, {});
});
it('produces one error', () => {
assert.lengthOf(coerceResult.errors, 1);
});
it('produces no warnings', () => {
assert.deepEqual(coerceResult.warnings, []);
});
});

describe('with blueprintPath set and empty path', () => {
const config = { blueprintPath: 'foo/bar' };
let coerceResult;

before(() => {
coerceResult = configuration._coerceRemovedOptions(config);
});

it('gets reassigned as path', () => {
assert.deepEqual(config, { options: { path: ['foo/bar'] } });
});
it('produces no errors', () => {
assert.deepEqual(coerceResult.errors, []);
});
it('produces no warnings', () => {
assert.lengthOf(coerceResult.warnings, 1);
});
});

describe('with blueprintPath set and path set to a string', () => {
const config = { blueprintPath: 'foo/bar', options: { path: 'moo.js' } };
let coerceResult;

before(() => {
coerceResult = configuration._coerceRemovedOptions(config);
});

it('gets reassigned as path', () => {
assert.deepEqual(config, {
options: { path: ['foo/bar', 'moo.js'] },
});
});
it('produces no errors', () => {
assert.deepEqual(coerceResult.errors, []);
});
it('produces no warnings', () => {
assert.lengthOf(coerceResult.warnings, 1);
});
});

describe('with blueprintPath set and path set to an array', () => {
const config = { blueprintPath: 'foo/bar', options: { path: ['moo.js'] } };
let coerceResult;

before(() => {
coerceResult = configuration._coerceRemovedOptions(config);
});

it('gets reassigned as path', () => {
assert.deepEqual(config, {
options: { path: ['foo/bar', 'moo.js'] },
});
});
it('produces no errors', () => {
assert.deepEqual(coerceResult.errors, []);
});
it('produces no warnings', () => {
assert.lengthOf(coerceResult.warnings, 1);
});
});

describe('with data set to { filename: apiDescription }', () => {
const config = { data: { 'filename.api': 'FORMAT: 1A\n# Sample API\n' } };
let coerceResult;
Expand Down

0 comments on commit 913f49a

Please sign in to comment.