-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/task/244054/recommendations-qa-w…
…orkflow' into task/244054/recommendations-qa-workflow
- Loading branch information
Showing
39 changed files
with
10,281 additions
and
8,365 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
16 changes: 12 additions & 4 deletions
16
contentful/content-management/changes/20240916-1200-delete-unlinked-headers.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 |
---|---|---|
@@ -1,21 +1,29 @@ | ||
const deleteEntry = require("../helpers/delete-entry"); | ||
const getClient = require("../helpers/get-client"); | ||
import deleteEntry from "../helpers/delete-entry.js"; | ||
import getClient from "../helpers/get-client.js"; | ||
|
||
export default async function () { | ||
console.log(`Deleting unlinked headers`); | ||
|
||
module.exports = async function () { | ||
const client = await getClient(); | ||
const headers = await client.entry.getMany({ | ||
query: { | ||
content_type: "header", | ||
}, | ||
}); | ||
|
||
for (const header of headers.items) { | ||
console.log(`Processing header ${header.sys.id}`); | ||
const linked = await client.entry.getMany({ | ||
query: { | ||
links_to_entry: header.sys.id, | ||
}, | ||
}); | ||
|
||
if (!linked.items.length) { | ||
console.log( | ||
`Deleting header ${header.sys.id} as it has no links to it.` | ||
); | ||
await deleteEntry(header); | ||
} | ||
} | ||
}; | ||
} |
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 { jest } from "@jest/globals"; | ||
|
||
export default jest.fn(); |
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,30 @@ | ||
import "dotenv/config"; | ||
import contentfulImport from "contentful-import"; | ||
import { existsSync } from "fs"; | ||
import { getAndValidateClient } from "./get-client.js"; | ||
|
||
export default async function importContentfulData() { | ||
const options = { | ||
contentFile: process.env.CONTENT_FILE, | ||
spaceId: process.env.SPACE_ID, | ||
managementToken: process.env.MANAGEMENT_TOKEN, | ||
environmentId: process.env.ENVIRONMENT, | ||
skipContentModel: process.env.SKIP_CONTENT_MODEL === "true", | ||
}; | ||
|
||
await getAndValidateClient(); | ||
|
||
if (!existsSync(options.contentFile)) { | ||
throw new Error(`File not found: ${options.contentFile}`); | ||
} | ||
|
||
try { | ||
await contentfulImport(options); | ||
console.log( | ||
`Import completed successfully from ${options.contentFile}` | ||
); | ||
} catch (error) { | ||
console.error("Error during import:", error); | ||
throw error; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,38 +1,9 @@ | ||
require('dotenv').config(); | ||
import "dotenv/config"; | ||
|
||
const contentfulImport = require('contentful-import'); | ||
const fs = require('fs'); | ||
const getClient = require("./helpers/get-client"); | ||
const deleteContentfulContent = require("./helpers/delete-all-content-and-content-types"); | ||
import importContentfulData from "./helpers/import-content"; | ||
|
||
async function importContentfulData() { | ||
const options = { | ||
contentFile: process.env.CONTENT_FILE, | ||
spaceId: process.env.SPACE_ID, | ||
managementToken: process.env.MANAGEMENT_TOKEN, | ||
environmentId: process.env.ENVIRONMENT, | ||
skipContentModel: process.env.SKIP_CONTENT_MODEL === 'true' ? true : false | ||
}; | ||
const client = await getClient(); | ||
|
||
if (!fs.existsSync(options.contentFile)) { | ||
throw new Error(`File not found: ${options.contentFile}`); | ||
} | ||
|
||
if (process.env.DELETE_ALL_DATA == 'true') { | ||
console.log(`Deleting all existing data from ${options.environmentId}`); | ||
await deleteContentfulContent({ client: client }); | ||
} | ||
|
||
console.log("Starting import with the following options:", options) | ||
|
||
try { | ||
await contentfulImport(options); | ||
console.log(`Import completed successfully from ${options.contentFile}`); | ||
} catch (error) { | ||
console.error('Error during import:', error); | ||
throw error; | ||
} | ||
} | ||
|
||
importContentfulData() | ||
importContentfulData() | ||
.then(() => console.log("Import completed successfully")) | ||
.catch((error) => { | ||
console.error("Error during import:", error); | ||
}); |
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,15 @@ | ||
export default { | ||
transform: { | ||
"^.+\\.ts$": [ | ||
"ts-jest", | ||
{ | ||
useESM: true, | ||
}, | ||
], | ||
}, | ||
moduleNameMapper: { | ||
"^(\\.{1,2}/.*)\\.js$": "$1.js", | ||
}, | ||
testEnvironment: "node", | ||
preset: "ts-jest", | ||
}; |
Oops, something went wrong.