-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into 1495-create-dds-templates
- Loading branch information
Showing
38 changed files
with
4,542 additions
and
3,007 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,57 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
// Path to the index.html file | ||
const indexHtmlPath = path.join(__dirname, '/index.html'); | ||
const isMaster = process.env.GITHUB_REF === 'refs/heads/master'; | ||
|
||
console.log("is local", process.env.GITHUB_REF === undefined) | ||
// Determine if the current branch is master | ||
const isMaster = process.env.GITHUB_REF === 'refs/heads/master'; | ||
|
||
// Read the content of index.html | ||
const htmlContent = fs.readFileSync(indexHtmlPath, 'utf-8'); | ||
|
||
const scriptRegex = /<\s*script[^>]+src\s*=\s*['"]\s?(https:\/\/www\.googletagservices\.com\/tag\/js\/gpt\.js)*([^'" ]+)\s*["'][^>]*><\/script>/gis | ||
// const stylesheetRegex = /<\s*link[^>]+href\s*=\s*['"]\s?(https:\/\/www\.googletagservices\.com\/tag\/js\/gpt\.js)*([^'" ]+)\s*["'][^>]*>/gis | ||
// Define regex patterns to match both local dist and CDN script tags for JS and link tags for CSS files | ||
const scriptRegex = /<\s*script[^>]+src\s*=\s*['"]\s?(https:\/\/cdn\.jsdelivr\.net\/npm\/@infineon\/infineon-design-system-stencil[^'" ]*\.esm\.js|\.\/dist\/infineon-design-system-stencil\/infineon-design-system-stencil\.esm\.js)\s*["'][^>]*><\/script>/gis; | ||
const stylesheetRegex = /<\s*link[^>]+href\s*=\s*['"]\s?(https:\/\/cdn\.jsdelivr\.net\/npm\/@infineon\/infineon-design-system-stencil[^'" ]*\.css|\.\/dist\/infineon-design-system-stencil\/infineon-design-system-stencil\.css)\s*["'][^>]*>/gis; | ||
|
||
// Load the current version from the package.json file | ||
const version = require('../../../packages/components/package.json').version; | ||
|
||
const cdnLinkLatest = '<script type="module" src="https://cdn.jsdelivr.net/npm/@infineon/infineon-design-system-stencil/dist/infineon-design-system-stencil/infineon-design-system-stencil.esm.js"></script>'; | ||
const cdnLinkCanary = `<script type="module" src="https://cdn.jsdelivr.net/npm/@infineon/infineon-design-system-stencil@${version}/dist/infineon-design-system-stencil/infineon-design-system-stencil.esm.js"></script>`; | ||
// Define the CDN links | ||
const cdnLinkLatestJS = '<script type="module" src="https://cdn.jsdelivr.net/npm/@infineon/infineon-design-system-stencil/dist/infineon-design-system-stencil/infineon-design-system-stencil.esm.js"></script>'; | ||
const cdnLinkCanaryJS = `<script type="module" src="https://cdn.jsdelivr.net/npm/@infineon/infineon-design-system-stencil@${version}/dist/infineon-design-system-stencil/infineon-design-system-stencil.esm.js"></script>`; | ||
|
||
// const cdnStylesheetLatest = `<script type="module" src="https://cdn.jsdelivr.net/npm/@infineon/infineon-design-system-stencil/dist/infineon-design-system-stencil/infineon-design-system-stencil.css"></script>`; | ||
// const cdnStylesheetCanary = `<script type="module" src="https://cdn.jsdelivr.net/npm/@infineon/infineon-design-system-stencil@${version}/dist/infineon-design-system-stencil/infineon-design-system-stencil.css"></script>`; | ||
const cdnLinkLatestCSS = '<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@infineon/infineon-design-system-stencil/dist/infineon-design-system-stencil/infineon-design-system-stencil.css">'; | ||
const cdnLinkCanaryCSS = `<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@infineon/infineon-design-system-stencil@${version}/dist/infineon-design-system-stencil/infineon-design-system-stencil.css">`; | ||
|
||
const localLink = '<script type="module" src="./dist/infineon-design-system-stencil/infineon-design-system-stencil.esm.js"></script>'; | ||
// const localStylesheet = '<link rel="stylesheet" href="dist/infineon-design-system-stencil/infineon-design-system-stencil.css">'; | ||
// Define the local links | ||
const localLinkJS = '<script type="module" src="./dist/infineon-design-system-stencil/infineon-design-system-stencil.esm.js"></script>'; | ||
const localLinkCSS = '<link rel="stylesheet" href="./dist/infineon-design-system-stencil/infineon-design-system-stencil.css">'; | ||
|
||
// Determine the new source links based on the environment | ||
let newScriptSrc; | ||
// let newStylesheet | ||
let newStylesheetSrc; | ||
|
||
console.log("current branch: ", process.env.GITHUB_REF, " - package version: ", require('../../../packages/components/package.json').version); | ||
console.log("current branch: ", process.env.GITHUB_REF, " - package version: ", version); | ||
|
||
if (process.env.GITHUB_REF === undefined) { | ||
newScriptSrc = localLink; | ||
// newStylesheet = localStylesheet; | ||
newScriptSrc = localLinkJS; | ||
newStylesheetSrc = localLinkCSS; | ||
} else { | ||
newScriptSrc = isMaster ? cdnLinkLatest : cdnLinkCanary; | ||
// newStylesheet = isMaster ? cdnStylesheetLatest : cdnStylesheetCanary; | ||
|
||
newScriptSrc = isMaster ? cdnLinkLatestJS : cdnLinkCanaryJS; | ||
newStylesheetSrc = isMaster ? cdnLinkLatestCSS : cdnLinkCanaryCSS; | ||
} | ||
const updatedScriptSrc = htmlContent.replace(scriptRegex, newScriptSrc); | ||
// const updatedScriptSrcAndStylesheet = updatedScriptSrc.replace(stylesheetRegex, newStylesheet); | ||
|
||
fs.writeFileSync(indexHtmlPath, updatedScriptSrc, 'utf-8'); | ||
console.log("newScriptSrc: ", newScriptSrc); | ||
console.log("newStylesheetSrc: ", newStylesheetSrc); | ||
|
||
// Replace local dist or CDN links with the appropriate new CDN links in the HTML content | ||
const updatedHtmlContent = htmlContent | ||
.replace(scriptRegex, newScriptSrc) | ||
.replace(stylesheetRegex, newStylesheetSrc); | ||
|
||
// Write the updated content back to index.html | ||
fs.writeFileSync(indexHtmlPath, updatedHtmlContent, 'utf-8'); | ||
|
||
console.log("updated: ", newScriptSrc); | ||
console.log("updated JS link: ", newScriptSrc); | ||
console.log("updated CSS link: ", newStylesheetSrc); |
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
72 changes: 46 additions & 26 deletions
72
examples/wrapper-components/react-vite-js/package-lock.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Oops, something went wrong.