@nordicsemiconductor/pc-nrfconnect-shared 190.0.0 → 191.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.
Files changed (37) hide show
  1. package/Changelog.md +18 -0
  2. package/ipc/MetaFiles.ts +1 -4
  3. package/ipc/apps.ts +2 -1
  4. package/nrfutil/device/logLibVersions.ts +37 -22
  5. package/nrfutil/index.ts +2 -1
  6. package/nrfutil/jlinkVersion.test.ts +323 -0
  7. package/nrfutil/jlinkVersion.ts +144 -0
  8. package/nrfutil/moduleVersion.ts +17 -31
  9. package/nrfutil/modules.ts +1 -6
  10. package/nrfutil/sandbox.ts +1 -0
  11. package/nrfutil/sandboxTypes.ts +19 -59
  12. package/nrfutil/version.ts +54 -0
  13. package/package.json +1 -1
  14. package/scripts/nordic-publish.js +12 -12
  15. package/src/utils/systemReport.ts +3 -6
  16. package/typings/generated/ipc/MetaFiles.d.ts +1 -1
  17. package/typings/generated/ipc/MetaFiles.d.ts.map +1 -1
  18. package/typings/generated/ipc/apps.d.ts +2 -1
  19. package/typings/generated/ipc/apps.d.ts.map +1 -1
  20. package/typings/generated/ipc/schema/packageJson.d.ts +15 -15
  21. package/typings/generated/nrfutil/device/logLibVersions.d.ts.map +1 -1
  22. package/typings/generated/nrfutil/index.d.ts +2 -1
  23. package/typings/generated/nrfutil/index.d.ts.map +1 -1
  24. package/typings/generated/nrfutil/jlinkVersion.d.ts +24 -0
  25. package/typings/generated/nrfutil/jlinkVersion.d.ts.map +1 -0
  26. package/typings/generated/nrfutil/jlinkVersion.test.d.ts +2 -0
  27. package/typings/generated/nrfutil/jlinkVersion.test.d.ts.map +1 -0
  28. package/typings/generated/nrfutil/moduleVersion.d.ts +4 -4
  29. package/typings/generated/nrfutil/moduleVersion.d.ts.map +1 -1
  30. package/typings/generated/nrfutil/modules.d.ts.map +1 -1
  31. package/typings/generated/nrfutil/sandbox.d.ts.map +1 -1
  32. package/typings/generated/nrfutil/sandboxTypes.d.ts +14 -46
  33. package/typings/generated/nrfutil/sandboxTypes.d.ts.map +1 -1
  34. package/typings/generated/nrfutil/version.d.ts +27 -0
  35. package/typings/generated/nrfutil/version.d.ts.map +1 -0
  36. package/typings/generated/src/utils/packageJson.d.ts +2 -2
  37. package/typings/generated/src/utils/systemReport.d.ts.map +1 -1
@@ -6,26 +6,16 @@
6
6
 
7
7
  import { packageJsonApp } from '../src/utils/packageJson';
8
8
  import {
9
- Dependency,
10
- isIncrementalVersion,
11
- isSemanticVersion,
12
- isStringVersion,
13
- SubDependency,
14
- versionToString,
9
+ type Dependency,
10
+ hasVersion,
11
+ type TopLevelDependency,
15
12
  } from './sandboxTypes';
13
+ import { versionToString } from './version';
16
14
 
