Skip to content

Commit

Permalink
Merge pull request #765 from particle-iot/feature/sc-129513/use-the-d…
Browse files Browse the repository at this point in the history
…eviceos-versions-endpoints-when

Use the DeviceOS versions endpoints when compiling
  • Loading branch information
suda authored Sep 11, 2024
2 parents 42b719d + f006e9a commit 7826f4e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 11 deletions.
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){
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

0 comments on commit 7826f4e

Please sign in to comment.