fitbit-sdk-types
Advanced tools
Comparing version 4.3.8 to 4.3.9
{ | ||
"name": "fitbit-sdk-types", | ||
"version": "4.3.8", | ||
"version": "4.3.9", | ||
"author": "Sergio Morchón Poveda <sergio.morchon@outlook.com>", | ||
@@ -39,16 +39,10 @@ "description": "Types for Fitbit SDK.", | ||
"devDependencies": { | ||
"@types/node": "^13.11.0", | ||
"@typescript-eslint/eslint-plugin": "^2.27.0", | ||
"@typescript-eslint/parser": "^2.27.0", | ||
"eslint": "^6.8.0", | ||
"eslint-config-prettier": "^6.10.1", | ||
"husky": "^4.2.5", | ||
"prettier": "^2.0.4", | ||
"typescript": "^3.8.3" | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "npm run fix-code" | ||
} | ||
"@types/node": "^14.6.3", | ||
"@typescript-eslint/eslint-plugin": "^4.0.1", | ||
"@typescript-eslint/parser": "^4.0.1", | ||
"eslint": "^7.8.1", | ||
"eslint-config-prettier": "^6.11.0", | ||
"prettier": "^2.1.1", | ||
"typescript": "^4.0.2" | ||
} | ||
} |
@@ -12,3 +12,3 @@ # Fitbit SDK Types ✔ | ||
2. Then, from that project root, run `npx fitbit-sdk-types` to enhance your existing Fitbit project with autocomplete and code checks. | ||
3. Finally, start using typescript by changing the suffix of the files "app/index.js", "companion/index.js" and "settings/index.jsx" to ".ts" and ".tsx" respectively. | ||
3. Take a look at the [FAQ](./FAQ.md). | ||
@@ -15,0 +15,0 @@ ## Benefits of using types |
@@ -5,3 +5,10 @@ #!/usr/bin/env node | ||
const { execSync } = require('child_process'); | ||
const { existsSync, writeFileSync, readFileSync } = require('fs'); | ||
const { | ||
existsSync, | ||
writeFileSync, | ||
readFileSync, | ||
readdirSync, | ||
statSync, | ||
renameSync, | ||
} = require('fs'); | ||
const { join } = require('path'); | ||
@@ -12,2 +19,18 @@ | ||
/** | ||
* @param {string} root | ||
* @returns {Generator<string>} | ||
*/ | ||
function* walkFiles(root) { | ||
for (const fileName of readdirSync(root)) { | ||
const path = join(root, fileName); | ||
if (statSync(path).isDirectory()) { | ||
yield* walkFiles(path); | ||
continue; | ||
} | ||
yield path; | ||
} | ||
} | ||
/** | ||
* @param {() => void} fn | ||
@@ -18,7 +41,6 @@ * @param {string} action | ||
try { | ||
console.log(`Start ${action}`); | ||
console.log(action); | ||
fn(); | ||
console.log('Done'); | ||
} catch (error) { | ||
console.error(`Error while ${action}: ${error}`); | ||
console.error(`${action}: ${error}`); | ||
} | ||
@@ -32,3 +54,3 @@ }; | ||
}), | ||
`Adding ${moduleDependency}`, | ||
`Add dev dependency ${moduleDependency}`, | ||
); | ||
@@ -46,4 +68,18 @@ | ||
() => writeFileSync(targetFile, readFileSync(sourceFile, 'utf-8')), | ||
`Adding ${targetFile}`, | ||
`Create ${targetFile}`, | ||
); | ||
for (const fileName of walkFiles(folder)) { | ||
const result = /^(.*)\.js(x)?$/.exec(fileName); | ||
if (!result) { | ||
continue; | ||
} | ||
const [, name, x = ''] = result; | ||
const targetName = `${name}.ts${x}`; | ||
tryRun( | ||
() => renameSync(fileName, targetName), | ||
`Rename ${fileName} to ${targetName}`, | ||
); | ||
} | ||
} |
@@ -12,3 +12,3 @@ declare module 'haptics' { | ||
interface Vibration { | ||
start(pattern: VibrationPatternName): void; | ||
start(pattern: VibrationPatternName): boolean; | ||
stop(): void; | ||
@@ -15,0 +15,0 @@ } |
@@ -24,3 +24,3 @@ declare const Fragment: (props: { children: JSX.Element }) => JSX.Element; | ||
declare const Button: (props: { | ||
label?: string; | ||
label?: JSX.Element; | ||
list?: boolean; | ||
@@ -43,4 +43,4 @@ onClick: (event: Event) => void; | ||
declare const TextInput: <Option extends { name: string }>(props: { | ||
title?: string; | ||
label?: string; | ||
title?: JSX.Element; | ||
label?: JSX.Element; | ||
placeholder?: string; | ||
@@ -69,5 +69,5 @@ action?: string; | ||
declare const Select: <Option extends { name: string }>(props: { | ||
title?: string; | ||
selectViewTitle?: string; | ||
label?: string; | ||
title?: JSX.Element; | ||
selectViewTitle?: JSX.Element; | ||
label?: JSX.Element; | ||
settingsKey?: string; | ||
@@ -87,4 +87,4 @@ options: ReadonlyArray<Option>; | ||
}>(props: { | ||
title?: string; | ||
description?: string; | ||
title?: JSX.Element; | ||
description?: JSX.Element; | ||
settingsKey?: string; | ||
@@ -98,6 +98,6 @@ minItems?: number | string; | ||
declare const Oauth: (props: { | ||
title?: string; | ||
label?: string; | ||
title?: JSX.Element; | ||
label?: JSX.Element; | ||
status?: string; | ||
description?: string; | ||
description?: JSX.Element; | ||
settingsKey?: string; | ||
@@ -125,4 +125,4 @@ authorizeUrl?: string; | ||
declare const StravaLogin: (props: { | ||
title?: string; | ||
description?: string; | ||
title?: JSX.Element; | ||
description?: JSX.Element; | ||
settingsKey: string; | ||
@@ -134,9 +134,9 @@ clientId?: string; | ||
declare const ImagePicker: (props: { | ||
title?: string; | ||
description?: string; | ||
label?: string; | ||
sublabel?: string; | ||
pickerTitle?: string; | ||
pickerImageTitle?: string; | ||
pickerLabel?: string; | ||
title?: JSX.Element; | ||
description?: JSX.Element; | ||
label?: JSX.Element; | ||
sublabel?: JSX.Element; | ||
pickerTitle?: JSX.Element; | ||
pickerImageTitle?: JSX.Element; | ||
pickerLabel?: JSX.Element; | ||
settingsKey?: string; | ||
@@ -143,0 +143,0 @@ imageWidth?: number | string; |
52851
7
1776