-
Notifications
You must be signed in to change notification settings - Fork 798
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GH Pages] Embedded mode configuration (#1733)
Ticket: CVS-132109
- Loading branch information
Showing
9 changed files
with
116 additions
and
4 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
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,52 @@ | ||
// @ts-check | ||
|
||
import crypto from 'node:crypto'; | ||
import fs from 'node:fs'; | ||
import { join, resolve } from 'node:path'; | ||
|
||
const algorithm = 'sha256'; | ||
|
||
export const checksumFileName = `checksum.${algorithm}`; | ||
|
||
const createSHAHash = () => crypto.createHash(algorithm); | ||
|
||
/** | ||
* @param {string} distPath | ||
* @returns {Promise<void>} | ||
*/ | ||
export async function createBuildChecksumFile(distPath) { | ||
const paths = await getFilesInDirectory(distPath); | ||
const fileChecksums = await Promise.all(paths.map(async (path) => await getFileChecksum(path))); | ||
const buildChecksum = createSHAHash().update(fileChecksums.join('')).digest('hex'); | ||
await fs.promises.writeFile(join(distPath, checksumFileName), buildChecksum, { flag: 'w' }); | ||
} | ||
|
||
/** | ||
* @param {string} filePath | ||
* @returns {Promise<string>} | ||
*/ | ||
async function getFileChecksum(filePath) { | ||
return new Promise((resolve, reject) => { | ||
const hash = createSHAHash(); | ||
const stream = fs.createReadStream(filePath); | ||
stream.on('error', (err) => reject(err)); | ||
stream.on('data', (chunk) => hash.update(chunk)); | ||
stream.on('end', () => resolve(hash.digest('hex'))); | ||
}); | ||
} | ||
|
||
/** | ||
* @param {string} directoryPath | ||
* @returns {Promise<string[]>} | ||
*/ | ||
async function getFilesInDirectory(directoryPath) { | ||
const entries = await fs.promises.readdir(directoryPath, { withFileTypes: true }); | ||
const entriesPromises = entries.map(async (entry) => { | ||
const entryPath = resolve(directoryPath, entry.name); | ||
if (entry.isDirectory()) { | ||
return await getFilesInDirectory(entryPath); | ||
} | ||
return entryPath; | ||
}); | ||
return (await Promise.all(entriesPromises)).flat(20); | ||
} |
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 |
---|---|---|
|
@@ -4,6 +4,10 @@ | |
body { | ||
margin: 0; | ||
@include flex-col(); | ||
|
||
&.embedded { | ||
overflow-y: hidden; | ||
} | ||
} | ||
|
||
#root { | ||
|
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