Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the DeviceOS versions endpoints when compiling #765

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"lodash": "^4.17.15",
"moment": "^2.24.0",
"node-wifiscanner2": "^1.2.1",
"particle-api-js": "^10.5.1",
"particle-api-js": "^10.6.0",
"particle-commands": "^1.0.1",
"particle-library-manager": "^0.1.15",
"particle-usb": "^3.6.0",
Expand Down
11 changes: 11 additions & 0 deletions src/cmd/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,17 @@ module.exports = class ParticleApi {
);
}

listDeviceOsVersions(platformId, internalVersion, perPage=100){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we have different params I think might worth to transform it like {platformId, internalVersion, perPage=100} = {} unless we can't use the params separately like just send internalVersion without platformId

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. In this instance only platformId parameter is being used. I kept the positional arguments instead of making them named (with {}) to keep the function signature match the others.

return this._wrap(
this.api.listDeviceOsVersions({
platformId,
internalVersion,
perPage,
auth: this.accessToken
})
);
}

compileCode(files, platformId, targetVersion){
return this._wrap(
this.api.compileCode({
Expand Down
6 changes: 3 additions & 3 deletions src/cmd/cloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,15 +300,15 @@ module.exports = class CloudCommand extends CLICommandBase {

let data;
try {
data = await createAPI().listBuildTargets(true /* onlyFeatured */);
data = await createAPI().listDeviceOsVersions(platformId);
} catch (error) {
throw normalizedApiError(error);
}

const validTargets = data.targets.filter((t) => t.platforms.includes(platformId));
const validTargets = data.versions.filter((t) => t.release_state !== 'archived');
const validTarget = validTargets.filter((t) => t.version === target);
if (!validTarget.length) {
throw new VError(['Invalid build target version.', 'Valid targets:'].concat(_.map(validTargets, 'version')).join('\n'));
throw new VError(['Invalid build target version.', 'Valid targets:'].concat(validTargets.map((v) => `${v.version} ${v.release_state === 'preview' ? '(preview)' : ''}`)).join('\n'));
}
targetVersion = validTarget[0].version;
this.ui.stdout.write(`Targeting version: ${targetVersion}${os.EOL}`);
Expand Down
Loading