Skip to content

Commit

Permalink
fix(documentation/preview): fix iframe path
Browse files Browse the repository at this point in the history
  • Loading branch information
danielleroux committed Oct 10, 2022
1 parent 3fb6c18 commit 639d40e
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 41 deletions.
15 changes: 7 additions & 8 deletions .github/workflows/deploy-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,17 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: ./.github/workflows/actions/install
- uses: ./.github/workflows/actions/build
with:
filter: '\!documentation'
- name: 'Install brand theme'
- name: 'Download @siemens/ix-brand-theme'
run: |
rm .yarnrc
ROOT=$(pwd)
cd ./packages/html-test-app/public/additional-theme
echo "@siemens:registry=https://code.siemens.com/api/v4/projects/249177/packages/npm/" >> .npmrc
echo "//code.siemens.com/api/v4/projects/249177/packages/npm/:_authToken=${{ secrets.READ_CSC_TOKEN }}" >> .npmrc
npm install @siemens/ix-brand-theme --no-save
rm .npmrc
rm ./packages/documentation/static/.gitignore
sed -i -e '/\"publishConfig\"/,/}/ d; /^$/d' node_modules/@siemens/ix-brand-theme/package.json
mv node_modules/@siemens ./
cd ROOT
- uses: ./.github/workflows/actions/build
- name: 'Build documentation'
run: |
yarn workspace documentation run build
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

###
# @siemens/html-test-app
###

packages/html-test-app/public/additional-theme

# compiled output
/dist
/tmp
Expand Down
4 changes: 2 additions & 2 deletions packages/documentation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"swizzle": "docusaurus swizzle",
"deploy": "docusaurus deploy",
"clear": "docusaurus clear",
"rimraf": "rimraf ./static/webcomponent-examples/lib/ix && rimraf ./static/webcomponent-examples/lib/ix-brand-theme && rimraf ./static/webcomponent-examples/lib/ix-icons && rimraf ./static/webcomponent-examples/lib/ix-aggrid",
"rimraf": "rimraf ./static/webcomponent-examples/*",
"serve": "docusaurus serve",
"write-translations": "docusaurus write-translations",
"write-heading-ids": "docusaurus write-heading-ids",
Expand All @@ -27,7 +27,7 @@
"@siemens/ix": "~1.0.0",
"@siemens/ix-react": "~1.0.0",
"@siemens/ix-echarts": "~1.0.0",
"html-test-app": "~1.0.0",
"@siemens/html-test-app": "~1.0.0",
"@stencil/postcss": "^2.1.0",
"clsx": "^1.2.1",
"docusaurus-plugin-sass": "^0.2.2",
Expand Down
25 changes: 8 additions & 17 deletions packages/documentation/scripts/copy-webcomponents.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,24 @@ import fsExtra from 'fs-extra';
import path from 'path';

const __dirname = path.resolve();
const libDestPath = path.join(
__dirname,
'static',
'webcomponent-examples',
'lib'
);
const examplePathPath = path.join(__dirname, 'static', 'webcomponent-examples');

const libDestPath = path.join(examplePathPath, 'lib');

const node_modules = path.join(__dirname, '../../', 'node_modules');
const ix_brand_theme_path = path.join(node_modules, '@siemens/ix-brand-theme');

