-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4612 from mermaid-js/sidv/docsVersion
Support MERMAID_RELEASE_VERSION in docs.
- Loading branch information
Showing
10 changed files
with
90 additions
and
22 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
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
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
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
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
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,3 @@ | ||
import { processDocs } from './docs.mjs'; | ||
|
||
void processDocs(); |
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
File renamed without changes.
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 @@ | ||
/* eslint-disable no-console */ | ||
|
||
/** | ||
* @file Update the MERMAID_RELEASE_VERSION placeholder in the documentation source files with the current version of mermaid. | ||
* So contributors adding new features will only have to add the placeholder and not worry about updating the version number. | ||
* | ||
*/ | ||
import { posix } from 'path'; | ||
import { | ||
getGlobs, | ||
getFilesFromGlobs, | ||
SOURCE_DOCS_DIR, | ||
readSyncedUTF8file, | ||
MERMAID_RELEASE_VERSION, | ||
} from './docs.mjs'; | ||
import { writeFile } from 'fs/promises'; | ||
|
||
const verifyOnly: boolean = process.argv.includes('--verify'); | ||
const versionPlaceholder = '<MERMAID_RELEASE_VERSION>'; | ||
|
||
const main = async () => { | ||
const sourceDirGlob = posix.join('.', SOURCE_DOCS_DIR, '**'); | ||
const mdFileGlobs = getGlobs([posix.join(sourceDirGlob, '*.md')]); | ||
mdFileGlobs.push('!**/community/development.md'); | ||
const mdFiles = await getFilesFromGlobs(mdFileGlobs); | ||
mdFiles.sort(); | ||
const mdFilesWithPlaceholder: string[] = []; | ||
for (const mdFile of mdFiles) { | ||
const content = readSyncedUTF8file(mdFile); | ||
if (content.includes(versionPlaceholder)) { | ||
mdFilesWithPlaceholder.push(mdFile); | ||
} | ||
} | ||
|
||
if (mdFilesWithPlaceholder.length === 0) { | ||
return; | ||
} | ||
|
||
if (verifyOnly) { | ||
console.log( | ||
`${mdFilesWithPlaceholder.length} file(s) were found with the placeholder ${versionPlaceholder}. Run \`pnpm --filter mermaid docs:release-version\` to update them.` | ||
); | ||
process.exit(1); | ||
} | ||
|
||
for (const mdFile of mdFilesWithPlaceholder) { | ||
const content = readSyncedUTF8file(mdFile); | ||
const newContent = content.replace(versionPlaceholder, MERMAID_RELEASE_VERSION); | ||
await writeFile(mdFile, newContent); | ||
} | ||
}; | ||
|
||
void main(); |
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