-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: build theme-data and type-declarations
- Loading branch information
1 parent
fe9309b
commit 42d4cab
Showing
4 changed files
with
51 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
node_modules/ | ||
!.figmaexportrc.js | ||
theme-data.js |
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 |
---|---|---|
|
@@ -2,5 +2,7 @@ | |
/dist/ | ||
/toucan.css | ||
/index.css | ||
/theme-data.js | ||
/theme-data.d.ts | ||
/coverage/ | ||
yarn-error.log |
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,33 @@ | ||
import path from 'path'; | ||
import fs from 'fs/promises'; | ||
import { fileURLToPath } from 'url'; | ||
import fse from 'fs-extra'; | ||
import { stripIndent } from 'common-tags'; | ||
|
||
const __dirname = path.dirname(fileURLToPath(import.meta.url)); | ||
|
||
const outputFile = 'theme-data.js'; | ||
const outputDeclarationsFile = 'theme-data.d.ts'; | ||
const themeJsonPath = path.join(__dirname, '..', 'themes.json'); | ||
|
||
async function build() { | ||
let json = await fse.readJSON(themeJsonPath); | ||
|
||
await fs.writeFile( | ||
path.join(__dirname, '..', outputFile), | ||
stripIndent` | ||
export default ${JSON.stringify(json, null, 2)}; | ||
` | ||
); | ||
|
||
await fs.writeFile( | ||
path.join(__dirname, '..', outputDeclarationsFile), | ||
stripIndent` | ||
declare let ThemeData = ${JSON.stringify(json, null, 2)}; | ||
export default ThemeData; | ||
` | ||
); | ||
} | ||
|
||
build(); |
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