File tree Expand file tree Collapse file tree 4 files changed +46
-3
lines changed Expand file tree Collapse file tree 4 files changed +46
-3
lines changed Original file line number Diff line number Diff line change @@ -44,4 +44,5 @@ jspm_packages
4444/.yarn_home
4545/dsfr
4646/dist_test
47+ /src /lib /useTheme /generated
4748
Original file line number Diff line number Diff line change 99 "main" : " dist/lib/index.js" ,
1010 "types" : " dist/lib/index.d.ts" ,
1111 "scripts" : {
12- "build" : " rimraf dist/ && tsc -p src/bin && tsc -p src && yarn grant_exec_perms && yarn copy_dsfr_dist_to_root " ,
12+ "build" : " rimraf dist/ && tsc -p src/bin && yarn copy_dsfr_dist_to_root && yarn css_to_ts && tsc -p src && yarn grant_exec_perms " ,
1313 "build:test" : " rimraf dist_test/ && tsc -p src/test" ,
1414 "pretest" : " yarn build:test" ,
1515 "test" : " node dist_test/test/bin/main.js" ,
2222 "format" : " yarn _format --write" ,
2323 "format:check" : " yarn _format --list-different" ,
2424 "yarn_link" : " ts-node src/bin/yarn_link.ts" ,
25- "grant_exec_perms" : " node dist/bin/tools/grant_exec_perms.js" ,
26- "copy_dsfr_dist_to_root" : " node dist/bin/copy_dsfr_dist_to_root.js"
25+ "grant_exec_perms" : " node dist/bin/tools/grant_exec_perms" ,
26+ "copy_dsfr_dist_to_root" : " node dist/bin/copy_dsfr_dist_to_root" ,
27+ "css_to_ts" : " node dist/bin/css_to_ts"
2728 },
2829 "bin" : {
2930 "copy_dsfr_dist_to_public" : " dist/bin/copy_dsfr_dist_to_public.js"
Original file line number Diff line number Diff line change 1+ import { generateGetColorOptionsTsCode , parseColorOptions } from "./colorOptions" ;
2+ import { getProjectRoot } from "../tools/getProjectRoot" ;
3+ import * as fs from "fs" ;
4+ import { join as pathJoin , dirname as pathDirname , relative as pathRelative } from "path" ;
5+
6+ const projectRoot = getProjectRoot ( ) ;
7+
8+ const rawCssCode = fs . readFileSync ( pathJoin ( projectRoot , "dsfr" , "dsfr.css" ) ) . toString ( "utf8" ) ;
9+
10+ const tsCode = generateGetColorOptionsTsCode ( parseColorOptions ( rawCssCode ) ) ;
11+
12+ const targetFilePath = pathJoin (
13+ projectRoot ,
14+ "src" ,
15+ "lib" ,
16+ "useTheme" ,
17+ "generated" ,
18+ "getColorOptions.ts"
19+ ) ;
20+
21+ fs . mkdirSync ( pathDirname ( targetFilePath ) , { "recursive" : true } ) ;
22+
23+ fs . writeFileSync (
24+ targetFilePath ,
25+ Buffer . from (
26+ [
27+ `// This file is generated automatically by ${ pathRelative (
28+ projectRoot ,
29+ __filename
30+ ) } , please don't edit.`,
31+ `import type { ColorScheme } from "../../useColorScheme";` ,
32+ `` ,
33+ tsCode ,
34+ `` ,
35+ `export type ColorOptions = ReturnType<typeof getColorOptions>;` ,
36+ ``
37+ ] . join ( "\n" ) ,
38+ "utf8"
39+ )
40+ ) ;
Original file line number Diff line number Diff line change 1+ import "./css_to_ts" ;
You can’t perform that action at this time.
0 commit comments