-
Notifications
You must be signed in to change notification settings - Fork 1
[CAI-612] Update sync worflow #1745
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
df543c2
Add new generation to sync gitbook
MarBert 1ce5ba7
Merge branch 'main' into CAI-612-update-sync-worflow
MarBert 06b3dd0
Fix to compile error
MarBert 4c8093f
Move types to helper file
MarBert efc6c31
Merge branch 'main' into CAI-612-update-sync-worflow
MarBert 2651fa6
Add base url to url
MarBert abf921f
rename file
MarBert fa24185
Update packages/gitbook-docs/src/scripts/generateStrapiResponseFiles.ts
MarBert b067f0e
Update packages/gitbook-docs/src/scripts/generateStrapiResponseFiles.ts
MarBert 3fa21de
Add changeset, fix linting
MarBert 44b2532
Merge branch 'main' into CAI-612-update-sync-worflow
marcobottaro 32023ee
update workflow
MarBert 3be92a7
fix scheduled workflow
MarBert b3e8b1f
remove reindex
MarBert File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,92 @@ | ||
export interface StrapiGuide { | ||
readonly id: number; | ||
readonly attributes: { | ||
readonly slug: string; | ||
readonly title: string; | ||
readonly product?: { | ||
readonly data?: { | ||
readonly attributes?: { | ||
readonly slug: string; | ||
}; | ||
}; | ||
}; | ||
readonly versions: readonly { | ||
readonly id: number; | ||
readonly main: boolean; | ||
readonly version: string; | ||
readonly dirName: string; | ||
}[]; | ||
}; | ||
} | ||
|
||
export interface StrapiReleaseNote { | ||
readonly id: number; | ||
readonly attributes: { | ||
readonly slug: string; | ||
readonly title: string; | ||
readonly product?: { | ||
readonly data?: { | ||
readonly attributes?: { | ||
readonly slug: string; | ||
}; | ||
}; | ||
}; | ||
readonly dirName: string; | ||
readonly landingFile: string; | ||
}; | ||
} | ||
|
||
export interface StrapiSolution { | ||
readonly id: number; | ||
readonly attributes: { | ||
readonly slug: string; | ||
readonly title: string; | ||
readonly landingUseCaseFile: string; | ||
readonly dirName: string; | ||
}; | ||
} | ||
|
||
export interface StrapiProduct { | ||
readonly attributes: { | ||
readonly name: string; | ||
readonly shortName: string; | ||
readonly slug: string; | ||
}; | ||
} | ||
|
||
export interface StrapiApiData { | ||
readonly id: number; | ||
readonly attributes: { | ||
readonly title: string; | ||
readonly description?: string; | ||
readonly icon: { | ||
readonly data?: { | ||
readonly attributes: { | ||
readonly name: string; | ||
readonly ext: string; | ||
readonly mime: string; | ||
readonly size: number; | ||
readonly url: string; | ||
readonly alternativeText?: string; | ||
readonly caption?: string; | ||
readonly height?: number; | ||
readonly width?: number; | ||
}; | ||
}; | ||
}; | ||
readonly apiRestDetail?: { | ||
readonly slug: string; | ||
readonly specUrls: readonly { | ||
readonly id: number; | ||
readonly name?: string; | ||
readonly url: string; | ||
readonly hideTryIt: boolean; | ||
}[]; | ||
}; | ||
readonly apiSoapDetail?: { | ||
readonly slug: string; | ||
readonly repositoryUrl: string; | ||
readonly dirName: string; | ||
}; | ||
}; | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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
82 changes: 82 additions & 0 deletions
82
packages/gitbook-docs/src/scripts/generateStrapiResponseFile.ts
This file contains hidden or 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,82 @@ | ||
/* eslint-disable functional/prefer-readonly-type */ | ||
/* eslint-disable functional/no-loop-statements */ | ||
/* eslint-disable functional/no-expression-statements */ | ||
/* eslint-disable functional/immutable-data */ | ||
/* eslint-disable functional/no-try-statements */ | ||
import dotenv from 'dotenv'; | ||
import { fetchFromStrapi } from '../helpers/fetchFromStrapi'; | ||
import { makeS3Client, writeSitemapJson } from '../helpers/s3Bucket.helper'; | ||
import { StrapiApiData, StrapiProduct } from '../helpers/strapiTypes'; | ||
|
||
dotenv.config(); | ||
|
||
const SITEMAP_URL = | ||
process.env.SITEMAP_URL || 'https://developer.pagopa.it/sitemap.xml'; | ||
MarBert marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
const S3_SITEMAP_PATH = process.env.S3_SITEMAP_PATH || 'sitemap.xml'; | ||
const S3_PRODUCTS_METADATA_JSON_PATH = | ||
process.env.S3_PRODUCTS_METADATA_JSON_PATH || 'synced-products-response.json'; | ||
const S3_APIS_DATA_METADATA_JSON_PATH = | ||
process.env.S3_APIS_DATA_METADATA_JSON_PATH || | ||
'synced-apis-data-response.json'; | ||
const S3_BUCKET_NAME = process.env.S3_BUCKET_NAME; | ||
|
||
const s3Client = makeS3Client(); | ||
async function main() { | ||
console.log('Recovering products and apis-data from Strapi CMS...'); | ||
// eslint-disable-next-line functional/no-let | ||
let strapiProducts; | ||
try { | ||
const { data } = await fetchFromStrapi<StrapiProduct>('api/products'); | ||
strapiProducts = data; | ||
} catch (error) { | ||
console.error('Error fetching Products from Strapi:', error); | ||
process.exit(1); | ||
} | ||
console.log(`Fetched ${strapiProducts.length} products from Strapi`); | ||
|
||
// eslint-disable-next-line functional/no-let | ||
let strapiApisData; | ||
try { | ||
const { data } = await fetchFromStrapi<StrapiApiData>( | ||
'api/apis-data?populate[product]=*&populate[apiRestDetail][populate][specUrls]=*' | ||
); | ||
strapiApisData = data; | ||
} catch (error) { | ||
console.error('Error fetching Products from Strapi:', error); | ||
process.exit(1); | ||
} | ||
console.log(`Fetched ${strapiApisData.length} apis-data from Strapi`); | ||
|
||
// eslint-disable-next-line functional/no-let | ||
let siteMap; | ||
try { | ||
const response = await fetch(SITEMAP_URL); | ||
siteMap = await response.text(); | ||
} catch (error) { | ||
console.error('Error fetching sitemap.xml:', error); | ||
process.exit(1); | ||
} | ||
|
||
await writeSitemapJson( | ||
siteMap, | ||
S3_SITEMAP_PATH, | ||
`${S3_BUCKET_NAME}`, | ||
s3Client | ||
); | ||
|
||
await writeSitemapJson( | ||
strapiProducts, | ||
S3_PRODUCTS_METADATA_JSON_PATH, | ||
`${S3_BUCKET_NAME}`, | ||
s3Client | ||
); | ||
|
||
await writeSitemapJson( | ||
strapiApisData, | ||
S3_APIS_DATA_METADATA_JSON_PATH, | ||
`${S3_BUCKET_NAME}`, | ||
s3Client | ||
); | ||
} | ||
|
||
main(); |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.