@nordicsemiconductor/pc-nrfconnect-shared 119.0.0 → 120.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Changelog.md CHANGED
@@ -7,6 +7,15 @@ This project does _not_ adhere to
7
7
  [Semantic Versioning](https://semver.org/spec/v2.0.0.html) but contrary to it
8
8
  every new version is a new major version.
9
9
 
10
+ ## 120 - 2023-10-13
11
+
12
+ ### Fixed
13
+
14
+ - `prepareSandbox()` couldn't be called from the launcher any longer. Even
15
+ when the version to install was provided, `prepareSandbox()` tried to look
16
+ into the `package.json`, which didn't exist any longer in the launcher,
17
+ because it is only supplied during build time by apps now.
18
+
10
19
  ## 119 - 2023-10-13
11
20
 
12
21
  ### Changed
@@ -43,6 +52,10 @@ every new version is a new major version.
43
52
  - `nrfutil device batch` could previously call the `onException` when task was
44
53
  complete.
45
54
 
55
+ ### Changed
56
+
57
+ - Read the `package.json` already during compile time, but only for apps.
58
+
46
59
  ## 115 - 2023-09-28
47
60
 
48
61
  ### Fixed
@@ -1,6 +1,6 @@
1
1
  <?xml version="1.0" ?>
2
2
  <!DOCTYPE coverage SYSTEM "http://cobertura.sourceforge.net/xml/coverage-04.dtd">
3
- <coverage lines-valid="3211" lines-covered="1788" line-rate="0.5568" branches-valid="1531" branches-covered="448" branch-rate="0.2926" timestamp="1697204097167" complexity="0" version="0.1">
3
+ <coverage lines-valid="3215" lines-covered="1792" line-rate="0.5573" branches-valid="1523" branches-covered="448" branch-rate="0.29410000000000003" timestamp="1697205972605" complexity="0" version="0.1">
4
4
  <sources>
5
5
  <source>/home/vsts/work/1/s</source>
6
6
  </sources>
@@ -401,59 +401,84 @@
401
401
  </class>
402
402
  </classes>
403
403
  </package>
404
- <package name="nrfutil" line-rate="0.0877" branch-rate="0">
404
+ <package name="nrfutil" line-rate="0.10339999999999999" branch-rate="0">
405
405
  <classes>
406
- <class name="moduleVersion.ts" filename="nrfutil/moduleVersion.ts" line-rate="0.29410000000000003" branch-rate="0">
406
+ <class name="moduleVersion.ts" filename="nrfutil/moduleVersion.ts" line-rate="0.3333" branch-rate="0">
407
407
  <methods>
408
- <method name="(anonymous_3)" hits="0" signature="()V">
408
+ <method name="(anonymous_5)" hits="0" signature="()V">
409
409
  <lines>
410
- <line number="15" hits="0"/>
410
+ <line number="16" hits="0"/>
411
411
  </lines>
412
412
  </method>
413
- <method name="(anonymous_4)" hits="0" signature="()V">
413
+ <method name="(anonymous_6)" hits="0" signature="()V">
414
414
  <lines>
415
- <line number="33" hits="0"/>
415
+ <line number="34" hits="0"/>
416
416
  </lines>
417
417
  </method>
418
- <method name="(anonymous_5)" hits="0" signature="()V">
418
+ <method name="(anonymous_7)" hits="0" signature="()V">
419
419
  <lines>
420
- <line number="34" hits="0"/>
420
+ <line number="35" hits="0"/>
421
421
  </lines>
422
422
  </method>
423
- <method name="(anonymous_6)" hits="0" signature="()V">
423
+ <method name="(anonymous_8)" hits="0" signature="()V">
424
424
  <lines>
425
- <line number="36" hits="0"/>
425
+ <line number="37" hits="0"/>
426
426
  </lines>
427
427
  </method>
428
- <method name="(anonymous_8)" hits="0" signature="()V">
428
+ <method name="(anonymous_10)" hits="0" signature="()V">
429
429
  <lines>
430
- <line number="46" hits="0"/>
430
+ <line number="47" hits="0"/>
431
431
  </lines>
432
432
  </method>
433
- <method name="(anonymous_9)" hits="0" signature="()V">
433
+ <method name="(anonymous_11)" hits="0" signature="()V">
434
434
  <lines>
435
- <line number="53" hits="0"/>
435
+ <line number="54" hits="0"/>
436
+ </lines>
437
+ </method>
438
+ <method name="(anonymous_12)" hits="0" signature="()V">
439
+ <lines>
440
+ <line number="60" hits="0"/>
441
+ </lines>
442
+ </method>
443
+ <method name="(anonymous_14)" hits="0" signature="()V">
444
+ <lines>
445
+ <line number="74" hits="0"/>
446
+ </lines>
447
+ </method>
448
+ <method name="(anonymous_15)" hits="0" signature="()V">
449
+ <lines>
450
+ <line number="78" hits="0"/>
436
451
  </lines>
437
452
  </method>
438
453
  </methods>
439
454
  <lines>
440
- <line number="13" hits="2" branch="false"/>
441
- <line number="15" hits="2" branch="false"/>
442
- <line number="16" hits="0" branch="true" condition-coverage="0% (0/1)"/>
443
- <line number="17" hits="0" branch="false"/>
444
- <line number="20" hits="0" branch="true" condition-coverage="0% (0/1)"/>
445
- <line number="21" hits="0" branch="false"/>
446
- <line number="24" hits="0" branch="true" condition-coverage="0% (0/3)"/>
447
- <line number="25" hits="0" branch="false"/>
448
- <line number="28" hits="0" branch="false"/>
449
- <line number="33" hits="2" branch="false"/>
450
- <line number="34" hits="0" branch="false"/>
451
- <line number="36" hits="2" branch="false"/>
452
- <line number="40" hits="0" branch="true" condition-coverage="0% (0/1)"/>
453
- <line number="43" hits="0" branch="false"/>
454
- <line number="46" hits="0" branch="false"/>
455
- <line number="53" hits="2" branch="false"/>
456
- <line number="57" hits="0" branch="true" condition-coverage="0% (0/4)"/>
455
+ <line number="7" hits="3" branch="false"/>
456
+ <line number="14" hits="3" branch="false"/>
457
+ <line number="16" hits="3" branch="false"/>
458
+ <line number="17" hits="0" branch="true" condition-coverage="0% (0/1)"/>
459
+ <line number="18" hits="0" branch="false"/>
460
+ <line number="21" hits="0" branch="true" condition-coverage="0% (0/1)"/>
461
+ <line number="22" hits="0" branch="false"/>
462
+ <line number="25" hits="0" branch="true" condition-coverage="0% (0/3)"/>
463
+ <line number="26" hits="0" branch="false"/>
464
+ <line number="29" hits="0" branch="false"/>
465
+ <line number="34" hits="3" branch="false"/>
466
+ <line number="35" hits="0" branch="false"/>
467
+ <line number="37" hits="3" branch="false"/>
468
+ <line number="41" hits="0" branch="true" condition-coverage="0% (0/1)"/>
469
+ <line number="44" hits="0" branch="false"/>
470
+ <line number="47" hits="0" branch="false"/>
471
+ <line number="54" hits="3" branch="false"/>
472
+ <line number="58" hits="0" branch="true" condition-coverage="0% (0/4)"/>
473
+ <line number="60" hits="3" branch="false"/>
474
+ <line number="61" hits="0" branch="false"/>
475
+ <line number="62" hits="0" branch="true" condition-coverage="0% (0/1)"/>
476
+ <line number="67" hits="0" branch="false"/>
477
+ <line number="72" hits="0" branch="true" condition-coverage="0% (0/4)"/>
478
+ <line number="74" hits="3" branch="false"/>
479
+ <line number="75" hits="0" branch="false"/>
480
+ <line number="78" hits="3" branch="false"/>
481
+ <line number="79" hits="0" branch="true" condition-coverage="0% (0/12)"/>
457
482
  </lines>
458
483
  </class>
459
484
  <class name="nrfutilLogger.ts" filename="nrfutil/nrfutilLogger.ts" line-rate="1" branch-rate="1">
@@ -475,7 +500,7 @@
475
500
  <line number="15" hits="3" branch="false"/>
476
501
  </lines>
477
502
  </class>
478
- <class name="sandbox.ts" filename="nrfutil/sandbox.ts" line-rate="0.0594" branch-rate="0">
503
+ <class name="sandbox.ts" filename="nrfutil/sandbox.ts" line-rate="0.061200000000000004" branch-rate="0">
479
504
  <methods>
480
505
  <method name="(anonymous_5)" hits="0" signature="()V">
481
506
  <lines>
@@ -709,7 +734,7 @@
709
734
  </method>
710
735
  <method name="(anonymous_52)" hits="0" signature="()V">
711
736
  <lines>
712
- <line number="532" hits="0"/>
737
+ <line number="512" hits="0"/>
713
738
  </lines>
714
739
  </method>
715
740
  </methods>
@@ -898,24 +923,18 @@
898
923
  <line number="485" hits="0" branch="false"/>
899
924
  <line number="489" hits="3" branch="false"/>
900
925
  <line number="495" hits="0" branch="false"/>
901
- <line number="497" hits="0" branch="true" condition-coverage="0% (0/1)"/>
926
+ <line number="501" hits="0" branch="true" condition-coverage="0% (0/4)"/>
902
927
  <line number="502" hits="0" branch="false"/>
903
- <line number="507" hits="0" branch="true" condition-coverage="0% (0/2)"/>
904
- <line number="511" hits="0" branch="true" condition-coverage="0% (0/4)"/>
905
- <line number="512" hits="0" branch="false"/>
906
- <line number="515" hits="0" branch="false"/>
907
- <line number="521" hits="0" branch="true" condition-coverage="0% (0/4)"/>
928
+ <line number="504" hits="0" branch="true" condition-coverage="0% (0/1)"/>
929
+ <line number="505" hits="0" branch="false"/>
930
+ <line number="508" hits="0" branch="true" condition-coverage="0% (0/4)"/>
931
+ <line number="509" hits="0" branch="false"/>
932
+ <line number="512" hits="3" branch="false"/>
933
+ <line number="513" hits="0" branch="true" condition-coverage="0% (0/4)"/>
934
+ <line number="514" hits="0" branch="true" condition-coverage="0% (0/4)"/>
935
+ <line number="516" hits="0" branch="false"/>
936
+ <line number="519" hits="0" branch="false"/>
908
937
  <line number="522" hits="0" branch="false"/>
909
- <line number="524" hits="0" branch="true" condition-coverage="0% (0/1)"/>
910
- <line number="525" hits="0" branch="false"/>
911
- <line number="528" hits="0" branch="true" condition-coverage="0% (0/4)"/>
912
- <line number="529" hits="0" branch="false"/>
913
- <line number="532" hits="3" branch="false"/>
914
- <line number="533" hits="0" branch="true" condition-coverage="0% (0/4)"/>
915
- <line number="534" hits="0" branch="true" condition-coverage="0% (0/4)"/>
916
- <line number="536" hits="0" branch="false"/>
917
- <line number="539" hits="0" branch="false"/>
918
- <line number="542" hits="0" branch="false"/>
919
938
  </lines>
920
939
  </class>
921
940
  <class name="sandboxTypes.ts" filename="nrfutil/sandboxTypes.ts" line-rate="0" branch-rate="0">
@@ -4,6 +4,7 @@
4
4
  * SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
5
5
  */
6
6
 
7
+ import packageJson from '../src/utils/packageJson';
7
8
  import {
8
9
  Dependency,
9
10
  isIncrementalVersion,
@@ -55,3 +56,27 @@ export const resolveModuleVersion = (
55
56
  versions: Dependency[] = []
56
57
  ): Dependency | SubDependency | undefined =>
57
58
  findTopLevel(module, versions) ?? findInDependencies(module, versions);
59
+
60
+ const overriddenVersion = (module: string) => {
61
+ const env = { ...process.env };
62
+ if (
63
+ process.env.NODE_ENV !== 'production' ||
64
+ (process.env.NODE_ENV === 'production' &&
65
+ !!process.env.NRF_OVERRIDE_NRFUTIL_SETTINGS)
66
+ ) {
67
+ return env[`NRF_OVERRIDE_VERSION_${module.toLocaleUpperCase()}`];
68
+ }
69
+ };
70
+
71
+ const versionFromPackageJson = (module: string) =>
72
+ packageJson().nrfConnectForDesktop.nrfutil?.[module][0];
73
+
74
+ const failToDetermineVersion = (module: string) => {
75
+ throw new Error(`No version specified for nrfutil-${module}`);
76
+ };
77
+
78
+ export const versionToInstall = (module: string, version?: string) =>
79
+ version ??
80
+ overriddenVersion(module) ??
81
+ versionFromPackageJson(module) ??
82
+ failToDetermineVersion(module);
@@ -10,7 +10,7 @@ import os from 'os';
10
10
  import path from 'path';
11
11
 
12
12
  import describeError from '../src/logging/describeError';
13
- import packageJson from '../src/utils/packageJson';
13
+ import { versionToInstall } from './moduleVersion';
14
14
  import { getNrfutilLogger } from './nrfutilLogger';
15
15
  import {
16
16
  BackgroundTask,
@@ -492,30 +492,10 @@ export default async (
492
492
  version?: string,
493
493
  onProgress?: (progress: Progress, task?: Task) => void
494
494
  ) => {
495
- const env = { ...process.env };
496
- let overrideVersion: string | undefined;
497
- if (
498
- process.env.NODE_ENV !== 'production' ||
499
- (process.env.NODE_ENV === 'production' &&
500
- !!process.env.NRF_OVERRIDE_NRFUTIL_SETTINGS)
501
- ) {
502
- overrideVersion =
503
- env[`NRF_OVERRIDE_VERSION_${module.toLocaleUpperCase()}`] ??
504
- undefined;
505
- }
506
-
507
- const moduleVersions = overrideVersion
508
- ? [overrideVersion]
509
- : packageJson().nrfConnectForDesktop?.nrfutil?.[module];
510
-
511
- if (!version && (!moduleVersions || moduleVersions.length === 0)) {
512
- throw new Error(`No version specified for nrfutil-${module}`);
513
- }
514
-
515
495
  const sandbox = new NrfutilSandbox(
516
496
  baseDir,
517
497
  module,
518
- version ?? (moduleVersions?.[0] as string)
498
+ versionToInstall(module, version)
519
499
  );
520
500
 
521
501
  onProgress?.(convertNrfutilProgress({ progressPercentage: 0 }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nordicsemiconductor/pc-nrfconnect-shared",
3
- "version": "119.0.0",
3
+ "version": "120.0.0",
4
4
  "description": "Shared commodities for developing pc-nrfconnect-* packages",
5
5
  "repository": {
6
6
  "type": "git",
@@ -21,7 +21,7 @@ const parsedPackageJson = () => {
21
21
  cache = parsed.data;
22
22
  } else {
23
23
  throw new Error(
24
- `The env variable PACKAGE_JSON_OF_APP must be defined during bundling (through the bundler settings) with a valid package.json but wasn't. Fix this. Error: ${parsed.error.details}`
24
+ `The env variable PACKAGE_JSON_OF_APP must be defined during bundling (through the bundler settings) with a valid package.json but wasn't. Fix this. Error: ${parsed.error.message}`
25
25
  );
26
26
  }
27
27
 
@@ -2,5 +2,6 @@ import { Dependency, SubDependency } from './sandboxTypes';
2
2
  export declare const describeVersion: (version?: SubDependency | string) => string;
3
3
  type KnownModule = 'nrfdl' | 'jprog' | 'JlinkARM';
4
4
  export declare const resolveModuleVersion: (module: KnownModule, versions?: Dependency[]) => Dependency | SubDependency | undefined;
5
+ export declare const versionToInstall: (module: string, version?: string) => string;
5
6
  export {};
6
7
  //# sourceMappingURL=moduleVersion.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"moduleVersion.d.ts","sourceRoot":"","sources":["../../../nrfutil/moduleVersion.ts"],"names":[],"mappings":"AAMA,OAAO,EACH,UAAU,EAIV,aAAa,EAChB,MAAM,gBAAgB,CAAC;AAExB,eAAO,MAAM,eAAe,aAAc,aAAa,GAAG,MAAM,WAc/D,CAAC;AAEF,KAAK,WAAW,GAAG,OAAO,GAAG,OAAO,GAAG,UAAU,CAAC;AAsBlD,eAAO,MAAM,oBAAoB,WACrB,WAAW,aACT,UAAU,EAAE,KACvB,UAAU,GAAG,aAAa,GAAG,SAC0C,CAAC"}
1
+ {"version":3,"file":"moduleVersion.d.ts","sourceRoot":"","sources":["../../../nrfutil/moduleVersion.ts"],"names":[],"mappings":"AAOA,OAAO,EACH,UAAU,EAIV,aAAa,EAChB,MAAM,gBAAgB,CAAC;AAExB,eAAO,MAAM,eAAe,aAAc,aAAa,GAAG,MAAM,WAc/D,CAAC;AAEF,KAAK,WAAW,GAAG,OAAO,GAAG,OAAO,GAAG,UAAU,CAAC;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