Skip to content

Commit

Permalink
Merge branch 'master' into 1495-create-dds-templates
Browse files Browse the repository at this point in the history
  • Loading branch information
tishoyanchev committed Dec 4, 2024
2 parents 5498aea + 444ebef commit 471114b
Show file tree
Hide file tree
Showing 38 changed files with 4,542 additions and 3,007 deletions.
2 changes: 2 additions & 0 deletions examples/stencil-components/vanilla-cdn/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script type="module" src="./dist/infineon-design-system-stencil/infineon-design-system-stencil.esm.js"></script>
<link rel="stylesheet" href="./dist/infineon-design-system-stencil/infineon-design-system-stencil.css">

<!-- <link rel="stylesheet" href="./node_modules/@infineon/design-system-tokens/dist/fonts/ifx-fonts.css"> -->


Expand Down
2 changes: 1 addition & 1 deletion examples/stencil-components/vanilla-cdn/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
"dependencies": {
"@infineon/design-system-tokens": "3.3.2--canary.35.37fb280e88ed6cac90c421f89ba851375e93e62d.0",
"@infineon/infineon-design-system-stencil": "^20.44.1--canary.952.e2740b8e640aa78a0a199512580d52d96004104f.0",
"@infineon/infineon-design-system-stencil": "25.15.1--canary.1561.1c1eb8e300b13c71569ad58d2397e7bc06c66329.0",
"typescript": "^4.5.4"
}
}
2 changes: 1 addition & 1 deletion examples/stencil-components/vanilla-cdn/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This example application demonstrates the usage of some of our Stencil web compo

The `index.html` at the root of this example application includes the CDN link to the latest npm package.
For testing purposes, however, we want to use the locally built Stencil components.
When not working on the Master branch, per default, the CDN link will point to the locally built components in the ```dist``` folder.
When not working on the Master branch, per default, the CDN links will point to the locally built components in the ```dist``` folder as well as the stylesheet.
To test the compiled components locally, follow the steps below.

## Run locally
Expand Down
56 changes: 35 additions & 21 deletions examples/stencil-components/vanilla-cdn/update-link.js
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);
3 changes: 1 addition & 2 deletions examples/stencil-components/vanilla-cdn/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { defineConfig } from 'vite'

export default defineConfig({

base: "./",
server: {

watch: {
// Watch the 'dist' folder for changes
include: 'dist/**',
Expand Down
72 changes: 46 additions & 26 deletions 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.

2 changes: 1 addition & 1 deletion examples/wrapper-components/react-vite-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"test:local": "run-p preview:link watch:library"
},
"dependencies": {
"@infineon/infineon-design-system-react": "27.7.2--canary.1496.8a2bf389d071805f3b7bc87fe8d34bdd9bc7e2a8.0",
"@infineon/infineon-design-system-react": "29.0.0--canary.1274.70bd4b0b0965df2da4c87c1b833b25dcd46022da.0",
"path": "^0.12.7",
"react": "^18.3.1",
"react-dom": "^18.3.1"
Expand Down
4 changes: 2 additions & 2 deletions examples/wrapper-components/vue-javascript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
"test:local": "run-p preview:link watch:library"
},
"dependencies": {
"@infineon/infineon-design-system-vue": "27.7.2--canary.1496.8a2bf389d071805f3b7bc87fe8d34bdd9bc7e2a8.0",
"@infineon/infineon-design-system-vue": "29.0.0--canary.1274.70bd4b0b0965df2da4c87c1b833b25dcd46022da.0",
"@vitejs/plugin-vue": "^4.0.0",
"@vitejs/plugin-vue-jsx": "^3.0.1",
"@vitejs/plugin-vue-jsx": "^4.0.0",
"vite": "^5.0.12",
"vue": "^3.4.15"
},
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"version": "27.7.2--canary.1496.8a2bf389d071805f3b7bc87fe8d34bdd9bc7e2a8.0",
"version": "29.0.0--canary.1274.70bd4b0b0965df2da4c87c1b833b25dcd46022da.0",
"command": {
"publish": {
"verifyAccess": false
Expand Down
Loading

0 comments on commit 471114b

Please sign in to comment.