Skip to content

Commit

Permalink
feat(ci-services-plugins): expect ciServices plugins to be provided…
Browse files Browse the repository at this point in the history
… under the `plugins` property

BREAKING CHANGE: the list of `ciServices` plugins are now expected to be provided under the
`plugins` property of the options object. the plugins are expected to be provided as full plugins. a
ciService can no longer define whether they are applicable to public or private projects. a
replacement ability to filter might be provided at some point in the future
  • Loading branch information
travi committed Sep 3, 2024
1 parent db35b7d commit 48bc27c
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 37 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ const {
unitTestFrameworks: {},
applicationTypes: {},
packageTypes: {},
packageBundlers: {}
packageBundlers: {},
ciServices: {}
},
ciServices: {},
decisions: {
[questionNames.DIALECT]: dialects.BABEL,
[questionNames.NODE_VERSION_CATEGORY]: 'LTS',
Expand Down
4 changes: 2 additions & 2 deletions example.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ const {
unitTestFrameworks: {},
applicationTypes: {},
packageTypes: {},
packageBundlers: {}
packageBundlers: {},
ciServices: {}
},
ciServices: {},
decisions: {
[questionNames.DIALECT]: dialects.BABEL,
[questionNames.NODE_VERSION_CATEGORY]: 'LTS',
Expand Down
28 changes: 9 additions & 19 deletions src/options-validator-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -455,42 +455,32 @@ suite('options validator', () => {
license: any.string(),
vcs: {host: any.word(), owner: any.word(), name: any.word()},
description: any.string(),
ciServices: {[ciServiceName]: {}}
plugins: {ciServices: {[ciServiceName]: {}}}
}),
`"ciServices.${ciServiceName}.scaffolder" is required`
`"plugins.ciServices.${ciServiceName}.scaffold" is required`
));

test('that a provided ci-service scaffolder must accept a single argument', () => assert.throws(
test('that a provided ci-service scaffold must accept a single argument', () => assert.throws(
() => validate({
projectRoot: any.string(),
projectName: any.string(),
visibility: any.fromList(['Public', 'Private']),
license: any.string(),
vcs: {host: any.word(), owner: any.word(), name: any.word()},
description: any.string(),
ciServices: {[ciServiceName]: {scaffolder: () => undefined}}
plugins: {ciServices: {[ciServiceName]: {scaffold: () => undefined}}}
}),
`"ciServices.${ciServiceName}.scaffolder" must have an arity of 1`
`"plugins.ciServices.${ciServiceName}.scaffold" must have an arity greater or equal to 1`
));

test('that a provided ci-service scaffolder can be enabled for public projects', () => validate({
test('that a provided ci-service scaffolder can be enabled', () => validate({
projectRoot: any.string(),
projectName: any.string(),
visibility: any.fromList(['Public', 'Private']),
license: any.string(),
vcs: {host: any.word(), owner: any.word(), name: any.word()},
description: any.string(),
ciServices: {[ciServiceName]: {scaffolder: options => options, public: any.boolean()}}
}));

test('that a provided ci-service scaffolder can be enabled for private projects', () => validate({
projectRoot: any.string(),
projectName: any.string(),
visibility: any.fromList(['Public', 'Private']),
license: any.string(),
vcs: {host: any.word(), owner: any.word(), name: any.word()},
description: any.string(),
ciServices: {[ciServiceName]: {scaffolder: options => options, private: any.boolean()}}
plugins: {ciServices: {[ciServiceName]: {scaffold: options => options}}}
}));
});

Expand Down Expand Up @@ -779,9 +769,9 @@ suite('options validator', () => {
monorepoTypes: {},
packageBundlers: {},
unitTestFrameworks: {},
hosts: {}
hosts: {},
ciServices: {}
},
ciServices: {},
registries: {}
}
);
Expand Down
10 changes: 2 additions & 8 deletions src/options-validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,15 @@ export function validate(options) {
remark: joi.string()
}).default({})
})
.keys({
ciServices: joi.object().pattern(/^/, joi.object({
scaffolder: joi.func().arity(1).required(),
public: joi.boolean(),
private: joi.boolean()
})).default({})
})
.keys({
plugins: {
unitTestFrameworks: pluginsSchema,
packageBundlers: pluginsSchema,
applicationTypes: pluginsSchema,
packageTypes: pluginsSchema,
monorepoTypes: pluginsSchema,
hosts: pluginsSchema
hosts: pluginsSchema,
ciServices: pluginsSchema
}
})
.keys({
Expand Down
4 changes: 2 additions & 2 deletions src/scaffolder/scaffolder-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,9 @@ suite('javascript project scaffolder', () => {
packageBundlers,
monorepoTypes,
unitTestFrameworks,
hosts
hosts,
ciServices
},
ciServices,
projectName,
license,
vcs: vcsDetails,
Expand Down
4 changes: 2 additions & 2 deletions src/scaffolder/scaffolder.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export default async function (options) {
vcs,
description,
configs,
ciServices,
decisions,
pathWithinParent,
registries,
Expand All @@ -41,7 +40,8 @@ export default async function (options) {
monorepoTypes,
packageBundlers,
unitTestFrameworks,
hosts
hosts,
ciServices
}
} = validate(options);

Expand Down
4 changes: 2 additions & 2 deletions test/integration/features/step_definitions/common-steps.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ When(/^the project is scaffolded$/, async function () {
projectRoot
})
}
}
},
ciServices: {[any.word()]: {scaffold: foo => ({foo}), public: true}}
},
ciServices: {[any.word()]: {scaffolder: foo => ({foo}), public: true}},
decisions: {
[questionNames.NODE_VERSION_CATEGORY]: 'LTS',
[questionNames.PROJECT_TYPE]: this.projectType,
Expand Down

0 comments on commit 48bc27c

Please sign in to comment.