fitbit-sdk-types
Advanced tools
Comparing version 7.0.5 to 8.0.0
{ | ||
"name": "fitbit-sdk-types", | ||
"version": "7.0.5", | ||
"version": "8.0.0", | ||
"author": "Sergio Morchón Poveda <sergio.morchon@outlook.com>", | ||
"description": "Types for Fitbit SDK.", | ||
"bin": "scripts/index.js", | ||
"type": "module", | ||
"files": [ | ||
@@ -39,11 +40,11 @@ "types/**/*.d.ts", | ||
"devDependencies": { | ||
"@types/node": "^17.0.8", | ||
"@typescript-eslint/eslint-plugin": "^5.9.1", | ||
"@typescript-eslint/parser": "^5.9.1", | ||
"eslint": "^8.6.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"prettier": "^2.5.1", | ||
"typescript": "^4.5.4" | ||
"@types/node": "^18.7.16", | ||
"@typescript-eslint/eslint-plugin": "^5.36.2", | ||
"@typescript-eslint/parser": "^5.36.2", | ||
"eslint": "^8.23.0", | ||
"eslint-config-prettier": "^8.5.0", | ||
"prettier": "^2.7.1", | ||
"typescript": "^4.8.3" | ||
}, | ||
"packageManager": "yarn@3.1.1" | ||
"packageManager": "yarn@3.2.2" | ||
} |
@@ -10,6 +10,17 @@ # 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` to enhance your existing Fitbit project with autocomplete and code checks. | ||
3. Take a look at the [FAQ](./FAQ.md). | ||
1. First, create your Fitbit CLI project following the official instructions at https://dev.fitbit.com/build/guides/command-line-interface/. | ||
1. Then, from that project root, run `npx fitbit-sdk-types install`. Also you acn use the following optional flags to customize your TypeScript and Visual Studio Code integrations. | ||
- `--vscode`: add a few tweaks to integrate with Visual Studio Code | ||
- Background tasks | ||
![Visual Studio Code problems integration](./doc/img/vscode-background-tasks.png) | ||
- Problems report | ||
![Visual Studio Code problems integration](./doc/img/vscode-problems-integration.png) | ||
- `--migrate`: rename all the `.js` files to `.ts`. | ||
1. Take a look at the [FAQ](./FAQ.md). | ||
## Benefits of using types | ||
@@ -16,0 +27,0 @@ |
#!/usr/bin/env node | ||
const { name: moduleName, version: moduleVersion } = require('../package.json'); | ||
const { execSync } = require('child_process'); | ||
import { parseArgs } from 'node:util'; | ||
import { install } from './install.js'; | ||
import { help } from './help.js'; | ||
const { | ||
existsSync, | ||
writeFileSync, | ||
readFileSync, | ||
readdirSync, | ||
statSync, | ||
renameSync, | ||
} = require('fs'); | ||
const { join } = require('path'); | ||
values: { migrate = false, vscode = false }, | ||
positionals: [command], | ||
} = parseArgs({ | ||
strict: true, | ||
options: { | ||
migrate: { type: 'boolean' }, | ||
vscode: { type: 'boolean' }, | ||
}, | ||
allowPositionals: true, | ||
}); | ||
const moduleDependency = `${moduleName}@${moduleVersion}`; | ||
/** | ||
* @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; | ||
} | ||
switch (command) { | ||
case 'install': | ||
install({ migrate, vscode }); | ||
break; | ||
default: | ||
help(); | ||
} | ||
/** | ||
* @param {() => void} fn | ||
* @param {string} action | ||
*/ | ||
const tryRun = (fn, action) => { | ||
try { | ||
console.log(action); | ||
fn(); | ||
} catch (error) { | ||
console.error(`${action}: ${error}`); | ||
} | ||
}; | ||
tryRun( | ||
() => | ||
execSync(`npm install --save-dev ${moduleDependency}`, { | ||
stdio: 'inherit', | ||
}), | ||
`Add dev dependency ${moduleDependency}`, | ||
); | ||
const tsconfigFileName = 'tsconfig.json'; | ||
for (const folder of ['app', 'companion', 'settings']) { | ||
if (!existsSync(folder)) { | ||
continue; | ||
} | ||
const sourceFile = join(__dirname, 'scaffolding', folder, tsconfigFileName); | ||
const targetFile = join(folder, tsconfigFileName); | ||
tryRun( | ||
() => writeFileSync(targetFile, readFileSync(sourceFile, 'utf-8')), | ||
`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}`, | ||
); | ||
} | ||
} |
{ | ||
"extends": "../tsconfig.json", | ||
"compilerOptions": { | ||
"target": "es2015", | ||
"lib": ["es2015"], | ||
"noEmit": true, | ||
@@ -7,0 +5,0 @@ "checkJs": true |
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
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
63902
71
2093
85
0
0
Yes