2.0.12 • Published 9 months ago

@particle/device-os-version-checks v2.0.12

Weekly downloads
205
License
UNLICENSED
Repository
-
Last release
9 months ago

@particle/device-os-version-checks

Version checking utilities for Device OS

Installation

npm install @particle/device-os-version-checks --save

API

@particle/device-os-version-checks


deviceOSVersionChecks.isObsoleteFirmware(target, allFirmware) ⇒ boolean

Determines if given Device OS version is considered obsolete based on a list of available versions.

Summary of rules: if you're on LTS, you should be on the latest major version. if you're on an RC (prerelease), it should be newer than any non-RC or LTS release and you should be on the latest RC available. if you are on a normal release (non-RC, non-LTS), you should be on the latest major and no more than 2 minor releases behind. if you're on something older than v1.4.4, you should update. otherwise, you're good!

Kind: static method of @particle/device-os-version-checks
Returns: boolean - Whether or not the given version is considered obsolete.

ParamTypeDescription
targetstring | objectSemver-compaitble version string or an object with a similarly formatted version field.
allFirmwarestring | arrayThe list of firmware versions (either strings or objects) to check against. NOTE: MUST BE SORTED IN DESCENDING ORDER

Example

const version = '1.0.0';
const dependency = { version };

const allFirmware = [
    { version: '1.0.0' },
    { version: '0.9.0' },
    { version: '0.8.0' },
    { version: '0.7.0' }
];

if (isObsoleteFirmware(version || dependency, allFirmware)){
    console.warn('...');
}

deviceOSVersionChecks.isLTSVersion(target) ⇒ boolean

Determines if given Device OS version is an LTS (long-term support) line.

Kind: static method of @particle/device-os-version-checks
Returns: boolean - Whether or not the given version is an LTS line.

ParamTypeDescription
targetstring | objectSemver-compaitble version string or an object with a similarly formatted version field.

Example

const version = '4.0.0';
const dependency = { version };

if (isLTSVersion(version || dependency)){
    console.log('LTS!');
}

deviceOSVersionChecks.isReleaseVersion(target) ⇒ boolean

Determines if given Device OS version is a standard (non-LTS, non-rc) line.

Kind: static method of @particle/device-os-version-checks
Returns: boolean - Whether or not the given version is a standard (non-LTS, non-rc) line.

ParamTypeDescription
targetstring | objectSemver-compaitble version string or an object with a similarly formatted version field.

Example

const version = '1.0.0';
const dependency = { version };

if (isReleaseVersion(version || dependency)){
    console.log('standard release line');
}

deviceOSVersionChecks.isPreReleaseVersion(target) ⇒ boolean

Determines if given Device OS version is a pre-release (rc).

Kind: static method of @particle/device-os-version-checks
Returns: boolean - Whether or not the given version is a pre-release (rc).

ParamTypeDescription
targetstring | objectSemver-compaitble version string or an object with a similarly formatted version field.

Example

const version = '1.0.0-rc.1';
const dependency = { version };

if (isPreReleaseVersion(version || dependency)){
    console.log('RC!');
}

deviceOSVersionChecks.isSourceVersion(target) ⇒ boolean

Determines if given Device OS version is source (e.g. deviceOS@source).

Kind: static method of @particle/device-os-version-checks
Returns: boolean - Whether or not the given version is source (e.g. deviceOS@source).

ParamTypeDescription
targetstring | objectSemver-compaitble version string or an object with a similarly formatted version field.

Example

const version = 'source';

if (isSourceVersion(version)){
    console.log('working from source!');
}

deviceOSVersionChecks.pickLatestVersion(a, b) ⇒ string

Returns greater of two targets' semver-compaitble version string.

Kind: static method of @particle/device-os-version-checks
Returns: string - The greater version amongst a and b.

ParamTypeDescription
astring | objectSemver-compaitble version string or an object with a similarly formatted version field.
bstring | objectSemver-compaitble version string or an object with a similarly formatted version field.

Example

const a = '0.6.0';
const b = { version: '0.8.5' };
const latest = pickLatestVersion(a, b);
console.log(latest); // 0.8.5;

NOTE: Unfortunately, docs have a nasty habit of falling out of date. When in doubt, check usage in tests

2.0.12

1 year ago

2.0.11

2 years ago

2.0.10

3 years ago

2.0.9-beta.0

3 years ago

2.0.8-beta.0

3 years ago

2.0.9

3 years ago

2.0.7

3 years ago

2.0.5

4 years ago

2.0.6

4 years ago

2.0.4

4 years ago

2.0.3

4 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago