Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
28d83ef
first pass for vault exclusions
williamdalessandro Sep 17, 2025
bf00207
added in functionality to have the exclusion work and play nice with …
williamdalessandro Sep 17, 2025
8029005
adding in manual test case to see if vault exclusion is actually working
williamdalessandro Sep 17, 2025
f826f97
added test case to terraform exclusion
williamdalessandro Sep 17, 2025
7a5924d
added in test suite for vault exclusions- currently failing
williamdalessandro Sep 17, 2025
ca1e6f4
Merge branch 'main' into adding-vault-content-inclusion-exclusions
williamdalessandro Sep 17, 2025
bd5f9b6
fixing tests, 2 more left
williamdalessandro Sep 18, 2025
1770d45
final test fixes, removing some comments
williamdalessandro Sep 18, 2025
60818e9
Merge branch 'main' into adding-vault-content-inclusion-exclusions
williamdalessandro Sep 18, 2025
e174739
adding in new compiled binaries since these are changes in the script…
williamdalessandro Sep 18, 2025
71ef912
updating the single file transform to include vault exclusions
williamdalessandro Sep 18, 2025
c55f4c4
Merge branch 'main' into adding-vault-content-inclusion-exclusions
williamdalessandro Sep 18, 2025
51b0a7d
slight comment change
williamdalessandro Sep 18, 2025
f321df5
adding latest binaries
williamdalessandro Sep 18, 2025
a0008ca
adding shared mjs file
williamdalessandro Sep 19, 2025
550b5c4
added revelant comment to shared.mjs, renamed VLT to vault
williamdalessandro Sep 19, 2025
76eb25a
forgot to add copyright header
williamdalessandro Sep 19, 2025
d2611de
Move config to productConfig
RubenSandwich Sep 22, 2025
8516798
Refactor version test code
RubenSandwich Sep 22, 2025
e115082
it's time to walk away
RubenSandwich Sep 22, 2025
04434cb
small changes
williamdalessandro Sep 23, 2025
80e1740
adding reducing code duplication and added readme explainer
williamdalessandro Sep 23, 2025
c3c0efa
adding in integration with existing code
williamdalessandro Sep 23, 2025
1d636f6
current binaries for build to reflect latest changes
williamdalessandro Sep 23, 2025
7e23f2d
initial changes for unified approach
williamdalessandro Sep 25, 2025
8371a05
massive structural change, turned shared functionality into shared ut…
williamdalessandro Sep 25, 2025
c5c2bb4
adding in individual file transform support
williamdalessandro Sep 25, 2025
8a563bb
merging changes back to primary branch
williamdalessandro Sep 25, 2025
c4692d1
staying consistent until the order should be properly changed
williamdalessandro Sep 25, 2025
4746560
removing older approach
williamdalessandro Sep 25, 2025
09fe52f
adding simple change to content exclusion
williamdalessandro Oct 2, 2025
a481a98
adding in change to do partials first and skip global partials
williamdalessandro Oct 2, 2025
2bd33e6
adding in two extra tests for exclude content to try to catch parsing…
williamdalessandro Oct 2, 2025
33634e8
adding in entire testing suite for mdx transforms to test against thi…
williamdalessandro Oct 2, 2025
3e92a7f
fixing bug caught by tests during global partials- certain partials w…
williamdalessandro Oct 2, 2025
d5c21df
update readme
williamdalessandro Oct 2, 2025
d32ac47
adding in global partial support for single file transform
williamdalessandro Oct 2, 2025
85a51fa
change formatting in mdx transform test, added in more test for edge …
williamdalessandro Oct 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,7 @@ tfe-releases-repos.json
scripts/prebuild/prebuild-arm-mac-binary
scripts/prebuild/prebuild-x64-linux-binary
scripts/prebuild/prebuild-arm-linux-binary

scripts/prebuild/mdx-transforms/benchmarks

scripts/prebuild/mdx-transforms/content-exclusion-OOP-approach
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
page_title: Test Vault Content Exclusion yoo
---

# Test Vault Content Exclusion

This content should always appear.

<!-- BEGIN: Vault:>=v1.21.x -->
This content should be REMOVED because current version (1.20.x) is less than 1.21.x
<!-- END: Vault:>=v1.21.x -->

<!-- BEGIN: Vault:<=v1.21.x -->
This content should STAY because current version (1.20.x) is less than or equal to 1.21.x
<!-- END: Vault:<=v1.21.x -->

<!-- BEGIN: Vault:=v1.20.x -->
This content should STAY because current version equals 1.20.x
<!-- END: Vault:=v1.20.x -->

<!-- BEGIN: Vault:<v1.19.x -->
This content shofuld be REMOVED because current version (1.20.x) is not less than 1.19.x
<!-- END: Vault:<v1.19.x -->

