mirror of
https://github.com/chenasraf/schemastore.git
synced 2026-05-18 01:58:58 +00:00
remove folder src/utility (#1747)
* remove folder src/utility This utility for creating readme.md file via nodejs is not used at all. * labeler.yml: Add ".gitignore" and ".gitattributes" Forgot to add them on first commit * gruntfile.js: improve error mesage at invalid json test file. 'find-duplicated-property-keys' cannot process invalid JSON file. But the error mesage does not show which JSON file it is. This is now fixed. * gruntfile.js: improve folder name alignment
This commit is contained in:
committed by
GitHub
parent
2f797da2f0
commit
9b411c3a96
5
.github/labeler.yml
vendored
5
.github/labeler.yml
vendored
@@ -40,6 +40,11 @@ editorconfig:
|
||||
eslintrcjson:
|
||||
- "src/.eslintrc.json"
|
||||
|
||||
# .gitignore change
|
||||
gitignore:
|
||||
- ".gitignore"
|
||||
- ".gitattributes"
|
||||
|
||||
# Do not add "api", "schema" and "test" directories.
|
||||
# Those are the usual commit. No need for extra attention.
|
||||
# src/api/**/*
|
||||
|
||||
@@ -176,7 +176,7 @@ module.exports = function (grunt) {
|
||||
|
||||
if (logTestFolder) {
|
||||
grunt.log.writeln('')
|
||||
grunt.log.writeln(`test folder : ${folderName}`)
|
||||
grunt.log.writeln(`test folder : ${folderName}`)
|
||||
}
|
||||
|
||||
const filesInsideOneTestFolder = fs.readdirSync(pt.join(testDir, folderName)).map(
|
||||
@@ -648,7 +648,12 @@ module.exports = function (grunt) {
|
||||
let countScan = 0
|
||||
const findDuplicatedProperty = (callbackParameter) => {
|
||||
countScan++
|
||||
const result = findDuplicatedPropertyKeys(callbackParameter.rawFile)
|
||||
let result
|
||||
try {
|
||||
result = findDuplicatedPropertyKeys(callbackParameter.rawFile)
|
||||
} catch (e) {
|
||||
throwWithErrorText([`Test file: ${callbackParameter.urlOrFilePath}`, e])
|
||||
}
|
||||
if (result.length > 0) {
|
||||
const errorText = []
|
||||
errorText.push(`Duplicated key found in: ${callbackParameter.urlOrFilePath}`)
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
# JSON Schema Store
|
||||
|
||||
A collection of JSON schemas
|
||||
|
||||
[](https://ci.appveyor.com/project/madskristensen/schemastore-371)
|
||||
|
||||
The repository is meant as a universal JSON schema store,
|
||||
where schemas for popular JSON documents can be found.
|
||||
|
||||
Website: [${domain}](${https})
|
||||
|
||||
## How to use
|
||||
|
||||
Schemas are available at (just append schema file name to the path):
|
||||
|
||||
${schemas}
|
||||
|
||||
## Contribute
|
||||
Contributions are more than welcome. Both to the website itself or to the various schema files. Before contributing, please carefully read the [guidelines](./CONTRIBUTING.md).
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"README_PATH": "../../README.md",
|
||||
"TLS_URL": "https://schemastore.azurewebsites.net"
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
const fs = require("fs");
|
||||
const { homepage } = require("../package.json");
|
||||
const { README_PATH, TLS_URL } = require("./fixtures.json");
|
||||
|
||||
const template = fs.readFileSync("./README_template.md", { encoding: "utf8" });
|
||||
|
||||
/**
|
||||
* @param {string} link
|
||||
* @param {string} [text]
|
||||
* @returns {string}
|
||||
*/
|
||||
function anchor(link, text = link) {
|
||||
return `<a href="${link}" referrerpolicy="no-referrer">${text}</a>`;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {...string} cells
|
||||
* @returns {string}
|
||||
*/
|
||||
const mdRow = (...cells) => {
|
||||
return `| ${cells.join(" | ")} |`;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} content
|
||||
* @param {function} callback
|
||||
* @param {string[]} acc
|
||||
* @returns {string[]}
|
||||
*/
|
||||
function readLines(content, callback, acc = []) {
|
||||
const lines = content.split(/\r|\n/);
|
||||
for (const line of lines) {
|
||||
callback(line, acc);
|
||||
}
|
||||
return acc;
|
||||
}
|
||||
|
||||
const placeholderMap = new Map()
|
||||
.set("domain", () => {
|
||||
return homepage.replace(/http(?:s)*:\/\/(?:www\.)*/, "");
|
||||
})
|
||||
.set("homepage", () => homepage)
|
||||
.set("https", () => TLS_URL)
|
||||
.set("schemas", () => {
|
||||
|
||||
const jsonHTTP = anchor(`${homepage}/json/`, "JSON");
|
||||
const cssHTTP = anchor(`${homepage}/css/`, "CSS");
|
||||
const jsHTTP = anchor(`${homepage}/javascript/`, "JS");
|
||||
|
||||
const jsonTLS = anchor(`${TLS_URL}/schemas/json/`, "JSON");
|
||||
const cssTLS = anchor(`${TLS_URL}/schemas/css/`, "CSS");
|
||||
const jsTLS = anchor(`${TLS_URL}/schemas/javascript/`, "JS");
|
||||
|
||||
return [
|
||||
mdRow("HTTP", "HTTP/TLS"),
|
||||
mdRow("---", "---"),
|
||||
mdRow(
|
||||
[cssHTTP, jsonHTTP, jsHTTP].join(" \\| "),
|
||||
[cssTLS, jsonTLS, jsTLS].join(" \\| ")
|
||||
)
|
||||
].join("\n");
|
||||
});
|
||||
|
||||
/**
|
||||
* @param {string} line
|
||||
* @param {string[]} acc
|
||||
* @returns {void}
|
||||
*/
|
||||
function parsePlaceholders(line, acc) {
|
||||
|
||||
const updated = line.replace(/\$\{(\w+)\}/g, (full, name) => {
|
||||
const handler = placeholderMap.get(name);
|
||||
return handler ? handler() : "";
|
||||
});
|
||||
|
||||
acc.push(updated);
|
||||
}
|
||||
|
||||
function run() {
|
||||
const parsed = readLines(template, parsePlaceholders);
|
||||
const output = fs.createWriteStream(README_PATH);
|
||||
output.write(parsed.join("\n"));
|
||||
}
|
||||
|
||||
run();
|
||||
Reference in New Issue
Block a user