Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(integration): port code-generator to ts
- Loading branch information
Showing
10 changed files
with
173 additions
and
78 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 |
---|---|---|
@@ -1,13 +1,8 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"strict": true, | ||
"lib": ["es5", "es2015.promise", "dom"], | ||
"target": "es5", | ||
|
||
"sourceMap": true, | ||
"declaration": true, | ||
"outDir": "build", | ||
"moduleResolution": "node" | ||
"lib": ["es5", "es2015.promise", "dom"] | ||
}, | ||
"include": ["src/**/*.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
10 changes: 5 additions & 5 deletions
10
packages/integrations/src/gen-readme.js → packages/integrations/src/gen-readme.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 was deleted.
Oops, something went wrong.
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,65 @@ | ||
import {parse} from 'yaml' | ||
import { readFileSync } from 'fs' | ||
import { resolve } from 'path' | ||
|
||
export interface IntegrationDeclaration { | ||
name: string | ||
ios: { | ||
disabled?: boolean | ||
pod?: { | ||
name?: string | ||
version?: string | ||
} | ||
prefix?: string | ||
className?: string | ||
framework?: string | ||
header?: string | ||
} | ||
android: { | ||
disabled?: boolean | ||
factory?: { | ||
class?: string | ||
import?: string | ||
} | ||
maven?: { | ||
repo?: string | ||
name?: string | ||
version?: string | ||
} | ||
} | ||
} | ||
|
||
export interface Integration extends IntegrationDeclaration { | ||
name: string | ||
slug(separator?: string): string | ||
npm: { | ||
package: string | ||
} | ||
} | ||
|
||
const integrations: IntegrationDeclaration[] = parse( | ||
readFileSync(resolve(__dirname, '../integrations.yml'), 'utf-8') | ||
) | ||
|
||
export default integrations | ||
.map(({ name, ios = {}, android = {} }) => { | ||
if (ios.disabled && android.disabled) { | ||
return null! | ||
} | ||
|
||
const slug = (sep = '') => name.replace(/-|_| /g, sep) | ||
const suffix = ios.disabled ? '-android' : android.disabled ? '-ios' : '' | ||
|
||
return { | ||
name, | ||
slug, | ||
ios, | ||
android, | ||
npm: { | ||
package: `@segment/analytics-react-native-${slug( | ||
'-' | ||
).toLowerCase()}${suffix}` | ||
} | ||
} | ||
}) | ||
.filter(integration => integration !== null) |
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,2 @@ | ||
declare module 'markdown-table' | ||
declare module '*.json' |
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,10 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"target": "es6", | ||
"outDir": "build", | ||
"allowSyntheticDefaultImports": true, | ||
"esModuleInterop": true | ||
}, | ||
"include": ["src/**/*.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"compilerOptions": { | ||
"strict": true, | ||
"noImplicitAny": true, | ||
"target": "es5", | ||
"sourceMap": true, | ||
"declaration": true, | ||
"moduleResolution": "node" | ||
} | ||
} |
Oops, something went wrong.