async function loadLib(libName) {
async function loadLib(libName, destPath) {
const libPath = path.join(node_modules, libName);
const pkg = JSON.parse(fsExtra.readFileSync(`${libPath}/package.json`));
return Promise.all(
pkg.files.map(async (file) => {
try {
await fsExtra.copy(
`${libPath}/${file}`,
path.join(libDestPath, libName, file)
destPath
? path.join(examplePathPath, file)
: path.join(libDestPath, libName, file)
);
} catch (e) {
console.warn('Cannot copy resource', file);
Expand All @@ -40,14 +39,6 @@ async function loadLib(libName) {

(async () => {
console.log('Start copy');
await Promise.all([
loadLib('@siemens/ix'),
loadLib('@siemens/ix-icons'),
loadLib('@siemens/ix-aggrid'),
fsExtra.pathExistsSync(ix_brand_theme_path)
? loadLib('@siemens/ix-brand-theme')
: Promise.resolve(),
loadLib('@siemens/ix-echarts'),
]);
await Promise.all([loadLib('@siemens/html-test-app', examplePathPath)]);
console.log('Copy finished!');
})();
6 changes: 4 additions & 2 deletions packages/documentation/src/components/Demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ export default function Demo(props: {
useEffect(() => {
const currentVersion: string = preferredVersion?.name;
if (currentVersion === undefined || currentVersion === 'current') {
setBase(baseUrl + `webcomponent-examples/${props.name}.html`);
setBase(
baseUrl + `webcomponent-examples/preview-examples/${props.name}.html`
);
} else {
setBase(
baseUrl +
`versioned_examples/version-${currentVersion}/webcomponent-examples/${props.name}.html`
`versioned_examples/version-${currentVersion}/webcomponent-examples/preview-examples/${props.name}.html`
);
}
}, [baseUrl, preferredVersion?.name, props.name]);
Expand Down
3 changes: 1 addition & 2 deletions packages/documentation/static/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
webcomponent-examples/lib/
!webcomponent-examples/lib/utils/
webcomponent-examples/*
10 changes: 7 additions & 3 deletions packages/html-test-app/package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
{
"name": "html-test-app",
"name": "@siemens/html-test-app",
"private": true,
"version": "0.0.0",
"version": "1.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"files": [
"dist",
"public"
],
"devDependencies": {
"vite": "^3.1.0",
"@siemens/ix": "1.0.0",
"@siemens/ix-aggrid": "1.0.0",
"@siemens/ix-echarts": "1.0.0",
"@siemens/ix-icons": "~1.0.1"
"@siemens/ix-icons": "~1.0.0"
}
}
1 change: 1 addition & 0 deletions packages/html-test-app/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ if (isBrandThemeExisting) {
// https://vitejs.dev/config/
export default defineConfig({
base: './',
root: './src',
define: {
additionalTheme: JSON.stringify(additionalTheme),
},
Expand Down
2 changes: 1 addition & 1 deletion packages/react-test-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@
"@types/react-dom": "^18.0.6",
"@vitejs/plugin-react": "^2.0.1",
"typescript": "^4.6.4",
"vite": "^3.0.7"
"vite": "^3.1.0"
}
}
12 changes: 6 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6657,7 +6657,7 @@ esbuild@0.15.5:
esbuild-windows-64 "0.15.5"
esbuild-windows-arm64 "0.15.5"

esbuild@^0.15.0, esbuild@^0.15.6:
esbuild@^0.15.0, esbuild@^0.15.9:
version "0.15.10"
resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.15.10.tgz#85c2f8446e9b1fe04fae68daceacba033eedbd42"
integrity sha512-N7wBhfJ/E5fzn/SpNgX+oW2RLRjwaL8Y0ezqNqhjD6w0H2p0rDuEz2FKZqpqLnO8DCaWumKe8dsC/ljvVSSxng==
Expand Down Expand Up @@ -14684,12 +14684,12 @@ vfile@^4.0.0:
unist-util-stringify-position "^2.0.0"
vfile-message "^2.0.0"

vite@^3.0.7:
version "3.1.4"
resolved "https://registry.yarnpkg.com/vite/-/vite-3.1.4.tgz#b75824b819d8354a6f36e4b988943c7e4947e155"
integrity sha512-JoQI08aBjY9lycL7jcEq4p9o1xUjq5aRvdH4KWaXtkSx7e7RpAh9D3IjzDWRD4Fg44LS3oDAIOG/Kq1L+82psA==
vite@^3.1.0:
version "3.1.7"
resolved "https://registry.yarnpkg.com/vite/-/vite-3.1.7.tgz#9fc2b57a395f79175d38fa3cffd15080b0d9cbfc"
integrity sha512-5vCAmU4S8lyVdFCInu9M54f/g8qbOMakVw5xJ4pjoaDy5wgy9sLLZkGdSLN52dlsBqh0tBqxjaqqa8LgPqwRAA==
dependencies:
esbuild "^0.15.6"
esbuild "^0.15.9"
postcss "^8.4.16"
resolve "^1.22.1"
rollup "~2.78.0"
Expand Down

0 comments on commit 639d40e

Please sign in to comment.