Skip to content
This repository has been archived by the owner on Mar 14, 2022. It is now read-only.

Commit

Permalink
Verify the component follows v2 of the Origami component specification.
Browse files Browse the repository at this point in the history
Rather than v1, which will not be supported in the next major version
of Origami Build Tools
  • Loading branch information
notlee committed Jan 11, 2021
1 parent f4b3e8b commit 7e6a9f1
Show file tree
Hide file tree
Showing 23 changed files with 41 additions and 37 deletions.
4 changes: 2 additions & 2 deletions lib/tasks/verify-origami-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ function origamiJson(config) {
if (origamiJson.origamiType !== 'imageset' && origamiJson.origamiType !== 'module' && origamiJson.origamiType !== 'service') {
result.push('The origamiType property needs to be set to either "imageset", "module" or "service"');
}
if (origamiJson.origamiVersion !== 1) {
result.push('The origamiVersion property needs to be set to 1');
if (origamiJson.origamiVersion !== 2) {
result.push('The origamiVersion property needs to be set to 2, this version of Origami Build tools only supports v2 of the Origami component specification.');
}
if (!origamiJson.support) {
result.push('The support property must be an email or url to an issue tracker for this module');
Expand Down
2 changes: 1 addition & 1 deletion test/integration/demo/fixtures/multiple-demos/origami.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"keywords": [],
"origamiType": "module",
"origamiCategory": "components",
"origamiVersion": 1,
"origamiVersion": 2,
"brands": ["master"],
"support": "https://github.com/Financial-Times/o-multiple-demos/issues",
"supportContact": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"keywords": [],
"origamiType": "module",
"origamiCategory": "components",
"origamiVersion": 1,
"origamiVersion": 2,
"brands": [],
"support": "https://github.com/Financial-Times/o-example/issues",
"supportContact": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"keywords": [],
"origamiType": "module",
"origamiCategory": "components",
"origamiVersion": 1,
"origamiVersion": 2,
"brands": [],
"support": "https://github.com/Financial-Times/o-example/issues",
"supportContact": {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/verify/fixtures/js-es5/origami.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"keywords": [],
"origamiType": "module",
"origamiCategory": "components",
"origamiVersion": 1,
"origamiVersion": 2,
"brands": [],
"support": "https://github.com/Financial-Times/o-example/issues",
"supportContact": {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/verify/fixtures/js-es6/origami.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"keywords": [],
"origamiType": "module",
"origamiCategory": "components",
"origamiVersion": 1,
"origamiVersion": 2,
"brands": [],
"support": "https://github.com/Financial-Times/o-example/issues",
"supportContact": {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/verify/fixtures/js-es7/origami.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"keywords": [],
"origamiType": "module",
"origamiCategory": "components",
"origamiVersion": 1,
"origamiVersion": 2,
"brands": [],
"support": "https://github.com/Financial-Times/o-example/issues",
"supportContact": {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/verify/fixtures/js-invalid/origami.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"keywords": [],
"origamiType": "module",
"origamiCategory": "components",
"origamiVersion": 1,
"origamiVersion": 2,
"brands": [],
"support": "https://github.com/Financial-Times/o-example/issues",
"supportContact": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"keywords": [],
"origamiType": "module",
"origamiCategory": "components",
"origamiVersion": 1,
"origamiVersion": 2,
"brands": [],
"support": "https://github.com/Financial-Times/o-example/issues",
"supportContact": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"keywords": [],
"origamiType": "module",
"origamiCategory": "components",
"origamiVersion": 1,
"origamiVersion": 2,
"brands": [],
"support": "https://github.com/Financial-Times/o-example/issues",
"supportContact": {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/verify/fixtures/no-readme/origami.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"keywords": [],
"origamiType": "module",
"origamiCategory": "components",
"origamiVersion": 1,
"origamiVersion": 2,
"brands": [],
"support": "https://github.com/Financial-Times/o-example/issues",
"supportContact": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"keywords": [],
"origamiType": "module",
"origamiCategory": "components",
"origamiVersion": 1,
"origamiVersion": 2,
"brands": [],
"support": "https://github.com/Financial-Times/o-example/issues",
"supportContact": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"keywords": [],
"origamiType": "module",
"origamiCategory": "components",
"origamiVersion": 1,
"origamiVersion": 2,
"brands": [],
"support": "https://github.com/Financial-Times/o-example/issues",
"supportContact": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"keywords": [],
"origamiType": "module",
"origamiCategory": "components",
"origamiVersion": 1,
"origamiVersion": 2,
"brands": [],
"support": "https://github.com/Financial-Times/o-example/issues",
"supportContact": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"keywords": [],
"origamiType": "module",
"origamiCategory": "components",
"origamiVersion": 1,
"origamiVersion": 2,
"brands": [],
"support": "https://github.com/Financial-Times/o-example/issues",
"supportContact": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"keywords": [],
"origamiType": "module",
"origamiCategory": "components",
"origamiVersion": 1,
"origamiVersion": 2,
"brands": [],
"support": "https://github.com/Financial-Times/o-example/issues",
"supportContact": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"keywords": [],
"origamiType": "module",
"origamiCategory": "components",
"origamiVersion": 1,
"origamiVersion": 2,
"brands": [],
"support": "https://github.com/Financial-Times/o-example/issues",
"supportContact": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"keywords": [],
"origamiType": "module",
"origamiCategory": "components",
"origamiVersion": 1,
"origamiVersion": 2,
"brands": [],
"support": "https://github.com/Financial-Times/o-example/issues",
"supportContact": {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/verify/fixtures/sass-invalid/origami.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"keywords": [],
"origamiType": "module",
"origamiCategory": "components",
"origamiVersion": 1,
"origamiVersion": 2,
"brands": [],
"support": "https://github.com/Financial-Times/o-example/issues",
"supportContact": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"keywords": [],
"origamiType": "module",
"origamiCategory": "components",
"origamiVersion": 1,
"origamiVersion": 2,
"brands": [],
"support": "https://github.com/Financial-Times/o-example/issues",
"supportContact": {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/verify/fixtures/sass/origami.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"keywords": [],
"origamiType": "module",
"origamiCategory": "components",
"origamiVersion": 1,
"origamiVersion": 2,
"brands": [],
"support": "https://github.com/Financial-Times/o-example/issues",
"supportContact": {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/fixtures/o-test/origami.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"description": "Test module",
"origamiType": "module",
"origamiVersion": 1,
"origamiVersion": 2,
"support": "[email protected]",
"supportStatus": "active",
"demosDefaults": {
Expand Down
32 changes: 18 additions & 14 deletions test/unit/tasks/verify-origami-json.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ describe('verify-origami-json', function () {
'Failed linting:\n\n' +
'A non-empty description property is required\n' +
'The origamiType property needs to be set to either "imageset", "module" or "service"\n' +
'The origamiVersion property needs to be set to 1\n' +
'The origamiVersion property needs to be set to 2, this version of Origami Build tools only supports v2 of the Origami component specification.\n' +
'The support property must be an email or url to an issue tracker for this module\n' +
'The supportStatus property must be set to either "active", "maintained", "deprecated", "dead" or "experimental"\n\n' +
'The origami.json file does not conform to the specification at http://origami.ft.com/docs/syntax/origamijson/'
Expand All @@ -121,7 +121,7 @@ describe('verify-origami-json', function () {
proclaim.calledOnce(console.log);
proclaim.calledWithExactly(
console.log,
`::error file=origami.json,line=1,col=1::Failed linting:%0A%0AA non-empty description property is required%0AThe origamiType property needs to be set to either "imageset", "module" or "service"%0AThe origamiVersion property needs to be set to 1%0AThe support property must be an email or url to an issue tracker for this module%0AThe supportStatus property must be set to either "active", "maintained", "deprecated", "dead" or "experimental"%0A%0AThe origami.json file does not conform to the specification at http://origami.ft.com/docs/syntax/origamijson/`
`::error file=origami.json,line=1,col=1::Failed linting:%0A%0AA non-empty description property is required%0AThe origamiType property needs to be set to either "imageset", "module" or "service"%0AThe origamiVersion property needs to be set to 2, this version of Origami Build tools only supports v2 of the Origami component specification.%0AThe support property must be an email or url to an issue tracker for this module%0AThe supportStatus property must be set to either "active", "maintained", "deprecated", "dead" or "experimental"%0A%0AThe origami.json file does not conform to the specification at http://origami.ft.com/docs/syntax/origamijson/`
);
}
});
Expand Down Expand Up @@ -184,7 +184,7 @@ describe('verify-origami-json', function () {
proclaim.calledOnce(console.log);
proclaim.calledWithExactly(
console.log,
`::error file=origami.json,line=1,col=1::Failed linting:%0A%0AA non-empty description property is required%0AThe origamiType property needs to be set to either "imageset", "module" or "service"%0AThe origamiVersion property needs to be set to 1%0AThe support property must be an email or url to an issue tracker for this module%0AThe supportStatus property must be set to either "active", "maintained", "deprecated", "dead" or "experimental"%0A%0AThe origami.json file does not conform to the specification at http://origami.ft.com/docs/syntax/origamijson/`
`::error file=origami.json,line=1,col=1::Failed linting:%0A%0AA non-empty description property is required%0AThe origamiType property needs to be set to either "imageset", "module" or "service"%0AThe origamiVersion property needs to be set to 2, this version of Origami Build tools only supports v2 of the Origami component specification.%0AThe support property must be an email or url to an issue tracker for this module%0AThe supportStatus property must be set to either "active", "maintained", "deprecated", "dead" or "experimental"%0A%0AThe origami.json file does not conform to the specification at http://origami.ft.com/docs/syntax/origamijson/`
);
});
});
Expand Down Expand Up @@ -268,41 +268,41 @@ describe('verify-origami-json', function () {
proclaim.equal(
verifiedOrigamiJson.message,
'Failed linting:\n\n' +
'The origamiVersion property needs to be set to 1\n\n' +
'The origamiVersion property needs to be set to 2, this version of Origami Build tools only supports v2 of the Origami component specification.\n\n' +
'The origami.json file does not conform to the specification at http://origami.ft.com/docs/syntax/origamijson/'
);
proclaim.calledOnce(console.log);
proclaim.calledWithExactly(
console.log,
`::error file=origami.json,line=1,col=1::Failed linting:%0A%0AThe origamiVersion property needs to be set to 1%0A%0AThe origami.json file does not conform to the specification at http://origami.ft.com/docs/syntax/origamijson/`
`::error file=origami.json,line=1,col=1::Failed linting:%0A%0AThe origamiVersion property needs to be set to 2, this version of Origami Build tools only supports v2 of the Origami component specification.%0A%0AThe origami.json file does not conform to the specification at http://origami.ft.com/docs/syntax/origamijson/`
);
});
});

it('should fail if origamiVersion property is not 1', function () {
it('should fail if origamiVersion property is not 2', function () {
const origamiJSON = JSON.parse(fs.readFileSync(path.join(process.cwd(), 'origami.json'), 'utf-8'));
origamiJSON.origamiVersion = 2;
origamiJSON.origamiVersion = 1;
fs.writeFileSync('origami.json', JSON.stringify(origamiJSON), 'utf8');

return verifyOrigamiJson().task()
.catch(function (verifiedOrigamiJson) {
proclaim.equal(
verifiedOrigamiJson.message,
'Failed linting:\n\n' +
'The origamiVersion property needs to be set to 1\n\n' +
'The origamiVersion property needs to be set to 2, this version of Origami Build tools only supports v2 of the Origami component specification.\n\n' +
'The origami.json file does not conform to the specification at http://origami.ft.com/docs/syntax/origamijson/'
);
proclaim.calledOnce(console.log);
proclaim.calledWithExactly(
console.log,
`::error file=origami.json,line=1,col=1::Failed linting:%0A%0AThe origamiVersion property needs to be set to 1%0A%0AThe origami.json file does not conform to the specification at http://origami.ft.com/docs/syntax/origamijson/`
`::error file=origami.json,line=1,col=1::Failed linting:%0A%0AThe origamiVersion property needs to be set to 2, this version of Origami Build tools only supports v2 of the Origami component specification.%0A%0AThe origami.json file does not conform to the specification at http://origami.ft.com/docs/syntax/origamijson/`
);
});
});

it('should pass if origamiVersion property is 1', async function () {
it('should pass if origamiVersion property is 2', async function () {
const origamiJSON = JSON.parse(fs.readFileSync(path.join(process.cwd(), 'origami.json'), 'utf-8'));
origamiJSON.origamiVersion = 1;
origamiJSON.origamiVersion = 2;
fs.writeFileSync('origami.json', JSON.stringify(origamiJSON), 'utf8');

await verifyOrigamiJson().task();
Expand Down Expand Up @@ -352,7 +352,7 @@ describe('verify-origami-json', function () {
proclaim.calledOnce(console.log);
proclaim.calledWithExactly(
console.log,
`::error file=origami.json,line=1,col=1::Failed linting:%0A%0AA non-empty description property is required%0AThe origamiType property needs to be set to either "imageset", "module" or "service"%0AThe origamiVersion property needs to be set to 1%0AThe support property must be an email or url to an issue tracker for this module%0AThe supportStatus property must be set to either "active", "maintained", "deprecated", "dead" or "experimental"%0A%0AThe origami.json file does not conform to the specification at http://origami.ft.com/docs/syntax/origamijson/`
`::error file=origami.json,line=1,col=1::Failed linting:%0A%0AA non-empty description property is required%0AThe origamiType property needs to be set to either "imageset", "module" or "service"%0AThe origamiVersion property needs to be set to 2, this version of Origami Build tools only supports v2 of the Origami component specification.%0AThe support property must be an email or url to an issue tracker for this module%0AThe supportStatus property must be set to either "active", "maintained", "deprecated", "dead" or "experimental"%0A%0AThe origami.json file does not conform to the specification at http://origami.ft.com/docs/syntax/origamijson/`
);
});
});
Expand Down Expand Up @@ -490,11 +490,15 @@ describe('verify-origami-json', function () {
});

describe('demo title', function() {
const origamiJSON = JSON.parse(fs.readFileSync(path.join(process.cwd(), 'origami.json'), 'utf-8'));
origamiJSON.origamiType = 'module';
const expectedError = 'Failed linting:\n\n' +
'All demos require a title property which is non-empty and of type "string".\n\n' +
'The origami.json file does not conform to the specification at http://origami.ft.com/docs/syntax/origamijson/';
let origamiJSON = {};

beforeEach(() => {
origamiJSON = JSON.parse(fs.readFileSync(path.join(process.cwd(), 'origami.json'), 'utf-8'));
origamiJSON.origamiType = 'module';
});

it('should fail when a demo does not have a title property', function () {
origamiJSON.demos = [{
Expand Down

0 comments on commit 7e6a9f1

Please sign in to comment.