-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ci): add enterprise and community edition release info to change…
…sets
- Loading branch information
Showing
3 changed files
with
147 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
.github/workflows/scripts/changesets/add-enterprise-header.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
const { readdirSync, readFileSync, writeFileSync } = require("fs"); | ||
const { join } = require("path"); | ||
|
||
function updateChangesetTitles() { | ||
const TITLE_TO_ADD = "# Refine Enterprise Release\n"; | ||
const changesetDir = join(process.cwd(), ".changeset"); | ||
|
||
try { | ||
const files = readdirSync(changesetDir); | ||
const mdFiles = files.filter( | ||
(file) => file !== "README.md" && file.endsWith(".md"), | ||
); | ||
|
||
if (!mdFiles.length) { | ||
console.log("✅ No changesets found"); | ||
return; | ||
} | ||
|
||
let updatedFilesCount = 0; | ||
|
||
for (const file of mdFiles) { | ||
const filePath = join(changesetDir, file); | ||
const content = readFileSync(filePath, "utf-8"); | ||
|
||
if (content.includes("# Refine Enterprise Release")) { | ||
continue; | ||
} | ||
|
||
const [_, frontmatter, ...bodyParts] = content.split("---"); | ||
if (!frontmatter) continue; | ||
|
||
const body = bodyParts.join("---").trim(); | ||
|
||
const updatedContent = [ | ||
"---", | ||
frontmatter.trim(), | ||
"---\n", | ||
TITLE_TO_ADD, | ||
body, | ||
].join("\n"); | ||
|
||
writeFileSync(filePath, updatedContent); | ||
updatedFilesCount++; | ||
} | ||
|
||
console.log(`✅ Successfully updated ${updatedFilesCount} changeset files`); | ||
} catch (error) { | ||
console.error("Error updating changeset files:", error); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
updateChangesetTitles(); |
90 changes: 90 additions & 0 deletions
90
.github/workflows/scripts/changesets/prepare-community-edition-changesets.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
const { mkdirSync, readdirSync, readFileSync, writeFileSync } = require("fs"); | ||
const { join } = require("path"); | ||
|
||
function copyChangesetFiles() { | ||
const sourceDir = join(process.cwd(), ".changeset"); | ||
const targetDir = join(process.cwd(), "_changeset"); | ||
|
||
try { | ||
try { | ||
mkdirSync(targetDir, { recursive: true }); | ||
} catch (error) { | ||
if (error.code !== "EEXIST") { | ||
throw error; | ||
} | ||
} | ||
|
||
const files = readdirSync(sourceDir); | ||
|
||
for (const file of files) { | ||
const sourcePath = join(sourceDir, file); | ||
const targetPath = join(targetDir, file); | ||
|
||
try { | ||
const content = readFileSync(sourcePath); | ||
writeFileSync(targetPath, content); | ||
console.log(`Copied: ${file}`); | ||
} catch (error) { | ||
console.error(`Failed to copy ${file}:`, error.message); | ||
} | ||
} | ||
|
||
console.log(`✅ Successfully copied ${files.length} files to _changeset`); | ||
} catch (error) { | ||
console.error("Error during changeset files copy operation:", error); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
function updateChangesetFiles() { | ||
const TITLE_TO_ADD = "# Refine Community Edition Release\n"; | ||
const changesetDir = join(process.cwd(), "_changeset"); | ||
|
||
try { | ||
const files = readdirSync(changesetDir); | ||
const mdFiles = files.filter((file) => file.endsWith(".md")); | ||
|
||
let updatedFilesCount = 0; | ||
|
||
for (const file of mdFiles) { | ||
const filePath = join(changesetDir, file); | ||
const content = readFileSync(filePath, "utf-8"); | ||
|
||
const [_, frontmatter, ...bodyParts] = content.split("---"); | ||
if (!frontmatter) continue; | ||
|
||
const updatedFrontmatter = frontmatter.replace( | ||
/": minor|": major/g, | ||
'": patch', | ||
); | ||
|
||
const body = bodyParts.join("---").trim(); | ||
|
||
const cleanBody = body | ||
.replace(/# Refine Enterprise Release\s*/g, "") | ||
.replace(/# Refine Community Edition Release\s*/g, "") | ||
.trim(); | ||
|
||
const updatedContent = [ | ||
"---", | ||
updatedFrontmatter.trim(), | ||
"---\n", | ||
TITLE_TO_ADD, | ||
cleanBody, | ||
].join("\n"); | ||
|
||
writeFileSync(filePath, updatedContent); | ||
console.log(`File updated: ${file}`); | ||
updatedFilesCount++; | ||
} | ||
|
||
console.log(`✅ Successfully updated ${updatedFilesCount} changeset files`); | ||
} catch (error) { | ||
console.error("Error updating changeset files:", error); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
copyChangesetFiles(); | ||
|
||
updateChangesetFiles(); |