fitbit-sdk-types
Advanced tools
Comparing version 4.1.5 to 4.1.6
{ | ||
"name": "fitbit-sdk-types", | ||
"version": "4.1.5", | ||
"version": "4.1.6", | ||
"author": "Sergio Morchón Poveda <sergio.morchon@outlook.com>", | ||
"description": "Types for Fitbit SDK.", | ||
"bin": "scripts/index.js", | ||
"files": [ | ||
"types/**/*.d.ts", | ||
"scripts/**/*.js" | ||
], | ||
"keywords": [ | ||
@@ -34,8 +38,8 @@ "typescript", | ||
"devDependencies": { | ||
"@types/node": "^11.13.8", | ||
"prettier": "^1.17.0", | ||
"tslint": "^5.16.0", | ||
"@types/node": "^11.13.19", | ||
"prettier": "^1.18.2", | ||
"tslint": "^5.19.0", | ||
"tslint-config-prettier": "^1.18.0", | ||
"typescript": "^3.4.5" | ||
"typescript": "^3.5.3" | ||
} | ||
} |
@@ -11,3 +11,5 @@ # Fitbit SDK Types ✔ | ||
1. First, create your Fitbit CLI project following the official instructions at https://dev.fitbit.com/build/guides/command-line-interface/. | ||
2. Then, from that project root, run `npx fitbit-sdk-types apply` to apply TypeScript to your existing Fitbit project. | ||
2. Then, from that project root, you can run: | ||
- `npx fitbit-sdk-types apply-js` to enhance your existing Fitbit project with autocomplete and soft checks. | ||
- Or `npx fitbit-sdk-types apply-ts` to convert your project to TypeScript and have all the features. | ||
@@ -14,0 +16,0 @@ You can also do it manually wit the following basic configuration files: |
@@ -38,2 +38,9 @@ const { name: moduleName, version: moduleVersion } = require('../package.json'); | ||
}; | ||
const commonJsConfig = { | ||
extends: '../tsconfig.json', | ||
compilerOptions: { | ||
checkJs: true, | ||
}, | ||
include: ['**/*.js'], | ||
}; | ||
@@ -47,2 +54,6 @@ const fitbitProjects = [ | ||
}, | ||
jsConfig: { | ||
...commonJsConfig, | ||
include: [getTypesPathForTarget('device'), ...commonJsConfig.include], | ||
} | ||
}, | ||
@@ -55,2 +66,6 @@ { | ||
}, | ||
jsConfig: { | ||
...commonJsConfig, | ||
include: [getTypesPathForTarget('companion'), ...commonJsConfig.include], | ||
} | ||
}, | ||
@@ -67,6 +82,14 @@ { | ||
}, | ||
jsConfig: { | ||
...commonJsConfig, | ||
include: [ | ||
getTypesPathForTarget('settings'), | ||
...commonJsConfig.include, | ||
'**/*.jsx', | ||
], | ||
}, | ||
}, | ||
]; | ||
exports.default = () => { | ||
exports.default = (/** @type {'ts' | 'js'} */ mode) => { | ||
tryRun( | ||
@@ -82,21 +105,23 @@ () => | ||
.filter(({ directory }) => existsSync(directory)) | ||
.forEach(({ directory, tsConfig }) => { | ||
for (const fileName of walkFiles(directory)) { | ||
if (!/.*\.j(s|sx)$/.test(fileName)) { | ||
continue; | ||
.forEach(({ directory, tsConfig, jsConfig }) => { | ||
if (mode === 'ts') { | ||
for (const fileName of walkFiles(directory)) { | ||
if (!/.*\.j(s|sx)$/.test(fileName)) { | ||
continue; | ||
} | ||
const renamedFileName = fileName.replace(/\.js(x)?$/, '.ts$1'); | ||
tryRun( | ||
() => renameSync(fileName, renamedFileName), | ||
`renaming ${fileName} > ${renamedFileName}`, | ||
); | ||
} | ||
} | ||
const renamedFileName = fileName.replace(/\.js(x)?$/, '.ts$1'); | ||
tryRun( | ||
() => renameSync(fileName, renamedFileName), | ||
`renaming ${fileName} > ${renamedFileName}`, | ||
); | ||
const tsConfigFileName = join(directory, 'tsconfig.json'); | ||
tryRun( | ||
() => writeFileSync(tsConfigFileName, stringify(tsConfig)), | ||
`creating ${tsConfigFileName}`, | ||
); | ||
} | ||
const configFileName = join(directory, mode === 'ts' ? 'tsconfig.json' : 'jsconfig.json'); | ||
tryRun( | ||
() => writeFileSync(configFileName, stringify(mode === 'ts' ? tsConfig : jsConfig)), | ||
`creating ${configFileName}`, | ||
); | ||
}); | ||
}; |
@@ -6,7 +6,8 @@ #!/usr/bin/env node | ||
const APPLY_COMMAND = 'apply'; | ||
const [, , applyArg] = process.argv; | ||
if (applyArg !== APPLY_COMMAND) { | ||
const APPLY_TS_COMMAND = 'apply-ts'; | ||
const APPLY_JS_COMMAND = 'apply-js'; | ||
const [, , command] = process.argv; | ||
if (command !== APPLY_JS_COMMAND && command !== APPLY_TS_COMMAND) { | ||
console.log( | ||
`Run '${moduleName} ${APPLY_COMMAND}' to move this project to TypeScript`, | ||
`Run '${moduleName} ${APPLY_JS_COMMAND}' to enhance your JavaScript project, or '${moduleName} ${APPLY_TS_COMMAND}' to move your project to the full TypeScript experience.`, | ||
); | ||
@@ -16,2 +17,2 @@ process.exit(); | ||
apply(); | ||
apply(command === APPLY_TS_COMMAND ? 'ts' : 'js'); |
@@ -0,1 +1,3 @@ | ||
/// <reference lib="es2015.iterable" /> | ||
/// <reference lib="es2015.promise" /> | ||
/// <reference path="../shared/cbor.d.ts" /> | ||
@@ -2,0 +4,0 @@ /// <reference path="../shared/console.d.ts" /> |
@@ -0,1 +1,3 @@ | ||
/// <reference lib="es2015.iterable" /> | ||
/// <reference lib="es2015.promise" /> | ||
/// <reference path="../shared/cbor.d.ts" /> | ||
@@ -2,0 +4,0 @@ /// <reference path="../shared/console.d.ts" /> |
type BatchedSensorReading<Reading> = { | ||
[P in keyof Reading]: Reading[P] extends number | ||
? Float32Array | ||
: Array<Reading[P]> | ||
: Array<Reading[P]>; | ||
}; | ||
@@ -6,0 +6,0 @@ |
@@ -0,1 +1,3 @@ | ||
/// <reference lib="es2015.iterable" /> | ||
/// <reference lib="es2015.promise" /> | ||
/// <reference path="../companion/live-storage.d.ts" /> | ||
@@ -2,0 +4,0 @@ /// <reference path="../companion/storage.d.ts" /> |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
49881
1595
116
62