-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(atomic-hosted-page): fix cdn import errors by externalizing headl…
- Loading branch information
1 parent
970d0a7
commit 2364a8d
Showing
14 changed files
with
271 additions
and
19 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,3 +29,6 @@ UserInterfaceState.xcuserstate | |
/playwright-report/ | ||
/blob-report/ | ||
/playwright/.cache/ | ||
|
||
/dev/public/ | ||
|
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<!doctype html> | ||
<html dir="ltr" lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=5.0" /> | ||
<title>Sample Pages Navigation</title> | ||
<style> | ||
body { | ||
font-family: Arial, sans-serif; | ||
text-align: center; | ||
margin: 0; | ||
padding: 2rem; | ||
background-color: #f9f9f9; | ||
} | ||
h1 { | ||
color: #333; | ||
} | ||
ul { | ||
list-style: none; | ||
padding: 0; | ||
} | ||
li { | ||
margin: 1rem 0; | ||
} | ||
a { | ||
text-decoration: none; | ||
color: #0078d4; | ||
font-size: 1.2rem; | ||
} | ||
a:hover { | ||
text-decoration: underline; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<h1>Sample Pages Navigation</h1> | ||
<ul> | ||
<li><a href="hosted-ui-builder.html">Hosted UI - Builder</a></li> | ||
<li><a href="hosted-ui-trial.html">Hosted UI - Trial</a></li> | ||
<li><a href="hosted-ui-code.html">Hosted UI - Code</a></li> | ||
</ul> | ||
</body> | ||
</html> |
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,9 @@ | ||
import {defineConfig} from 'vite'; | ||
|
||
export default defineConfig({ | ||
define: { | ||
'process.env.DEPLOYMENT_ENVIRONMENT': JSON.stringify( | ||
process.env.DEPLOYMENT_ENVIRONMENT || 'LOCAL' | ||
), | ||
}, | ||
}); |
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,97 @@ | ||
import {execSync} from 'child_process'; | ||
import fs from 'fs/promises'; | ||
import ncp from 'ncp'; | ||
import path from 'path'; | ||
|
||
const getCurrentDir = () => { | ||
const url = import.meta.url; | ||
const fileURL = new URL(url); | ||
return path.dirname(fileURL.pathname); | ||
}; | ||
|
||
const getVersionFromPackageJson = async (packagePath) => { | ||
const packageJsonPath = path.join(packagePath, 'package.json'); | ||
try { | ||
const packageJson = JSON.parse(await fs.readFile(packageJsonPath, 'utf-8')); | ||
return packageJson.version; | ||
} catch (err) { | ||
console.error(`Error reading ${packageJsonPath}: ${err.message}`); | ||
process.exit(1); | ||
} | ||
}; | ||
|
||
const copyFiles = async (source, destination) => { | ||
return new Promise((resolve, reject) => { | ||
ncp(source, destination, (err) => { | ||
if (err) { | ||
reject(err); | ||
} else { | ||
resolve(); | ||
} | ||
}); | ||
}); | ||
}; | ||
|
||
const currentDir = getCurrentDir(); | ||
const headlessDir = path.resolve(currentDir, '../../headless'); | ||
const buenoDir = path.resolve(currentDir, '../../bueno'); | ||
const atomicHostedPageDir = path.resolve( | ||
currentDir, | ||
'../dist/atomic-hosted-page' | ||
); | ||
const devPublicDir = path.resolve(currentDir, '../dev/public'); | ||
|
||
const run = async () => { | ||
const headlessVersion = await getVersionFromPackageJson(headlessDir); | ||
const buenoVersion = await getVersionFromPackageJson(buenoDir); | ||
|
||
const directories = [ | ||
`${devPublicDir}/headless/v${headlessVersion}`, | ||
`${devPublicDir}/bueno/v${buenoVersion}`, | ||
`${devPublicDir}/atomic-hosted-page/`, | ||
]; | ||
|
||
for (const dir of directories) { | ||
if ( | ||
await fs | ||
.access(dir) | ||
.then(() => true) | ||
.catch(() => false) | ||
) { | ||
console.log(`Deleting existing directory: ${dir}`); | ||
await fs.rm(dir, {recursive: true, force: true}); | ||
} | ||
} | ||
|
||
for (const dir of directories) { | ||
console.log(`Creating directory: ${dir}`); | ||
await fs.mkdir(dir, {recursive: true}); | ||
} | ||
|
||
console.log( | ||
`Copying headless files to ${devPublicDir}/headless/v${headlessVersion}` | ||
); | ||
await copyFiles( | ||
path.join(headlessDir, 'dist/browser'), | ||
`${devPublicDir}/headless/v${headlessVersion}` | ||
); | ||
|
||
console.log(`Copying bueno files to ${devPublicDir}/bueno/v${buenoVersion}`); | ||
await copyFiles( | ||
path.join(buenoDir, 'dist/browser'), | ||
`${devPublicDir}/bueno/v${buenoVersion}` | ||
); | ||
|
||
console.log( | ||
`Copying atomic-hosted-page files to ${devPublicDir}/atomic-hosted-page/` | ||
); | ||
await copyFiles(atomicHostedPageDir, `${devPublicDir}/atomic-hosted-page/`); | ||
|
||
console.log('Starting Vite server...'); | ||
execSync('vite serve dev', {stdio: 'inherit'}); | ||
}; | ||
|
||
run().catch((err) => { | ||
console.error('An error occurred:', err); | ||
process.exit(1); | ||
}); |
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.