17
- export const describeVersion = (version?: SubDependency | string) => {
18
- if (typeof version === 'string') {
19
- return version;
20
- }
21
-
22
- if (isSemanticVersion(version)) {
23
- return `${version.version.major}.${version.version.minor}.${version.version.patch}`;
24
- }
25
-
26
- if (isIncrementalVersion(version) || isStringVersion(version)) {
27
- return String(version.version);
28
- }
15
+ export const describeVersion = (dependencyOrVersion?: Dependency | string) => {
16
+ if (typeof dependencyOrVersion === 'string') return dependencyOrVersion;
17
+ if (hasVersion(dependencyOrVersion))
18
+ return versionToString(dependencyOrVersion);
29
19
 
30
20
  return 'Unknown';
31
21
  };
@@ -37,10 +27,10 @@ const findTopLevel = (module: KnownModule, dependencies: Dependency[]) =>
37
27
 
38
28
  const findInDependencies = (
39
29
  module: KnownModule,
40
- dependencies: Dependency[]
30
+ dependencies: TopLevelDependency[]
41
31
  ) => {
42
32
  if (dependencies.length > 0) {
43
- return resolveModuleVersion(
33
+ return findDependency(
44
34
  module,
45
35
  dependencies.flatMap(dependency => [
46
36
  ...(dependency.dependencies ?? []),
@@ -53,16 +43,12 @@ const findInDependencies = (
53
43
  };
54
44
 
55
45
  export const getExpectedVersion = (dependency: Dependency) => {
56
- const currentVersion = versionToString(
57
- dependency.versionFormat,
58
- dependency.version
59
- );
46
+ if (!hasVersion(dependency)) return null;
47
+
48
+ const currentVersion = versionToString(dependency);
60
49
 
61
50
  const expectedVersion = dependency.expectedVersion
62
- ? versionToString(
63
- dependency.expectedVersion.versionFormat,
64
- dependency.expectedVersion.version
65
- )
51
+ ? versionToString(dependency.expectedVersion)
66
52
  : currentVersion;
67
53
 
68
54
  return {
@@ -71,10 +57,10 @@ export const getExpectedVersion = (dependency: Dependency) => {
71
57
  };
72
58
  };
73
59
 
74
- export const resolveModuleVersion = (
60
+ export const findDependency = (
75
61
  module: KnownModule,
76
- versions: Dependency[] = []
77
- ): Dependency | SubDependency | undefined =>
62
+ versions: TopLevelDependency[] = []
63
+ ): Dependency | undefined =>
78
64
  findTopLevel(module, versions) ?? findInDependencies(module, versions);
79
65
 
80
66
  const overriddenVersion = (module: string) => {
@@ -79,12 +79,7 @@ const getModuleSandbox = (module: string) => {
79
79
 
80
80
  const createModuleSandbox = async () => {
81
81
  getNrfutilLogger()?.info(`Initialising the bundled nrfutil ${module}`);
82
- promiseModuleSandbox = sandbox(
83
- getUserDataDir(),
84
- module,
85
- undefined,
86
- undefined
87
- );
82
+ promiseModuleSandbox = sandbox(getUserDataDir(), module);
88
83
  moduleSandbox = await promiseModuleSandbox;
89
84
 
90
85
  logModuleVersions(module, moduleSandbox);
@@ -201,6 +201,7 @@ export class NrfutilSandbox {
201
201
  force: true,
202
202
  });
203
203
  }
204
+ await this.updateNrfUtilCore();
204
205
  await this.spawnNrfutil(
205
206
  'install',
206
207
  [`${this.module}=${this.version}`, '--force'],
@@ -4,6 +4,8 @@
4
4
  * SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
5
5
  */
6
6
 
7
+ import type { DiscriminatedVersion } from './version';
8
+
7
9
  export interface BackgroundTask<T> {
8
10
  onError: (error: Error, pid?: number) => void;
9
11
  onData: (data: T) => void;
@@ -126,80 +128,38 @@ export type LogMessage = {
126
128
  message: string;
127
129
  };
128
130
 
129
- export interface SemanticVersion {
130
- major: number;
131
- minor: number;
132
- patch: number;
133
- semverPreNumeric?: number;
134
- semverPreAlphaNumeric?: number;
135
- semverMetadataNumeric?: number;
136
- semverMetadataAlphaNumeric?: number;
137
- }
138
-
139
- type VersionFormat = 'incremental' | 'semantic' | 'string';
140
-
141
- export type Plugin = {
142
- dependencies: Dependency[];
131
+ type Plugin = DiscriminatedVersion & {
132
+ dependencies: TopLevelDependency[];
143
133
  name: string;
144
- versionFormat: VersionFormat;
145
- version: VersionType;
146
134
  };
147
135
 
148
- export type Dependency = {
149
- classification?: FeatureClassification;
136
+ type DependencyWithoutVersion = {
150
137
  name: string;
151
- plugins?: Plugin[];
152
- dependencies?: SubDependency[];
153
- versionFormat: VersionFormat;
154
- version: VersionType;
155
- expectedVersion?: {
156
- versionFormat: VersionFormat;
157
- version: VersionType;
158
- };
138
+ description?: string;
139
+ dependencies?: Dependency[];
140
+ expectedVersion?: DiscriminatedVersion;
159
141
  };
142
+ type DependencyWithVersion = DiscriminatedVersion & DependencyWithoutVersion;
160
143
 
161
- export type VersionType = SemanticVersion | string | number;
144
+ export type Dependency = DependencyWithoutVersion | DependencyWithVersion;
162
145
 
163
- export interface SubDependency {
164
- name: string;
165
- description?: string;
166
- dependencies?: SubDependency[];
167
- versionFormat: VersionFormat;
168
- version: VersionType;
169
- expectedVersion?: { versionFormat: VersionFormat; version: VersionType };
170
- }
146
+ export type TopLevelDependency = Dependency & {
147
+ classification?: FeatureClassification;
148
+ plugins?: Plugin[];
149
+ };
171
150
 
172
151
  export type ModuleVersion = {
173
152
  build_timestamp: string;
174
153
  classification: FeatureClassification;
175
154
  commit_date: string;
176
155
  commit_hash: string;
177
- dependencies: Dependency[];
156
+ dependencies: TopLevelDependency[];
178
157
  host: string;
179
158
  name: string;
180
159
  version: string;
181
160
  };
182
161
 
183
- export const isSemanticVersion = (
184
- version?: SubDependency
185
- ): version is SubDependency & { version: SemanticVersion } =>
186
- version?.versionFormat === 'semantic';
187
-
188
- export const isIncrementalVersion = (
189
- version?: SubDependency
190
- ): version is SubDependency & { version: number } =>
191
- version?.versionFormat === 'incremental';
192
-
193
- export const isStringVersion = (
194
- version?: SubDependency
195
- ): version is SubDependency & { version: string } =>
196
- version?.versionFormat === 'string';
197
-
198
- export const versionToString = (type: VersionFormat, version: VersionType) => {
199
- if (type === 'incremental' || type === 'string') {
200
- return `${version}`;
201
- }
202
-
203
- const v = version as SemanticVersion;
204
- return `${v.major}.${v.minor}.${v.patch}`;
205
- };
162
+ export const hasVersion = (
163
+ dependency?: Dependency | DiscriminatedVersion
164
+ ): dependency is DependencyWithVersion | DiscriminatedVersion =>
165
+ dependency != null && 'version' in dependency && dependency.version != null;
@@ -0,0 +1,54 @@
1
+ /*
2
+ * Copyright (c) 2024 Nordic Semiconductor ASA
3
+ *
4
+ * SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
5
+ */
6
+
7
+ type IncrementalVersion = {
8
+ versionFormat: 'incremental';
9
+ version: number;
10
+ };
11
+
12
+ type SemanticVersion = {
13
+ versionFormat: 'semantic';
14
+ version: {
15
+ major: number;
16
+ minor: number;
17
+ patch: number;
18
+ semverPreNumeric?: number;
19
+ semverPreAlphaNumeric?: number;
20
+ semverMetadataNumeric?: number;
21
+ semverMetadataAlphaNumeric?: number;
22
+ };
23
+ };
24
+
25
+ type StringVersion = {
26
+ versionFormat: 'string';
27
+ version: string;
28
+ };
29
+
30
+ export type DiscriminatedVersion =
31
+ | IncrementalVersion
32
+ | SemanticVersion
33
+ | StringVersion;
34
+
35
+ export const isSemanticVersion = (
36
+ version?: DiscriminatedVersion
37
+ ): version is SemanticVersion => version?.versionFormat === 'semantic';
38
+
39
+ export const isIncrementalVersion = (
40
+ version?: DiscriminatedVersion
41
+ ): version is IncrementalVersion => version?.versionFormat === 'incremental';
42
+
43
+ export const isStringVersion = (
44
+ version?: DiscriminatedVersion
45
+ ): version is StringVersion => version?.versionFormat === 'string';
46
+
47
+ export const versionToString = (version: DiscriminatedVersion) => {
48
+ if (isSemanticVersion(version)) {
49
+ const semantic = version.version;
50
+ return `${semantic.major}.${semantic.minor}.${semantic.patch}`;
51
+ }
52
+
53
+ return String(version.version);
54
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nordicsemiconductor/pc-nrfconnect-shared",
3
- "version": "190.0.0",
3
+ "version": "191.0.0",
4
4
  "description": "Shared commodities for developing pc-nrfconnect-* packages",
5
5
  "repository": {
6
6
  "type": "git",