Initialise le fichier .gitlab-ci.yml
This commit is contained in:
21
src/build_job/package-lock.json
generated
Normal file
21
src/build_job/package-lock.json
generated
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "build_job",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "build_job",
|
||||
"version": "1.0.0",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"node-iptc": "^1.0.5"
|
||||
}
|
||||
},
|
||||
"node_modules/node-iptc": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://registry.npmjs.org/node-iptc/-/node-iptc-1.0.5.tgz",
|
||||
"integrity": "sha512-+e9aVETp/X8iFX2qBw2GnABkq/jGs7dJdxGURZysOdn4ZdOdArPW2a3xQpSq6GX2CcgEzUklDfaC/cg4sLv35g=="
|
||||
}
|
||||
}
|
||||
}
|
14
src/build_job/package.json
Normal file
14
src/build_job/package.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "build_job",
|
||||
"version": "1.0.0",
|
||||
"description": "Generate a theme.json file from the images' metadata of the working folder.",
|
||||
"main": "themeset_builder.js",
|
||||
"scripts": {
|
||||
"start": "node themeset_builder.js"
|
||||
},
|
||||
"author": "Simon",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"node-iptc": "^1.0.5"
|
||||
}
|
||||
}
|
@@ -0,0 +1,74 @@
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const iptc = require("node-iptc");
|
||||
|
||||
|
||||
// find all images
|
||||
const slug = process.env["PACKAGE_NAME"];
|
||||
const root = process.env["ENTRY_FOLDER"];
|
||||
let workingDirectory = path.join("../..", root, slug);
|
||||
|
||||
// extract metadata from them
|
||||
fs.readdir(workingDirectory, (err, files) => {
|
||||
if (err) { throw err };
|
||||
|
||||
// construct a JSON file
|
||||
let theme = new Object();
|
||||
theme.dayImageList = [];
|
||||
theme.nightImageList = [];
|
||||
theme.sunsetImageList = [];
|
||||
theme.sunriseImageList = [];
|
||||
|
||||
// iterate each files
|
||||
files.filter(file => path.extname(file) == '.jpg').forEach(image => {
|
||||
buffer = fs.readFileSync(path.join(workingDirectory, image));
|
||||
//if (err) { throw err };
|
||||
// extract metadata
|
||||
let metadata = iptc(buffer);
|
||||
// fill object
|
||||
theme.imageFilename ||= metadata.special_instructions + "_*" + path.extname(image);
|
||||
theme.imageCredits ||= metadata.copyright_notice;
|
||||
theme.displayName ||= metadata.headline;
|
||||
// explore categories to find if image is dayHighlight or nightHighlight
|
||||
metadata.supplemental_categories?.forEach(cat => {
|
||||
switch (cat) {
|
||||
case "dayHighlight":
|
||||
theme.dayHighlight ||= parseInt(metadata.original_transmission_reference);
|
||||
break;
|
||||
case "nightHighlight":
|
||||
theme.nightHighlight ||= parseInt(metadata.original_transmission_reference);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
switch (metadata.category) {
|
||||
case "day":
|
||||
theme.dayImageList.push(parseInt(metadata.original_transmission_reference));
|
||||
break;
|
||||
case "night":
|
||||
case "nig":
|
||||
theme.nightImageList.push(parseInt(metadata.original_transmission_reference));
|
||||
break;
|
||||
case "sunset":
|
||||
case "twilight":
|
||||
case "twi":
|
||||
theme.sunsetImageList.push(parseInt(metadata.original_transmission_reference));
|
||||
break;
|
||||
case "sunrise":
|
||||
case "dawn":
|
||||
case "daw":
|
||||
theme.sunriseImageList.push(parseInt(metadata.original_transmission_reference));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
fs.writeFileSync(path.join(workingDirectory, 'theme.json'), JSON.stringify(theme));
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -46,8 +46,8 @@ def validate_brightness_image(working_path, theme_config, high_light, image_list
|
||||
@pytest.fixture
|
||||
def working_path():
|
||||
# get the global variables containing gitlab-given project slug.
|
||||
project_slug = os.environ["WPP_SLUG"]
|
||||
root_folder = os.environ["WPP_ROOT"]
|
||||
project_slug = os.environ["PACKAGE_NAME"]
|
||||
root_folder = os.environ["ENTRY_FOLDER"]
|
||||
working_path = Path(root_folder, project_slug)
|
||||
if not working_path.is_dir():
|
||||
raise FileNotFoundError(f"No project found for the given {working_path}.")
|
||||
@@ -76,7 +76,6 @@ def test_image_size(working_path, manifest):
|
||||
assert w >= h, "✖ Image orientation is portrait (must be landscape or square)"
|
||||
# print(f"✔ Images are big enough ({w}×{h}) and landscape.")
|
||||
|
||||
|
||||
def test_overlapping_images(manifest):
|
||||
jointed_lists = manifest.get("dayImageList")
|
||||
jointed_lists.extend(manifest.get("nightImageList"))
|
||||
|
78
src/test_manifest_job/package-lock.json
generated
78
src/test_manifest_job/package-lock.json
generated
@@ -1,18 +1,20 @@
|
||||
{
|
||||
"name": "wppchecker",
|
||||
"name": "wpp-checker",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "wppchecker",
|
||||
"name": "wpp-checker",
|
||||
"version": "1.0.0",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"ajv": "^8.5.0",
|
||||
"ajv": "^8.12.0",
|
||||
"ajv-errors": "^3.0.0",
|
||||
"chai": "^4.3.4",
|
||||
"mocha": "^8.4.0",
|
||||
"chai": "^4.3.7",
|
||||
"mocha": "^8.4.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"mocha-steps": "^1.3.0"
|
||||
}
|
||||
},
|
||||
@@ -22,9 +24,9 @@
|
||||
"integrity": "sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q=="
|
||||
},
|
||||
"node_modules/ajv": {
|
||||
"version": "8.5.0",
|
||||
"resolved": "https://registry.npmjs.org/ajv/-/ajv-8.5.0.tgz",
|
||||
"integrity": "sha512-Y2l399Tt1AguU3BPRP9Fn4eN+Or+StUGWCUpbnFyXSo8NZ9S4uj+AG2pjs5apK+ZMOwYOz1+a+VKvKH7CudXgQ==",
|
||||
"version": "8.12.0",
|
||||
"resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz",
|
||||
"integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==",
|
||||
"dependencies": {
|
||||
"fast-deep-equal": "^3.1.1",
|
||||
"json-schema-traverse": "^1.0.0",
|
||||
@@ -149,14 +151,15 @@
|
||||
}
|
||||
},
|
||||
"node_modules/chai": {
|
||||
"version": "4.3.4",
|
||||
"resolved": "https://registry.npmjs.org/chai/-/chai-4.3.4.tgz",
|
||||
"integrity": "sha512-yS5H68VYOCtN1cjfwumDSuzn/9c+yza4f3reKXlE5rUg7SFcCEy90gJvydNgOYtblyf4Zi6jIWRnXOgErta0KA==",
|
||||
"version": "4.3.7",
|
||||
"resolved": "https://registry.npmjs.org/chai/-/chai-4.3.7.tgz",
|
||||
"integrity": "sha512-HLnAzZ2iupm25PlN0xFreAlBA5zaBSv3og0DdeGA4Ar6h6rJ3A0rolRUKJhSF2V10GZKDgWF/VmAEsNWjCRB+A==",
|
||||
"dependencies": {
|
||||
"assertion-error": "^1.1.0",
|
||||
"check-error": "^1.0.2",
|
||||
"deep-eql": "^3.0.1",
|
||||
"deep-eql": "^4.1.2",
|
||||
"get-func-name": "^2.0.0",
|
||||
"loupe": "^2.3.1",
|
||||
"pathval": "^1.1.1",
|
||||
"type-detect": "^4.0.5"
|
||||
},
|
||||
@@ -322,14 +325,14 @@
|
||||
}
|
||||
},
|
||||
"node_modules/deep-eql": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz",
|
||||
"integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==",
|
||||
"version": "4.1.3",
|
||||
"resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-4.1.3.tgz",
|
||||
"integrity": "sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw==",
|
||||
"dependencies": {
|
||||
"type-detect": "^4.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.12"
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/diff": {
|
||||
@@ -605,6 +608,14 @@
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/loupe": {
|
||||
"version": "2.3.6",
|
||||
"resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.6.tgz",
|
||||
"integrity": "sha512-RaPMZKiMy8/JruncMU5Bt6na1eftNoo++R4Y+N2FrxkDVTrGvcyzFTsaGif4QTeKESheMGegbhw6iUAq+5A8zA==",
|
||||
"dependencies": {
|
||||
"get-func-name": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/minimatch": {
|
||||
"version": "3.0.4",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
|
||||
@@ -662,7 +673,8 @@
|
||||
"node_modules/mocha-steps": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/mocha-steps/-/mocha-steps-1.3.0.tgz",
|
||||
"integrity": "sha512-KZvpMJTqzLZw3mOb+EEuYi4YZS41C9iTnb7skVFRxHjUd1OYbl64tCMSmpdIRM9LnwIrSOaRfPtNpF5msgv6Eg=="
|
||||
"integrity": "sha512-KZvpMJTqzLZw3mOb+EEuYi4YZS41C9iTnb7skVFRxHjUd1OYbl64tCMSmpdIRM9LnwIrSOaRfPtNpF5msgv6Eg==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/ms": {
|
||||
"version": "2.1.3",
|
||||
@@ -1098,9 +1110,9 @@
|
||||
"integrity": "sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q=="
|
||||
},
|
||||
"ajv": {
|
||||
"version": "8.5.0",
|
||||
"resolved": "https://registry.npmjs.org/ajv/-/ajv-8.5.0.tgz",
|
||||
"integrity": "sha512-Y2l399Tt1AguU3BPRP9Fn4eN+Or+StUGWCUpbnFyXSo8NZ9S4uj+AG2pjs5apK+ZMOwYOz1+a+VKvKH7CudXgQ==",
|
||||
"version": "8.12.0",
|
||||
"resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz",
|
||||
"integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==",
|
||||
"requires": {
|
||||
"fast-deep-equal": "^3.1.1",
|
||||
"json-schema-traverse": "^1.0.0",
|
||||
@@ -1189,14 +1201,15 @@
|
||||
"integrity": "sha512-c7wVvbw3f37nuobQNtgsgG9POC9qMbNuMQmTCqZv23b6MIz0fcYpBiOlv9gEN/hdLdnZTDQhg6e9Dq5M1vKvfg=="
|
||||
},
|
||||
"chai": {
|
||||
"version": "4.3.4",
|
||||
"resolved": "https://registry.npmjs.org/chai/-/chai-4.3.4.tgz",
|
||||
"integrity": "sha512-yS5H68VYOCtN1cjfwumDSuzn/9c+yza4f3reKXlE5rUg7SFcCEy90gJvydNgOYtblyf4Zi6jIWRnXOgErta0KA==",
|
||||
"version": "4.3.7",
|
||||
"resolved": "https://registry.npmjs.org/chai/-/chai-4.3.7.tgz",
|
||||
"integrity": "sha512-HLnAzZ2iupm25PlN0xFreAlBA5zaBSv3og0DdeGA4Ar6h6rJ3A0rolRUKJhSF2V10GZKDgWF/VmAEsNWjCRB+A==",
|
||||
"requires": {
|
||||
"assertion-error": "^1.1.0",
|
||||
"check-error": "^1.0.2",
|
||||
"deep-eql": "^3.0.1",
|
||||
"deep-eql": "^4.1.2",
|
||||
"get-func-name": "^2.0.0",
|
||||
"loupe": "^2.3.1",
|
||||
"pathval": "^1.1.1",
|
||||
"type-detect": "^4.0.5"
|
||||
}
|
||||
@@ -1319,9 +1332,9 @@
|
||||
"integrity": "sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ=="
|
||||
},
|
||||
"deep-eql": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz",
|
||||
"integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==",
|
||||
"version": "4.1.3",
|
||||
"resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-4.1.3.tgz",
|
||||
"integrity": "sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw==",
|
||||
"requires": {
|
||||
"type-detect": "^4.0.0"
|
||||
}
|
||||
@@ -1514,6 +1527,14 @@
|
||||
"chalk": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"loupe": {
|
||||
"version": "2.3.6",
|
||||
"resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.6.tgz",
|
||||
"integrity": "sha512-RaPMZKiMy8/JruncMU5Bt6na1eftNoo++R4Y+N2FrxkDVTrGvcyzFTsaGif4QTeKESheMGegbhw6iUAq+5A8zA==",
|
||||
"requires": {
|
||||
"get-func-name": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"minimatch": {
|
||||
"version": "3.0.4",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
|
||||
@@ -1557,7 +1578,8 @@
|
||||
"mocha-steps": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/mocha-steps/-/mocha-steps-1.3.0.tgz",
|
||||
"integrity": "sha512-KZvpMJTqzLZw3mOb+EEuYi4YZS41C9iTnb7skVFRxHjUd1OYbl64tCMSmpdIRM9LnwIrSOaRfPtNpF5msgv6Eg=="
|
||||
"integrity": "sha512-KZvpMJTqzLZw3mOb+EEuYi4YZS41C9iTnb7skVFRxHjUd1OYbl64tCMSmpdIRM9LnwIrSOaRfPtNpF5msgv6Eg==",
|
||||
"dev": true
|
||||
},
|
||||
"ms": {
|
||||
"version": "2.1.3",
|
||||
|
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "wppchecker",
|
||||
"name": "wpp-checker",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "wppChecker.js",
|
||||
"main": "wpp_checker.js",
|
||||
"scripts": {
|
||||
"test": "mocha wppChecker.js --require mocha-step --colors"
|
||||
"test": "src/test_manifest_job/node_modules/mocha/bin/_mocha --require mocha-steps --colors src/test_manifest_job/wpp_checker.js"
|
||||
},
|
||||
"author": "PtiSimon",
|
||||
"author": "Simon",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"ajv": "^8.5.0",
|
||||
@@ -15,4 +15,4 @@
|
||||
"mocha": "^8.4.0",
|
||||
"mocha-steps": "^1.3.0"
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,76 +0,0 @@
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const { env, exit } = require("process");
|
||||
const expect = require("chai").expect;
|
||||
const Ajv = require("ajv").default;
|
||||
const ajv = new Ajv({allErrors: true});
|
||||
require("ajv-errors")(ajv);
|
||||
|
||||
//let root, slug;
|
||||
//let workingDirectory = path.join(root, slug);
|
||||
//console.log(`👷♂️ Working with ‘${slug}’ slug.`);
|
||||
|
||||
const themeSchemaFile = ".gitlab/node_job/json_theme_schema.jsonc";
|
||||
let wppManifest;
|
||||
let validator;
|
||||
let files;
|
||||
|
||||
function leftOuterJoin(leftArray, rightArray) {
|
||||
return leftArray.filter(function(el) {
|
||||
return this.indexOf(el) < 0;
|
||||
}, rightArray);
|
||||
}
|
||||
|
||||
function flatReferences(wppManifest) {
|
||||
allImageIds = [
|
||||
wppManifest.dayHighlight,
|
||||
wppManifest.nightHighlight,
|
||||
...wppManifest.dayImageList,
|
||||
...wppManifest.nightImageList,
|
||||
...(wppManifest.sunsetImageList || []),
|
||||
...(wppManifest.sunriseImageList || [])
|
||||
];
|
||||
return allImageIds.filter(el => el !== undefined).map(el => {
|
||||
return wppManifest.imageFilename.replace("*", el);
|
||||
});
|
||||
}
|
||||
|
||||
describe('Mandatory Checks', function() {
|
||||
before(function() {
|
||||
slug = env.WPP_SLUG;
|
||||
expect(slug).to.be.a("string").that.is.not.empty;
|
||||
root = env.WPP_ROOT;
|
||||
expect(root).to.be.a("string").that.is.not.empty;
|
||||
workingDirectory = path.join(root, slug);
|
||||
files = fs.readdirSync(workingDirectory);
|
||||
expect(files).to.be.an('array').that.is.not.empty;
|
||||
validator = ajv.compile(JSON.parse(fs.readFileSync(themeSchemaFile, 'utf8')));
|
||||
});
|
||||
|
||||
step('Manifest is an existing json file', function() {
|
||||
wppManifest = JSON.parse(fs.readFileSync(path.join(workingDirectory, "theme.json"), "utf8"));
|
||||
});
|
||||
|
||||
step('Manifest passes the schema', function() {
|
||||
const isValid = validator(wppManifest);
|
||||
if(!isValid) expect.fail(`\n\t• ${validator.errors.map(el => {return el.message;}).join('\n\t• ')}`);
|
||||
});
|
||||
|
||||
step('There are no missing files', function() {
|
||||
let references = flatReferences(wppManifest);
|
||||
references.push("theme.json");
|
||||
missings = leftOuterJoin(references, files);
|
||||
expect(missings,
|
||||
`The following reference${(missings.length > 1)? "s": ""} from theme.json ${(missings.length > 1)? "are": "is"} missing in the pack. Consider adding ${(missings.length > 1)? "them": " it"} to the pack or removing the reference${(missings.length > 1)? "s": ""} from the theme.json:\n\t• ${missings.join('\n\t• ')}\n`
|
||||
).to.be.lengthOf(0, );
|
||||
});
|
||||
|
||||
step('There are no orphan files', function() {
|
||||
let references = flatReferences(wppManifest);
|
||||
orphans = leftOuterJoin(files.filter(x => x !== "theme.json"), references);
|
||||
expect(orphans,
|
||||
`The following orphan file${(orphans.length > 1)? "s are": " is"} not referenced in this theme.json. Consider removing the file${(orphans.length > 1)? "s": ""} or referencing ${(orphans.length > 1)? "them": "it"} in the theme.json:\n\t• ${orphans.join('\n\t• ')}\n`
|
||||
).to.be.lengthOf(0);
|
||||
});
|
||||
|
||||
});
|
76
src/test_manifest_job/wpp_checker.js
Normal file
76
src/test_manifest_job/wpp_checker.js
Normal file
@@ -0,0 +1,76 @@
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const expect = require("chai").expect;
|
||||
const Ajv = require("ajv").default;
|
||||
const ajv = new Ajv({ allErrors: true });
|
||||
require("ajv-errors")(ajv);
|
||||
|
||||
//let root, slug;
|
||||
//let workingDirectory = path.join(root, slug);
|
||||
//console.log(`👷♂️ Working with ‘${slug}’ slug.`);
|
||||
|
||||
const themeSchemaFile = "src/test_manifest_job/json_theme_schema.jsonc";
|
||||
let wppManifest;
|
||||
let validator;
|
||||
let files;
|
||||
let workingDirectory;
|
||||
|
||||
function leftOuterJoin(leftArray, rightArray) {
|
||||
return leftArray.filter(function (el) {
|
||||
return this.indexOf(el) < 0;
|
||||
}, rightArray);
|
||||
}
|
||||
|
||||
function flatReferences(wppManifest) {
|
||||
allImageIds = [
|
||||
wppManifest.dayHighlight,
|
||||
wppManifest.nightHighlight,
|
||||
...wppManifest.dayImageList,
|
||||
...wppManifest.nightImageList,
|
||||
...(wppManifest.sunsetImageList || []),
|
||||
...(wppManifest.sunriseImageList || [])
|
||||
];
|
||||
return allImageIds.filter(el => el !== undefined).map(el => {
|
||||
return wppManifest.imageFilename.replace("*", el);
|
||||
});
|
||||
}
|
||||
|
||||
describe('Mandatory Checks', function () {
|
||||
before(function () {
|
||||
const slug = process.env["PACKAGE_NAME"];
|
||||
expect(slug).to.be.a("string").that.is.not.empty;
|
||||
const root = process.env["ENTRY_FOLDER"];
|
||||
expect(root).to.be.a("string").that.is.not.empty;
|
||||
workingDirectory = path.join(root, slug);
|
||||
files = fs.readdirSync(workingDirectory);
|
||||
expect(files).to.be.an('array').that.is.not.empty;
|
||||
validator = ajv.compile(JSON.parse(fs.readFileSync(themeSchemaFile, 'utf8')));
|
||||
});
|
||||
|
||||
step('Manifest is an existing json file', function () {
|
||||
wppManifest = JSON.parse(fs.readFileSync(path.join(workingDirectory, "theme.json"), "utf8"));
|
||||
});
|
||||
|
||||
step('Manifest passes the schema', function () {
|
||||
const isValid = validator(wppManifest);
|
||||
if (!isValid) expect.fail(`\n\t• ${validator.errors.map(el => { return el.message; }).join('\n\t• ')}`);
|
||||
});
|
||||
|
||||
step('There are no missing files', function () {
|
||||
let references = flatReferences(wppManifest);
|
||||
references.push("theme.json");
|
||||
let missings = leftOuterJoin(references, files);
|
||||
expect(missings,
|
||||
`The following reference${(missings.length > 1) ? "s" : ""} from theme.json ${(missings.length > 1) ? "are" : "is"} missing in the pack. Consider adding ${(missings.length > 1) ? "them" : " it"} to the pack or removing the reference${(missings.length > 1) ? "s" : ""} from the theme.json:\n\t• ${missings.join('\n\t• ')}\n`
|
||||
).to.be.lengthOf(0,);
|
||||
});
|
||||
|
||||
step('There are no orphan files', function () {
|
||||
let references = flatReferences(wppManifest);
|
||||
let orphans = leftOuterJoin(files.filter(x => x !== "theme.json"), references);
|
||||
expect(orphans,
|
||||
`The following orphan file${(orphans.length > 1) ? "s are" : " is"} not referenced in this theme.json. Consider removing the file${(orphans.length > 1) ? "s" : ""} or referencing ${(orphans.length > 1) ? "them" : "it"} in the theme.json:\n\t• ${orphans.join('\n\t• ')}\n`
|
||||
).to.be.lengthOf(0);
|
||||
});
|
||||
|
||||
});
|
Reference in New Issue
Block a user