Skip to content
Merged
Changes from all commits
Commits
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
28 changes: 11 additions & 17 deletions scripts/migrate-content/migrate-content.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,9 @@ async function migrateContent(targetRepos, ghCloneDir, outputDirs, options) {
)
for (let i = targetReleaseRefs.length - 1; i >= 0; i--) {
const targetRef = targetReleaseRefs[i]
const versionString = repoConfig.versionedDocs
? targetRef.versionString
: ''

try {
migrateRepoContentAtRef(
Expand All @@ -260,13 +263,13 @@ async function migrateContent(targetRepos, ghCloneDir, outputDirs, options) {

successes.push({
repoSlug,
versionString: targetRef.versionString,
versionString,
})
} catch (error) {
console.error(`🔴 Failed to extract content from "${repoSlug}"`, error)
failures.push({
repoSlug,
versionString: targetRef.versionString,
versionString,
hash: targetRef.hash,
error: error.stack,
})
Expand Down Expand Up @@ -336,27 +339,18 @@ function migrateRepoContentAtRef(
* TODO: investigate why `terraform-cdk` doesn't seem to have an asset
* directory. Maybe intentional, in which case this conditional is fine.
*/
const version = repoConfig.versionedDocs ? targetRef.versionString : ''
if (typeof repoConfig.assetDir === 'string') {
const assetsSrc = path.join(websiteDirPath, repoConfig.assetDir)
const assetsDest = path.join(
outputDirs.content,
repoSlug,
targetRef.versionString,
'img',
)
const assetsDest = path.join(outputDirs.content, repoSlug, version, 'img')

if (fs.existsSync(assetsSrc)) {
dirsToCopy.push({ src: assetsSrc, dest: assetsDest })
}
} else if (Array.isArray(repoConfig.assetDir)) {
for (const assetDir of repoConfig.assetDir) {
const assetsSrc = path.join(websiteDirPath, assetDir)
const assetsDest = path.join(
outputDirs.content,
repoSlug,
targetRef.versionString,
'img',
)
const assetsDest = path.join(outputDirs.content, repoSlug, version, 'img')

if (fs.existsSync(assetsSrc)) {
dirsToCopy.push({ src: assetsSrc, dest: assetsDest })
Expand All @@ -369,14 +363,14 @@ function migrateRepoContentAtRef(
const contentDest = path.join(
outputDirs.content,
repoSlug,
targetRef.versionString,
version,
repoConfig.contentDir,
)
const dataSrc = path.join(websiteDirPath, repoConfig.dataDir)
const dataDest = path.join(
outputDirs.content,
repoSlug,
targetRef.versionString,
version,
repoConfig.dataDir,
)

Expand All @@ -388,7 +382,7 @@ function migrateRepoContentAtRef(
const redirectsDest = path.join(
outputDirs.content,
repoSlug,
targetRef.versionString,
version,
'redirects.jsonc',
)
dirsToCopy.push({ src: redirectsSrcJsonc, dest: redirectsDest })
Expand Down