Final content that should always appear.
3 changes: 3 additions & 0 deletions productConfig.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ export const PRODUCT_CONFIG = {
contentDir: 'docs',
dataDir: 'data',
productSlug: 'terraform',
supportsExclusionDirectives: true,
/**
* Note: we need to sort versions for various reasons. Nearly all
* our documentation is semver-versioned. PTFE is not. Rather than
Expand Down Expand Up @@ -310,6 +311,7 @@ export const PRODUCT_CONFIG = {
semverCoerce: semver.coerce,
versionedDocs: false,
websiteDir: 'website',
supportsExclusionDirectives: true,
},
'terraform-plugin-framework': {
/**
Expand Down Expand Up @@ -450,6 +452,7 @@ export const PRODUCT_CONFIG = {
semverCoerce: semver.coerce,
versionedDocs: true,
websiteDir: 'website',
supportsExclusionDirectives: true,
},
'well-architected-framework': {
/**
Expand Down
25 changes: 22 additions & 3 deletions scripts/prebuild/mdx-transforms/build-mdx-transforms-file.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import {
rewriteInternalRedirectsPlugin,
loadRedirects,
} from './rewrite-internal-redirects/rewrite-internal-redirects.mjs'
import { transformExcludeTerraformContent } from './exclude-terraform-content/index.mjs'
import { transformExcludeContent } from './exclude-content/index.mjs'
import { PRODUCT_CONFIG } from '#productConfig.mjs'

const CWD = process.cwd()
const VERSION_METADATA_FILE = path.join(CWD, 'app/api/versionMetadata.json')
Expand Down Expand Up @@ -86,10 +87,28 @@ export async function applyFileMdxTransforms(entry, versionMetadata = {}) {

const { data, content } = grayMatter(fileString)

const remarkResults = await remark()
// Check if this file is in a global/partials directory
// Global partials should not have content exclusion applied to them
// as they are version-agnostic and shared across all versions
const isGlobalPartial = filePath.includes('/global/partials/')

const processor = remark()
.use(remarkMdx)
.use(transformExcludeTerraformContent, { filePath })
// Process partials first, then content exclusion
// This ensures exclusion directives in global partials are properly evaluated
.use(remarkIncludePartialsPlugin, { partialsDir, filePath })

// Only apply content exclusion if this is NOT a global partial
if (!isGlobalPartial) {
processor.use(transformExcludeContent, {
filePath,
version,
repoSlug: entry.repoSlug,
productConfig: PRODUCT_CONFIG[entry.repoSlug],
})
}

const remarkResults = await processor
.use(paragraphCustomAlertsPlugin)
.use(rewriteInternalRedirectsPlugin, {
redirects,
Expand Down
31 changes: 24 additions & 7 deletions scripts/prebuild/mdx-transforms/build-mdx-transforms.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ import {
rewriteInternalRedirectsPlugin,
loadRedirects,
} from './rewrite-internal-redirects/rewrite-internal-redirects.mjs'
import { transformExcludeTerraformContent } from './exclude-terraform-content/index.mjs'

import { transformExcludeContent } from './exclude-content/index.mjs'

import { PRODUCT_CONFIG } from '#productConfig.mjs'

Expand Down Expand Up @@ -78,11 +79,9 @@ export async function buildMdxTransforms(
)
const redirectsDir = path.join(targetDir, repoSlug, verifiedVersion)
const outPath = path.join(outputDir, relativePath)
return { filePath, partialsDir, outPath, version, redirectsDir }
return { repoSlug, filePath, partialsDir, outPath, version, redirectsDir }
})
/**
* Apply MDX transforms to each file entry, in batches
*/

console.log(`Running MDX transforms on ${mdxFileEntries.length} files...`)
const results = await batchPromises(
'MDX transforms',
Expand Down Expand Up @@ -132,10 +131,28 @@ async function applyMdxTransforms(entry, versionMetadata = {}) {
const fileString = fs.readFileSync(filePath, 'utf8')
const { data, content } = grayMatter(fileString)

const remarkResults = await remark()
// Check if this file is in a global/partials directory
// Global partials should not have content exclusion applied to them
// as they are version-agnostic and shared across all versions
const isGlobalPartial = filePath.includes('/global/partials/')

const processor = remark()
.use(remarkMdx)
.use(transformExcludeTerraformContent, { filePath })
// Process partials first, then content exclusion
// This ensures exclusion directives in global partials are properly evaluated
.use(remarkIncludePartialsPlugin, { partialsDir, filePath })

// Only apply content exclusion if this is NOT a global partial
if (!isGlobalPartial) {
processor.use(transformExcludeContent, {
filePath,
version,
repoSlug: entry.repoSlug,
productConfig: PRODUCT_CONFIG[entry.repoSlug],
})
}

const remarkResults = await processor
.use(paragraphCustomAlertsPlugin)
.use(rewriteInternalRedirectsPlugin, {
redirects,
Expand Down
Loading