-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
076ba50
commit a8505c8
Showing
13 changed files
with
92 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ | |
/.vscode | ||
/workbench | ||
/lib | ||
/es | ||
/es | ||
/generated |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
export const TYPES_BUILD_DIR = '../lib/'; | ||
export const TYPES_BUILD_DIR = '../generated/'; | ||
export const LENGTH_GENERIC_ARGUMENT = 'TLength'; | ||
export const LENGTH_TYPE_NAME = 'Length'; | ||
export const CSS_TYPES_FILE = 'types.ts'; | ||
export const UNIT_TYPES_FILE = 'unitTypes.ts'; | ||
export const UNIT_UTILS_FILE = 'unitUtils.ts'; |
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,42 @@ | ||
import * as fs from 'fs'; | ||
import { map } from 'lodash/fp'; | ||
import * as path from 'path'; | ||
import ts from 'typescript'; | ||
import * as util from 'util'; | ||
import { TYPES_BUILD_DIR } from './constants'; | ||
|
||
export function generateIndex(filenames: string[]) { | ||
const printer = ts.createPrinter({ | ||
newLine: ts.NewLineKind.LineFeed, | ||
}); | ||
|
||
const indexSource = ts.createSourceFile( | ||
'index.ts', | ||
'', | ||
ts.ScriptTarget.ESNext, | ||
false, | ||
ts.ScriptKind.TS, | ||
); | ||
const exportDeclarations = map( | ||
filename => | ||
ts.createExportDeclaration( | ||
[], | ||
[], | ||
undefined, | ||
ts.createStringLiteral(filename), | ||
), | ||
filenames, | ||
); | ||
|
||
// const export | ||
const updatedSource = ts.updateSourceFileNode( | ||
indexSource, | ||
exportDeclarations, | ||
); | ||
|
||
const writeFile = util.promisify(fs.writeFile); | ||
return writeFile( | ||
path.join(__dirname, TYPES_BUILD_DIR, indexSource.fileName), | ||
printer.printFile(updatedSource), | ||
); | ||
} |
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,7 @@ | ||
{ | ||
"extends": "./tsconfig.compile.generated.json", | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"outDir": "lib" | ||
} | ||
} |
File renamed without changes.
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,12 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es5", | ||
}, | ||
"extends": "./tsconfig.json", | ||
"include": [ | ||
"generated/**/*", | ||
], | ||
"exclude": [ | ||
"**/*/__tests__/**/*" | ||
] | ||
} |
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