Skip to content

Commit

Permalink
chore: format all files (#5684)
Browse files Browse the repository at this point in the history
  • Loading branch information
BatuhanW committed Feb 26, 2024
1 parent 6360573 commit 16eefc4
Show file tree
Hide file tree
Showing 5,386 changed files with 361,333 additions and 376,959 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
2 changes: 1 addition & 1 deletion .changeset/config.json
Expand Up @@ -11,4 +11,4 @@
"___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH": {
"onlyUpdatePeerDependentsWhenOutOfRange": true
}
}
}
122 changes: 61 additions & 61 deletions .github/workflows/build-example-chunks.js
Expand Up @@ -11,69 +11,69 @@ const BASE_REF = process.env.BASE_REF ? process.env.BASE_REF : "master";
const BUILD_ALL_EXAMPLES = process.env.BUILD_ALL_EXAMPLES === "true";

const getChangedPackages = () => {
const p = require.resolve("lerna/cli.js");
const p = require.resolve("lerna/cli.js");

const output = execSync(`node ${p} ls --since origin/${BASE_REF} --json`, {
stdio: "pipe",
});
const output = execSync(`node ${p} ls --since origin/${BASE_REF} --json`, {
stdio: "pipe",
});

const changedPackages = JSON.parse(output.toString());
const changedPackages = JSON.parse(output.toString());

return changedPackages.map((pkg) => pkg.name);
return changedPackages.map((pkg) => pkg.name);
};

const isExampleAffected = (example, changedPackages) => {
const examplePath = path.join(EXAMPLES_DIR, example);
const examplePath = path.join(EXAMPLES_DIR, example);

if (changedPackages.length === 0) {
return false;
}
if (changedPackages.length === 0) {
return false;
}

const pkgJson = JSON.parse(
fs.readFileSync(path.join(examplePath, "package.json")),
);
const pkgJson = JSON.parse(
fs.readFileSync(path.join(examplePath, "package.json")),
);

const dependencies = Object.keys(pkgJson.dependencies || {});
const devDependencies = Object.keys(pkgJson.devDependencies || {});
const dependencies = Object.keys(pkgJson.dependencies || {});
const devDependencies = Object.keys(pkgJson.devDependencies || {});

const allDependencies = [...dependencies, ...devDependencies];
const allDependencies = [...dependencies, ...devDependencies];

return allDependencies.some((dependency) => {
return changedPackages.includes(dependency);
});
return allDependencies.some((dependency) => {
return changedPackages.includes(dependency);
});
};

const isExampleModified = (example) => {
const output = execSync(
`git diff --quiet HEAD origin/${BASE_REF} -- ${EXAMPLES_DIR}/${example} || echo changed`,
{ stdio: "pipe" },
);
const output = execSync(
`git diff --quiet HEAD origin/${BASE_REF} -- ${EXAMPLES_DIR}/${example} || echo changed`,
{ stdio: "pipe" },
);

return output.toString().includes("changed");
return output.toString().includes("changed");
};

const hasPackageJson = (example) => {
return fs.existsSync(path.join(EXAMPLES_DIR, example, "package.json"));
return fs.existsSync(path.join(EXAMPLES_DIR, example, "package.json"));
};

const hasE2eTests = (example) => {
return fs.existsSync(path.join(EXAMPLES_DIR, example, "cypress.config.ts"));
return fs.existsSync(path.join(EXAMPLES_DIR, example, "cypress.config.ts"));
};

const isDirectory = (example) => {
return fs.statSync(path.join(EXAMPLES_DIR, example)).isDirectory();
return fs.statSync(path.join(EXAMPLES_DIR, example)).isDirectory();
};

const isIgnored = (example) => {
return ignoredRegexes.some((regex) => regex.test(example));
return ignoredRegexes.some((regex) => regex.test(example));
};

const getExamples = () => {
return fs
.readdirSync(EXAMPLES_DIR)
.filter((dir) => isDirectory(dir))
.filter((dir) => !isIgnored(dir))
.filter((dir) => hasPackageJson(dir));
return fs
.readdirSync(EXAMPLES_DIR)
.filter((dir) => isDirectory(dir))
.filter((dir) => !isIgnored(dir))
.filter((dir) => hasPackageJson(dir));
};

