Skip to content

Commit 1d40beb

Browse files
committed
feat(options): removed overrides from the potential options to provide
since `decisions` is the more appropriate approach to this anyway BREAKING CHANGE: `overrides` is no longer a support option. use `decisions` instead
1 parent 5cbd216 commit 1d40beb

10 files changed

+19
-58
lines changed

README.md

-11
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ opinionated scaffolder for new projects
2424
* [`languages` (_optional_)](#languages-optional)
2525
* [`vcsHosts` (_optional_)](#vcshosts-optional)
2626
* [`dependencyUpdaters` (_optional_)](#dependencyupdaters-optional)
27-
* [`overrides` (_optional_) (_deprecated_)](#overrides-optional-deprecated)
28-
* [`copyrightHolder`](#copyrightholder)
2927
* [Contributing](#contributing)
3028
* [Dependencies](#dependencies)
3129
* [Verification](#verification)
@@ -195,15 +193,6 @@ __object__:
195193
* `owner`: __string__ account name on the host service for the repository
196194
owner. defaults to `$ git config github.user`
197195

198-
#### `overrides` (_optional_) (_deprecated_)
199-
200-
use `decisions` instead of `overrides`
201-
202-
##### `copyrightHolder`
203-
204-
__string__ enables setting the value of the prompt default for the copyright
205-
holder. if not provided, the default will be empty.
206-
207196
## Contributing
208197

209198
<!--contribution-badges start -->

src/options-schemas.js

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
import joi from 'joi';
22

3-
export const overridesSchema = joi.object({copyrightHolder: joi.string()});
4-
53
export const decisionsSchema = joi.object();

src/options-schemas.test.js

+1-18
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,9 @@ import {validateOptions} from '@form8ion/core';
33
import {describe, expect, it} from 'vitest';
44
import any from '@travi/any';
55

6-
import {overridesSchema, decisionsSchema} from './options-schemas';
6+
import {decisionsSchema} from './options-schemas';
77

88
describe('generic options schemas', () => {
9-
describe('overrides', () => {
10-
it('should return the validated options', () => {
11-
const options = {copyrightHolder: any.string()};
12-
13-
expect(validateOptions(overridesSchema, options)).toEqual(options);
14-
});
15-
16-
it('should require the overrides to be defined as a map', () => {
17-
expect(() => validateOptions(overridesSchema, any.word())).toThrowError('must be of type object');
18-
});
19-
20-
it('should require `copyrightHolder` to be a string', () => {
21-
expect(() => validateOptions(overridesSchema, {copyrightHolder: any.simpleObject()}))
22-
.toThrowError('must be a string');
23-
});
24-
});
25-
269
describe('decisions', () => {
2710
it('should return the validated options', () => {
2811
const options = any.simpleObject();

src/options-validator.js

+4-8
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
import {validateOptions} from '@form8ion/core';
22
import joi from 'joi';
33

4-
import languagePluginsSchema from './language/schema';
5-
import vcsHostPluginsSchema from './vcs/host/schema';
6-
import dependencyUpdaterPluginsSchema from './dependency-updater/schema';
7-
import {decisionsSchema, overridesSchema} from './options-schemas';
4+
import languagePluginsSchema from './language/schema.js';
5+
import vcsHostPluginsSchema from './vcs/host/schema.js';
6+
import dependencyUpdaterPluginsSchema from './dependency-updater/schema.js';
7+
import {decisionsSchema} from './options-schemas.js';
88

99
export function validate(options) {
1010
return validateOptions(joi.object({
1111
languages: languagePluginsSchema,
12-
/**
13-
* @deprecated overrides should no longer be necessary. use decisions instead
14-
*/
15-
overrides: overridesSchema,
1612
vcsHosts: vcsHostPluginsSchema,
1713
decisions: decisionsSchema,
1814
dependencyUpdaters: dependencyUpdaterPluginsSchema

src/options-validator.test.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import {describe, expect, it, beforeEach, afterEach, vi} from 'vitest';
55
import any from '@travi/any';
66
import {when} from 'jest-when';
77

8-
import languagePluginsSchema from './language/schema';
9-
import {decisionsSchema, overridesSchema} from './options-schemas';
10-
import vcsHostPluginsSchema from './vcs/host/schema';
11-
import dependencyUpdaterPluginsSchema from './dependency-updater/schema';
12-
import {validate} from './options-validator';
8+
import languagePluginsSchema from './language/schema.js';
9+
import {decisionsSchema} from './options-schemas.js';
10+
import vcsHostPluginsSchema from './vcs/host/schema.js';
11+
import dependencyUpdaterPluginsSchema from './dependency-updater/schema.js';
12+
import {validate} from './options-validator.js';
1313

1414
vi.mock('@form8ion/core');
1515

@@ -28,7 +28,6 @@ describe('options validator', () => {
2828
const validatedOptions = any.simpleObject();
2929
when(joi.object).calledWith({
3030
languages: languagePluginsSchema,
31-
overrides: overridesSchema,
3231
vcsHosts: vcsHostPluginsSchema,
3332
decisions: decisionsSchema,
3433
dependencyUpdaters: dependencyUpdaterPluginsSchema

src/prompts/questions.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import {prompt} from '@form8ion/overridable-prompts';
33

44
import {questionNames} from './question-names';
55

6-
export function promptForBaseDetails(projectRoot, copyrightHolder, decisions) {
6+
export function promptForBaseDetails(projectRoot, decisions) {
77
return prompt([
8-
...questionsForBaseDetails(decisions, projectRoot, copyrightHolder),
8+
...questionsForBaseDetails(decisions, projectRoot),
99
{name: questionNames.GIT_REPO, type: 'confirm', default: true, message: 'Should a git repository be initialized?'}
1010
], decisions);
1111
}

src/prompts/questions.test.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ describe('base details prompt', () => {
2222
});
2323

2424
it('should prompt for the necessary details', async () => {
25-
const copyrightHolder = any.string();
26-
when(core.questionsForBaseDetails).calledWith(decisions, projectPath, copyrightHolder).mockReturnValue(questions);
25+
when(core.questionsForBaseDetails).calledWith(decisions, projectPath).mockReturnValue(questions);
2726
when(prompts.prompt).calledWith([
2827
...questions,
2928
{
@@ -34,6 +33,6 @@ describe('base details prompt', () => {
3433
}
3534
], decisions).mockResolvedValue(answers);
3635

37-
expect(await promptForBaseDetails(projectPath, copyrightHolder, decisions)).toEqual(answers);
36+
expect(await promptForBaseDetails(projectPath, decisions)).toEqual(answers);
3837
});
3938
});

src/scaffolder.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ import {scaffold as scaffoldContributing} from './contributing';
1818

1919
export async function scaffold(options) {
2020
const projectRoot = process.cwd();
21-
const {languages = {}, overrides = {}, vcsHosts = {}, decisions, dependencyUpdaters} = validate(options);
22-
const {copyrightHolder} = overrides;
21+
const {languages = {}, vcsHosts = {}, decisions, dependencyUpdaters} = validate(options);
2322

2423
const {
2524
[coreQuestionNames.PROJECT_NAME]: projectName,
@@ -29,7 +28,7 @@ export async function scaffold(options) {
2928
[questionNames.GIT_REPO]: gitRepo,
3029
[coreQuestionNames.COPYRIGHT_YEAR]: copyrightYear,
3130
[coreQuestionNames.COPYRIGHT_HOLDER]: copyHolder
32-
} = await promptForBaseDetails(projectRoot, copyrightHolder, decisions);
31+
} = await promptForBaseDetails(projectRoot, decisions);
3332
const copyright = {year: copyrightYear, holder: copyHolder};
3433

3534
const vcs = await initializeGit(gitRepo, projectRoot, projectName, vcsHosts, visibility, decisions);

src/scaffolder.test.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,16 @@ describe('project scaffolder', () => {
7171
const year = any.word();
7272
const holder = any.sentence();
7373
const copyright = {year, holder};
74-
const overrides = {...any.simpleObject(), copyrightHolder: any.string()};
7574
const gitRepoShouldBeInitialized = true;
7675
const dependencyUpdaters = any.simpleObject();
7776
const gitNextSteps = any.listOf(any.simpleObject);
7877
const dependencyUpdaterNextSteps = any.listOf(any.simpleObject);
7978
const dependencyUpdaterContributionBadges = any.simpleObject();
8079
when(optionsValidator.validate)
8180
.calledWith(options)
82-
.mockReturnValue({languages: languageScaffolders, overrides, vcsHosts, decisions, dependencyUpdaters});
81+
.mockReturnValue({languages: languageScaffolders, vcsHosts, decisions, dependencyUpdaters});
8382
when(prompts.promptForBaseDetails)
84-
.calledWith(projectPath, overrides.copyrightHolder, decisions)
83+
.calledWith(projectPath, decisions)
8584
.mockResolvedValue({
8685
[coreQuestionNames.PROJECT_NAME]: projectName,
8786
[questionNames.GIT_REPO]: gitRepoShouldBeInitialized,
@@ -162,7 +161,7 @@ describe('project scaffolder', () => {
162161
const gitRepoShouldBeInitialized = any.boolean();
163162
optionsValidator.validate.mockReturnValue({});
164163
when(prompts.promptForBaseDetails)
165-
.calledWith(projectPath, undefined, undefined)
164+
.calledWith(projectPath, undefined)
166165
.mockResolvedValue({
167166
[coreQuestionNames.PROJECT_NAME]: projectName,
168167
[questionNames.GIT_REPO]: gitRepoShouldBeInitialized

test/integration/features/step_definitions/common-steps.mjs

-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ When(/^the project is scaffolded$/, async function () {
6161
}
6262
}
6363
},
64-
overrides: {},
6564
...this.updaterScaffolderDetails && {dependencyUpdaters: {[chosenUpdater]: this.updaterScaffolderDetails}},
6665
...vcsHost && {
6766
vcsHosts: {

0 commit comments

Comments
 (0)