|
| 1 | +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 2 | +// SPDX-License-Identifier: Apache-2.0 |
| 3 | +import fs from "node:fs"; |
| 4 | +import path from "node:path"; |
| 5 | +import process from "node:process"; |
| 6 | +import { globbySync } from "globby"; |
| 7 | +const cwd = process.cwd(); |
| 8 | + |
| 9 | +const targetDir = path.join(cwd, "./lib/components-themeable/internal"); |
| 10 | +const stylesSourceDir = path.join(cwd, "./src/"); |
| 11 | +const stylesTargetDir = path.join(targetDir, "/scss"); |
| 12 | + |
| 13 | +const componentsSourceDir = path.join(cwd, "./lib/components"); |
| 14 | +const componentsTargetDir = path.join(targetDir, "/template"); |
| 15 | + |
| 16 | +function copyStyles() { |
| 17 | + for (const file of globbySync("**/*.scss", { cwd: stylesSourceDir })) { |
| 18 | + const content = fs.readFileSync(path.join(stylesSourceDir, file), "utf-8"); |
| 19 | + fs.mkdirSync(path.join(stylesTargetDir, path.dirname(file)), { recursive: true }); |
| 20 | + fs.writeFileSync( |
| 21 | + path.join(stylesTargetDir, file), |
| 22 | + content.replace( |
| 23 | + /@use "(\.\.\/)+node_modules\/@cloudscape-design\/design-tokens\/index.scss"/, |
| 24 | + '@use "awsui:tokens"' |
| 25 | + ), |
| 26 | + "utf-8" |
| 27 | + ); |
| 28 | + } |
| 29 | +} |
| 30 | + |
| 31 | +function copyTemplate() { |
| 32 | + fs.mkdirSync(componentsTargetDir, { recursive: true }); |
| 33 | + fs.cpSync(componentsSourceDir, componentsTargetDir, { recursive: true }); |
| 34 | +} |
| 35 | + |
| 36 | +copyTemplate(); |
| 37 | +copyStyles(); |
0 commit comments