//
Expand All @@ -82,20 +82,20 @@ const getExamples = () => {
const changedPackages = getChangedPackages();

const examples = getExamples().filter((dir) =>
BUILD_ALL_EXAMPLES
? true
: isExampleAffected(dir, changedPackages) || isExampleModified(dir),
BUILD_ALL_EXAMPLES
? true
: isExampleAffected(dir, changedPackages) || isExampleModified(dir),
);

console.log(
`Changed packages (${changedPackages.length}):\n- ` +
changedPackages.join("\n- "),
`Changed packages (${changedPackages.length}):\n- ` +
changedPackages.join("\n- "),
);

console.log("");

console.log(
`Affected examples (${examples.length}):\n- ` + examples.join("\n- "),
`Affected examples (${examples.length}):\n- ` + examples.join("\n- "),
);

//
Expand All @@ -104,11 +104,11 @@ console.log(
const examplesWithE2eTests = examples.filter((dir) => hasE2eTests(dir));

const examplesWithoutE2eTests = examples.filter(
(dir) => !examplesWithE2eTests.includes(dir),
(dir) => !examplesWithE2eTests.includes(dir),
);

console.log(
`\nFound ${examplesWithE2eTests.length} examples with e2e tests and ${examplesWithoutE2eTests.length} without.\n`,
`\nFound ${examplesWithE2eTests.length} examples with e2e tests and ${examplesWithoutE2eTests.length} without.\n`,
);

//
Expand All @@ -119,34 +119,34 @@ const chunkSize = Math.ceil(examples.length / CHUNK_COUNT);
const chunks = [];

for (let i = 0; i < examples.length; i += chunkSize) {
const tempChunk = [];

for (j = 0; j < chunkSize; j++) {
if (j % (CHUNK_COUNT / 2) === 1) {
if (examplesWithE2eTests.length > 0) {
tempChunk.push(examplesWithE2eTests.shift());
} else if (examplesWithoutE2eTests.length > 0) {
tempChunk.push(examplesWithoutE2eTests.shift());
}
} else {
if (examplesWithoutE2eTests.length > 0) {
tempChunk.push(examplesWithoutE2eTests.shift());
}
}
const tempChunk = [];

for (j = 0; j < chunkSize; j++) {
if (j % (CHUNK_COUNT / 2) === 1) {
if (examplesWithE2eTests.length > 0) {
tempChunk.push(examplesWithE2eTests.shift());
} else if (examplesWithoutE2eTests.length > 0) {
tempChunk.push(examplesWithoutE2eTests.shift());
}
} else {
if (examplesWithoutE2eTests.length > 0) {
tempChunk.push(examplesWithoutE2eTests.shift());
}
}
}

if (i + chunkSize >= examples.length) {
tempChunk.push(...examplesWithE2eTests);
if (i + chunkSize >= examples.length) {
tempChunk.push(...examplesWithE2eTests);

tempChunk.push(...examplesWithoutE2eTests);
}
tempChunk.push(...examplesWithoutE2eTests);
}

chunks.push(tempChunk);
chunks.push(tempChunk);
}

//
// Set outputs
//
chunks.forEach((chunk, i) => {
console.log("::set-output name=CHUNK_" + (i + 1) + "::" + chunk.join(","));
console.log("::set-output name=CHUNK_" + (i + 1) + "::" + chunk.join(","));
});
104 changes: 52 additions & 52 deletions .github/workflows/check-existing-doc-links.js
@@ -1,81 +1,81 @@
const getUrlToCheck = (currentUrl, deploymentUrl) => {
const url = new URL(currentUrl);
url.hostname = new URL(deploymentUrl).hostname;
return url.toString();
const url = new URL(currentUrl);
url.hostname = new URL(deploymentUrl).hostname;
return url.toString();
};

const checkUrl = async (url) => {
const { status } = await fetch(url, {
method: "GET",
});
return [status, new URL(url).pathname];
const { status } = await fetch(url, {
method: "GET",
});
return [status, new URL(url).pathname];
};

const toChunks = (array, chunkSize) => {
const chunks = [];
for (let i = 0; i < array.length; i += chunkSize) {
chunks.push(array.slice(i, i + chunkSize));
}
return chunks;
const chunks = [];
for (let i = 0; i < array.length; i += chunkSize) {
chunks.push(array.slice(i, i + chunkSize));
}
return chunks;
};

const checkChunk = (chunk, deploymentUrl, success, fail) => {
return new Promise((resolve) => {
const promises = chunk.map((url) => {
return checkUrl(getUrlToCheck(url, deploymentUrl));
});
return new Promise((resolve) => {
const promises = chunk.map((url) => {
return checkUrl(getUrlToCheck(url, deploymentUrl));
});

Promise.all(promises).then((results) => {
results.forEach(([status, url]) => {
if (status === 200) {
success.push(url);
} else {
fail.push(url);
}
});
resolve();
});
Promise.all(promises).then((results) => {
results.forEach(([status, url]) => {
if (status === 200) {
success.push(url);
} else {
fail.push(url);
}
});
resolve();
});
});
};

const checkExistingLinks = async (sitemapUrl, deploymentUrl) => {
const data = await (await fetch(sitemapUrl)).text();
const data = await (await fetch(sitemapUrl)).text();

const urls = data.match(/<loc>(.*?)<\/loc>/g).map((loc) => {
return loc.replace("<loc>", "").replace("</loc>", "");
});
const urls = data.match(/<loc>(.*?)<\/loc>/g).map((loc) => {
return loc.replace("<loc>", "").replace("</loc>", "");
});

let success = [];
let fail = [];
let success = [];
let fail = [];

console.log("Checking for existing urls in:", sitemapUrl);
console.log("Deployment url:", deploymentUrl);
console.log("Checking for existing urls in:", sitemapUrl);
console.log("Deployment url:", deploymentUrl);

const chunks = toChunks(urls, 10);
const chunks = toChunks(urls, 10);

let done = 0;
let done = 0;

for (const chunk of chunks) {
console.log(`Checking chunk ${done + 1}/${chunks.length}`);
done++;
await checkChunk(chunk, deploymentUrl, success, fail);
}
for (const chunk of chunks) {
console.log(`Checking chunk ${done + 1}/${chunks.length}`);
done++;
await checkChunk(chunk, deploymentUrl, success, fail);
}

if (fail.length > 0) {
console.log("Broken links:");
fail.forEach((link) => {
console.log(link);
});
process.exit(1);
}
if (fail.length > 0) {
console.log("Broken links:");
fail.forEach((link) => {
console.log(link);
});
process.exit(1);
}
};

if (!process.env.DEPLOY_URL) {
console.log("DEPLOY_URL is not defined");
process.exit(1);
console.log("DEPLOY_URL is not defined");
process.exit(1);
}

checkExistingLinks(
process.env.SITEMAP_URL ?? "https://refine.dev/sitemap.xml",
process.env.DEPLOY_URL,
process.env.SITEMAP_URL ?? "https://refine.dev/sitemap.xml",
process.env.DEPLOY_URL,
);

0 comments on commit 16eefc4

Please sign in to comment.