-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: Add theming script
- Loading branch information
Rúben Carvalho
authored
Jan 22, 2024
1 parent
f5b64b8
commit 3e7478d
Showing
5 changed files
with
52 additions
and
2 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,37 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
import fs from "node:fs"; | ||
import path from "node:path"; | ||
import process from "node:process"; | ||
import { globbySync } from "globby"; | ||
const cwd = process.cwd(); | ||
|
||
const targetDir = path.join(cwd, "./lib/components-themeable/internal"); | ||
const stylesSourceDir = path.join(cwd, "./src/"); | ||
const stylesTargetDir = path.join(targetDir, "/scss"); | ||
|
||
const componentsSourceDir = path.join(cwd, "./lib/components"); | ||
const componentsTargetDir = path.join(targetDir, "/template"); | ||
|
||
function copyStyles() { | ||
for (const file of globbySync("**/*.scss", { cwd: stylesSourceDir })) { | ||
const content = fs.readFileSync(path.join(stylesSourceDir, file), "utf-8"); | ||
fs.mkdirSync(path.join(stylesTargetDir, path.dirname(file)), { recursive: true }); | ||
fs.writeFileSync( | ||
path.join(stylesTargetDir, file), | ||
content.replace( | ||
/@use "(\.\.\/)+node_modules\/@cloudscape-design\/design-tokens\/index.scss"/, | ||
'@use "awsui:tokens"' | ||
), | ||
"utf-8" | ||
); | ||
} | ||
} | ||
|
||
function copyTemplate() { | ||
fs.mkdirSync(componentsTargetDir, { recursive: true }); | ||
fs.cpSync(componentsSourceDir, componentsTargetDir, { recursive: true }); | ||
} | ||
|
||
copyTemplate(); | ||
copyStyles(); |