@nordicsemiconductor/pc-nrfconnect-shared 122.0.0 → 123.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 (93) hide show
  1. package/Changelog.md +51 -0
  2. package/coverage/cobertura-coverage.xml +1343 -978
  3. package/ipc/launcherConfig.ts +25 -0
  4. package/ipc/openWindow.ts +17 -1
  5. package/ipc/schema/packageJson.ts +26 -22
  6. package/main/index.ts +11 -5
  7. package/mocks/packageJsonMock.ts +1 -1
  8. package/nrfutil/device/batch.ts +1 -7
  9. package/nrfutil/device/common.ts +15 -8
  10. package/nrfutil/device/list.ts +1 -1
  11. package/nrfutil/moduleVersion.ts +2 -2
  12. package/nrfutil/sandbox.ts +52 -32
  13. package/nrfutil/sandboxTypes.ts +1 -1
  14. package/package.json +3 -2
  15. package/scripts/check-app-properties.ts +6 -6
  16. package/scripts/esbuild.ts +3 -3
  17. package/scripts/nordic-publish.js +23 -23
  18. package/scripts/nordic-publish.ts +3 -3
  19. package/scripts/release-shared.ts +2 -2
  20. package/src/About/ApplicationCard.tsx +3 -5
  21. package/src/App/App.test.tsx +7 -0
  22. package/src/App/App.tsx +14 -27
  23. package/src/Device/DeviceSelector/DeviceList/MoreDeviceInfo.tsx +1 -1
  24. package/src/Device/DeviceSelector/DeviceSelector.tsx +27 -9
  25. package/src/Device/deviceLister.ts +66 -23
  26. package/src/Device/deviceSetup.ts +4 -4
  27. package/src/Device/deviceSlice.ts +12 -3
  28. package/src/ErrorBoundary/ErrorBoundary.tsx +7 -13
  29. package/src/Feedback/sendFeedback.ts +2 -4
  30. package/src/index.ts +3 -0
  31. package/src/logging/sendInitialLogMessages.ts +2 -4
  32. package/src/utils/appDetails.ts +22 -0
  33. package/src/utils/appDirs.ts +4 -4
  34. package/src/utils/launcherConfig.ts +17 -0
  35. package/src/utils/packageJson.ts +52 -10
  36. package/src/utils/persistentStore.ts +21 -14
  37. package/src/utils/systemReport.ts +1 -3
  38. package/src/utils/usageData.ts +75 -167
  39. package/src/utils/usageDataCommon.ts +59 -0
  40. package/src/utils/usageDataMain.ts +117 -0
  41. package/src/utils/usageDataRenderer.ts +126 -0
  42. package/src/utils/useHotKey.ts +2 -2
  43. package/typings/generated/ipc/launcherConfig.d.ts +14 -0
  44. package/typings/generated/ipc/launcherConfig.d.ts.map +1 -0
  45. package/typings/generated/ipc/openWindow.d.ts +10 -4
  46. package/typings/generated/ipc/openWindow.d.ts.map +1 -1
  47. package/typings/generated/ipc/schema/packageJson.d.ts +34 -52
  48. package/typings/generated/ipc/schema/packageJson.d.ts.map +1 -1
  49. package/typings/generated/main/index.d.ts +8 -2
  50. package/typings/generated/main/index.d.ts.map +1 -1
  51. package/typings/generated/nrfutil/device/batch.d.ts.map +1 -1
  52. package/typings/generated/nrfutil/device/common.d.ts +1 -1
  53. package/typings/generated/nrfutil/device/common.d.ts.map +1 -1
  54. package/typings/generated/nrfutil/device/device.d.ts +2 -2
  55. package/typings/generated/nrfutil/device/list.d.ts +1 -1
  56. package/typings/generated/nrfutil/device/list.d.ts.map +1 -1
  57. package/typings/generated/nrfutil/sandbox.d.ts +2 -2
  58. package/typings/generated/nrfutil/sandbox.d.ts.map +1 -1
  59. package/typings/generated/nrfutil/sandboxTypes.d.ts +1 -1
  60. package/typings/generated/nrfutil/sandboxTypes.d.ts.map +1 -1
  61. package/typings/generated/src/About/ApplicationCard.d.ts.map +1 -1
  62. package/typings/generated/src/App/App.d.ts +0 -1
  63. package/typings/generated/src/App/App.d.ts.map +1 -1
  64. package/typings/generated/src/Device/DeviceSelector/DeviceSelector.d.ts.map +1 -1
  65. package/typings/generated/src/Device/deviceLister.d.ts.map +1 -1
  66. package/typings/generated/src/Device/deviceSetup.d.ts +2 -2
  67. package/typings/generated/src/Device/deviceSetup.d.ts.map +1 -1
  68. package/typings/generated/src/Device/deviceSlice.d.ts +5 -1
  69. package/typings/generated/src/Device/deviceSlice.d.ts.map +1 -1
  70. package/typings/generated/src/ErrorBoundary/ErrorBoundary.d.ts.map +1 -1
  71. package/typings/generated/src/Feedback/sendFeedback.d.ts.map +1 -1
  72. package/typings/generated/src/index.d.ts +2 -0
  73. package/typings/generated/src/index.d.ts.map +1 -1
  74. package/typings/generated/src/logging/sendInitialLogMessages.d.ts.map +1 -1
  75. package/typings/generated/src/utils/appDetails.d.ts +4 -0
  76. package/typings/generated/src/utils/appDetails.d.ts.map +1 -0
  77. package/typings/generated/src/utils/appDirs.d.ts +1 -1
  78. package/typings/generated/src/utils/appDirs.d.ts.map +1 -1
  79. package/typings/generated/src/utils/launcherConfig.d.ts +4 -0
  80. package/typings/generated/src/utils/launcherConfig.d.ts.map +1 -0
  81. package/typings/generated/src/utils/packageJson.d.ts +30 -7
  82. package/typings/generated/src/utils/packageJson.d.ts.map +1 -1
  83. package/typings/generated/src/utils/persistentStore.d.ts +3 -2
  84. package/typings/generated/src/utils/persistentStore.d.ts.map +1 -1
  85. package/typings/generated/src/utils/systemReport.d.ts.map +1 -1
  86. package/typings/generated/src/utils/usageData.d.ts +8 -65
  87. package/typings/generated/src/utils/usageData.d.ts.map +1 -1
  88. package/typings/generated/src/utils/usageDataCommon.d.ts +27 -0
  89. package/typings/generated/src/utils/usageDataCommon.d.ts.map +1 -0
  90. package/typings/generated/src/utils/usageDataMain.d.ts +10 -0
  91. package/typings/generated/src/utils/usageDataMain.d.ts.map +1 -0
  92. package/typings/generated/src/utils/usageDataRenderer.d.ts +10 -0
  93. package/typings/generated/src/utils/usageDataRenderer.d.ts.map +1 -0
@@ -0,0 +1,25 @@
1
+ /*
2
+ * Copyright (c) 2023 Nordic Semiconductor ASA
3
+ *
4
+ * SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
5
+ */
6
+
7
+ import { ipcMain, ipcRenderer } from 'electron';
8
+
9
+ export interface Configuration {
10
+ isRunningLauncherFromSource: boolean;
11
+ isSkipUpdateApps: boolean;
12
+ isSkipUpdateLauncher: boolean;
13
+ launcherVersion: string;
14
+ userDataDir: string;
15
+ }
16
+ const channel = 'get-config';
17
+
18
+ const getConfig = (): Configuration => ipcRenderer.sendSync(channel);
19
+ const registerGetConfig = (config: Configuration) =>
20
+ ipcMain.on(channel, event => {
21
+ event.returnValue = config;
22
+ });
23
+
24
+ export const forRenderer = { registerGetConfig };
25
+ export const inMain = { getConfig };
package/ipc/openWindow.ts CHANGED
@@ -12,8 +12,24 @@ const channel = {
12
12
  launcher: 'open-app-launcher', // It would be nice to call this `open:launcher` but we have to stick to the current name, because that is used by supported apps.
13
13
  };
14
14
 
15
+ export const isOpenAppOptionsDeviceSN = (
16
+ device: OpenAppOptionsDevice
17
+ ): device is OpenAppOptionsDeviceSN =>
18
+ (device as OpenAppOptionsDeviceSN).serialNumber !== undefined;
19
+
20
+ export const isOpenAppOptionsDevicePort = (
21
+ device: OpenAppOptionsDevice
22
+ ): device is OpenAppOptionsDevicePort =>
23
+ (device as OpenAppOptionsDevicePort).serialPortPath !== undefined;
24
+
25
+ type OpenAppOptionsDeviceSN = { serialNumber: string };
26
+
27
+ type OpenAppOptionsDevicePort = { serialPortPath: string };
28
+
29
+ type OpenAppOptionsDevice = OpenAppOptionsDeviceSN | OpenAppOptionsDevicePort;
30
+
15
31
  export interface OpenAppOptions {
16
- device?: { serialNumber: string; serialPortPath?: string };
32
+ device?: OpenAppOptionsDevice;
17
33
  }
18
34
 
19
35
  type OpenApp = (app: AppSpec, openAppOptions?: OpenAppOptions) => void;
@@ -10,6 +10,20 @@ import { knownDevicePcas } from '../device';
10
10
  import { nrfModules, semver } from '../MetaFiles';
11
11
  import { parseWithPrettifiedErrorMessage } from './parseJson';
12
12
 
13
+ const packageJson = z.object({
14
+ name: z.string(),
15
+ version: semver,
16
+
17
+ displayName: z.string().optional(),
18
+ });
19
+
20
+ export type PackageJson = z.infer<typeof packageJson>;
21
+
22
+ export const parsePackageJson =
23
+ parseWithPrettifiedErrorMessage<PackageJson>(packageJson);
24
+
25
+ // Apps have more required fields in their package.json
26
+
13
27
  const nrfConnectForDesktop = z.object({
14
28
  supportedDevices: z.enum(knownDevicePcas).array().nonempty().optional(),
15
29
  nrfutil: nrfModules.optional(),
@@ -22,12 +36,7 @@ const engines = recordOfOptionalStrings.and(
22
36
  z.object({ nrfconnect: z.string() })
23
37
  );
24
38
 
25
- const packageJson = z.object({
26
- name: z.string(),
27
- version: semver,
28
-
29
- author: z.string().optional(),
30
- bin: z.string().or(recordOfOptionalStrings).optional(),
39
+ const packageJsonApp = packageJson.extend({
31
40
  dependencies: recordOfOptionalStrings.optional(),
32
41
  description: z.string(),
33
42
  homepage: z.string().url().optional(),
@@ -36,8 +45,6 @@ const packageJson = z.object({
36
45
  engines,
37
46
  nrfConnectForDesktop,
38
47
  files: z.string().array().optional(),
39
- license: z.string().optional(),
40
- main: z.string().optional(),
41
48
  peerDependencies: recordOfOptionalStrings.optional(),
42
49
  repository: z
43
50
  .object({
@@ -45,25 +52,22 @@ const packageJson = z.object({
45
52
  url: z.string().url(),
46
53
  })
47
54
  .optional(),
48
- scripts: recordOfOptionalStrings.optional(),
49
55
  });
50
56
 
51
- export type PackageJson = z.infer<typeof packageJson>;
57
+ export type PackageJsonApp = z.infer<typeof packageJsonApp>;
52
58
 
53
- export const parsePackageJson =
54
- parseWithPrettifiedErrorMessage<PackageJson>(packageJson);
59
+ export const parsePackageJsonApp =
60
+ parseWithPrettifiedErrorMessage<PackageJsonApp>(packageJsonApp);
55
61
 
56
62
  // In the launcher we want to handle that the whole nrfConnectForDesktop may be missing
57
63
  // and the html in it can also be undefined, so there we need to use this legacy variant
58
- const legacyPackageJson = packageJson.merge(
59
- z.object({
60
- nrfConnectForDesktop: nrfConnectForDesktop
61
- .partial({ html: true })
62
- .optional(),
63
- })
64
- );
64
+ const packageJsonLegacyApp = packageJsonApp.extend({
65
+ nrfConnectForDesktop: nrfConnectForDesktop
66
+ .partial({ html: true })
67
+ .optional(),
68
+ });
65
69
 
66
- export type LegacyPackageJson = z.infer<typeof legacyPackageJson>;
70
+ export type PackageJsonLegacyApp = z.infer<typeof packageJsonLegacyApp>;
67
71
 
68
- export const parseLegacyPackageJson =
69
- parseWithPrettifiedErrorMessage<LegacyPackageJson>(legacyPackageJson);
72
+ export const parsePackageJsonLegacyApp =
73
+ parseWithPrettifiedErrorMessage<PackageJsonLegacyApp>(packageJsonLegacyApp);
package/main/index.ts CHANGED
@@ -6,6 +6,7 @@
6
6
 
7
7
  import { forRenderer as forRendererAppDetails } from '../ipc/appDetails';
8
8
  import { forRenderer as forRendererApps } from '../ipc/apps';
9
+ import { forRenderer as forRendererLauncherConfig } from '../ipc/launcherConfig';
9
10
  import { forRenderer as forRendererOpenWindow } from '../ipc/openWindow';
10
11
  import { forRenderer as forRendererPreventSleep } from '../ipc/preventSleep';
11
12
  import { forRenderer as forRendererSafeStorage } from '../ipc/safeStorage';
@@ -18,6 +19,7 @@ export { registerLauncherWindowFromMain } from '../ipc/infrastructure/mainToRend
18
19
 
19
20
  export const appDetails = { forRenderer: forRendererAppDetails };
20
21
  export const apps = { forRenderer: forRendererApps };
22
+ export const launcherConfig = { forRenderer: forRendererLauncherConfig };
21
23
  export const openWindow = { forRenderer: forRendererOpenWindow };
22
24
  export const preventSleep = { forRenderer: forRendererPreventSleep };
23
25
  export const safeStorage = {
@@ -37,11 +39,15 @@ export {
37
39
  type WithdrawnJson,
38
40
  } from '../ipc/MetaFiles';
39
41
  export {
40
- type LegacyPackageJson,
41
- type PackageJson,
42
- parseLegacyPackageJson,
43
- parsePackageJson,
42
+ type PackageJsonLegacyApp,
43
+ type PackageJsonApp,
44
+ parsePackageJsonLegacyApp,
45
+ parsePackageJsonApp,
44
46
  } from '../ipc/schema/packageJson';
45
47
 
46
48
  export { type OverwriteOptions } from '../ipc/serialPort';
47
- export { type OpenAppOptions } from '../ipc/openWindow';
49
+ export type { OpenAppOptions } from '../ipc/openWindow';
50
+ export {
51
+ isOpenAppOptionsDevicePort,
52
+ isOpenAppOptionsDeviceSN,
53
+ } from '../ipc/openWindow';
@@ -4,7 +4,7 @@
4
4
  * SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
5
5
  */
6
6
 
7
- export default () => ({
7
+ export const packageJson = () => ({
8
8
  name: 'mocked-test-app',
9
9
  version: '27.6.72',
10
10
  });
@@ -55,13 +55,7 @@ export class Batch {
55
55
  await box.singleInfoOperationOptionalData<object>(
56
56
  command,
57
57
  undefined,
58
- [
59
- '--serial-number', // this is a workaround this param should now be needed with --generate
60
- '123',
61
- '--generate',
62
- '--core',
63
- core,
64
- ].concat(args)
58
+ ['--generate', '--core', core].concat(args)
65
59
  );
66
60
 
67
61
  return {
@@ -50,7 +50,7 @@ export interface NordicDevKit {
50
50
  export interface NrfutilDevice {
51
51
  id: number;
52
52
  devkit?: NordicDevKit;
53
- serialNumber?: string; // undefined in case udev is not installed
53
+ serialNumber?: string | null; // undefined in case udev is not installed
54
54
  traits: DeviceTraits;
55
55
  usb?: USB;
56
56
  // non-Nordic devices may not have serialPorts property at all
@@ -172,26 +172,33 @@ export const getDeviceSandbox = async () => {
172
172
  );
173
173
  deviceSandbox = await promiseDeviceSandbox;
174
174
 
175
- deviceSandbox.onLogging(evt => {
175
+ deviceSandbox.onLogging((evt, pid) => {
176
176
  const deviceLogger = getNrfutilLogger();
177
+ const formatMsg = (msg: string) =>
178
+ `${
179
+ pid && deviceSandbox?.logLevel === 'trace'
180
+ ? `[PID:${pid}] `
181
+ : ''
182
+ }${msg}`;
183
+
177
184
  switch (evt.level) {
178
185
  case 'TRACE':
179
- deviceLogger?.verbose(evt.message);
186
+ deviceLogger?.verbose(formatMsg(evt.message));
180
187
  break;
181
188
  case 'DEBUG':
182
- deviceLogger?.debug(evt.message);
189
+ deviceLogger?.debug(formatMsg(evt.message));
183
190
  break;
184
191
  case 'INFO':
185
- deviceLogger?.info(evt.message);
192
+ deviceLogger?.info(formatMsg(evt.message));
186
193
  break;
187
194
  case 'WARN':
188
- deviceLogger?.warn(evt.message);
195
+ deviceLogger?.warn(formatMsg(evt.message));
189
196
  break;
190
197
  case 'ERROR':
191
- deviceLogger?.error(evt.message);
198
+ deviceLogger?.error(formatMsg(evt.message));
192
199
  break;
193
200
  case 'CRITICAL':
194
- deviceLogger?.error(evt.message);
201
+ deviceLogger?.error(formatMsg(evt.message));
195
202
  break;
196
203
  case 'OFF':
197
204
  default:
@@ -31,7 +31,7 @@ const isHotplugEvent = (
31
31
  export default async (
32
32
  traits: DeviceTraits,
33
33
  onEnumerated: (devices: NrfutilDevice[]) => void,
34
- onError: (error: Error) => void,
34
+ onError: (error: Error, pid?: number) => void,
35
35
  onHotplugEvent?: {
36
36
  onDeviceArrived: (device: NrfutilDevice) => void;
37
37
  onDeviceLeft: (id: number) => void;
@@ -4,7 +4,7 @@
4
4
  * SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
5
5
  */
6
6
 
7
- import packageJson from '../src/utils/packageJson';
7
+ import { packageJsonApp } from '../src/utils/packageJson';
8
8
  import {
9
9
  Dependency,
10
10
  isIncrementalVersion,
@@ -89,7 +89,7 @@ const overriddenVersion = (module: string) => {
89
89
  };
90
90
 
91
91
  const versionFromPackageJson = (module: string) =>
92
- packageJson().nrfConnectForDesktop.nrfutil?.[module][0];
92
+ packageJsonApp().nrfConnectForDesktop.nrfutil?.[module][0];
93
93
 
94
94
  const failToDetermineVersion = (module: string) => {
95
95
  throw new Error(`No version specified for nrfutil-${module}`);
@@ -10,6 +10,7 @@ import os from 'os';
10
10
  import path from 'path';
11
11
 
12
12
  import describeError from '../src/logging/describeError';
13
+ import usageData from '../src/utils/usageData';
13
14
  import { versionToInstall } from './moduleVersion';
14
15
  import { getNrfutilLogger } from './nrfutilLogger';
15
16
  import {
@@ -67,8 +68,9 @@ const commonParser = <Result>(
67
68
  onInfo?: (info: Result) => void;
68
69
  onTaskBegin?: (taskEnd: TaskBegin) => void;
69
70
  onTaskEnd?: (taskEnd: TaskEnd<Result>) => void;
70
- onLogging?: (logging: LogMessage) => void;
71
- }
71
+ onLogging?: (logging: LogMessage, pid?: number) => void;
72
+ },
73
+ pid?: number
72
74
  ): Buffer | undefined => {
73
75
  const parsedData: NrfutilJson<Result>[] | undefined =
74
76
  parseJsonBuffers(data);
@@ -95,7 +97,7 @@ const commonParser = <Result>(
95
97
  callbacks.onInfo?.(item.data);
96
98
  break;
97
99
  case 'log':
98
- callbacks.onLogging?.(item.data);
100
+ callbacks.onLogging?.(item.data, pid);
99
101
  break;
100
102
  case 'batch_update':
101
103
  processItem(item.data.data);
@@ -110,7 +112,7 @@ export class NrfutilSandbox {
110
112
  baseDir: string;
111
113
  module: string;
112
114
  version: string;
113
- onLoggingHandlers: ((logging: LogMessage) => void)[] = [];
115
+ onLoggingHandlers: ((logging: LogMessage, pid?: number) => void)[] = [];
114
116
  logLevel: LogLevel = 'info';
115
117
  env: ReturnType<typeof prepareEnv>;
116
118
 
@@ -122,9 +124,11 @@ export class NrfutilSandbox {
122
124
  this.env = prepareEnv(baseDir, module, version);
123
125
  }
124
126
 
125
- private processLoggingData = (data: NrfutilJson) => {
127
+ private processLoggingData = (data: NrfutilJson, pid?: number) => {
126
128
  if (data.type === 'log') {
127
- this.onLoggingHandlers.forEach(onLogging => onLogging(data.data));
129
+ this.onLoggingHandlers.forEach(onLogging =>
130
+ onLogging(data.data, pid)
131
+ );
128
132
  return true;
129
133
  }
130
134
 
@@ -200,28 +204,35 @@ export class NrfutilSandbox {
200
204
  const info: Result[] = [];
201
205
  const taskEnd: TaskEnd<Result>[] = [];
202
206
  let stdErr: string | undefined;
207
+ let pid: number | undefined;
208
+
203
209
  try {
204
210
  await this.execCommand(
205
211
  command,
206
212
  args,
207
- data =>
208
- commonParser<Result>(data, {
209
- onProgress,
210
- onTaskBegin,
211
- onTaskEnd: end => {
212
- taskEnd.push(end);
213
- onTaskEnd?.(end);
214
- },
215
- onInfo: i => {
216
- info.push(i);
213
+ (data, processId) =>
214
+ commonParser<Result>(
215
+ data,
216
+ {
217
+ onProgress,
218
+ onTaskBegin,
219
+ onTaskEnd: end => {
220
+ taskEnd.push(end);
221
+ onTaskEnd?.(end);
222
+ },
223
+ onInfo: i => {
224
+ info.push(i);
225
+ },
226
+ onLogging: logging => {
227
+ this.onLoggingHandlers.forEach(onLogging => {
228
+ onLogging(logging, processId);
229
+ });
230
+ },
217
231
  },
218
- onLogging: logging => {
219
- this.onLoggingHandlers.forEach(onLogging => {
220
- onLogging(logging);
221
- });
222
- },
223
- }),
224
- data => {
232
+ processId
233
+ ),
234
+ (data, processId) => {
235
+ pid = processId;
225
236
  stdErr = (stdErr ?? '') + data.toString();
226
237
  },
227
238
  controller
@@ -256,6 +267,11 @@ export class NrfutilSandbox {
256
267
  }
257
268
 
258
269
  error.message = error.message.replaceAll('Error: ', '');
270
+ usageData.sendErrorReport(
271
+ `${
272
+ pid && this.logLevel === 'trace' ? `[PID:${pid}] ` : ''
273
+ }${describeError(error)}`
274
+ );
259
275
  throw error;
260
276
  }
261
277
  };
@@ -280,12 +296,13 @@ export class NrfutilSandbox {
280
296
  private execCommand = (
281
297
  command: string,
282
298
  args: string[],
283
- parser: (data: Buffer) => Buffer | undefined,
284
- onStdError: (data: Buffer) => void,
299
+ parser: (data: Buffer, pid?: number) => Buffer | undefined,
300
+ onStdError: (data: Buffer, pid?: number) => void,
285
301
  controller?: AbortController
286
302
  ) =>
287
303
  new Promise<void>((resolve, reject) => {
288
304
  let aborting = false;
305
+ usageData.sendUsageData(`running nrfutil ${command}`, { args });
289
306
  const nrfutil = spawn(
290
307
  path.join(this.baseDir, 'nrfutil'),
291
308
  [
@@ -319,7 +336,7 @@ export class NrfutilSandbox {
319
336
  if (controller?.signal.aborted) return;
320
337
 
321
338
  buffer = Buffer.concat([buffer, data]);
322
- const remainingBytes = parser(buffer);
339
+ const remainingBytes = parser(buffer, nrfutil.pid);
323
340
  if (remainingBytes) {
324
341
  buffer = remainingBytes;
325
342
  } else {
@@ -328,7 +345,7 @@ export class NrfutilSandbox {
328
345
  });
329
346
 
330
347
  nrfutil.stderr.on('data', (data: Buffer) => {
331
- onStdError(data);
348
+ onStdError(data, nrfutil.pid);
332
349
  });
333
350
 
334
351
  nrfutil.on('close', code => {
@@ -364,7 +381,7 @@ export class NrfutilSandbox {
364
381
  const operation = this.execCommand(
365
382
  this.module,
366
383
  [command, ...args],
367
- data => {
384
+ (data, pid) => {
368
385
  const parsedData: NrfutilJson<Result>[] | undefined =
369
386
  parseJsonBuffers(data);
370
387
 
@@ -373,15 +390,15 @@ export class NrfutilSandbox {
373
390
  }
374
391
 
375
392
  parsedData.forEach(item => {
376
- if (!this.processLoggingData(item)) {
393
+ if (!this.processLoggingData(item, pid)) {
377
394
  if (item.type === 'info') {
378
395
  processors.onData(item.data);
379
396
  }
380
397
  }
381
398
  });
382
399
  },
383
- data => {
384
- processors.onError(new Error(data.toString()));
400
+ (data, pid) => {
401
+ processors.onError(new Error(data.toString()), pid);
385
402
  },
386
403
  controller
387
404
  );
@@ -392,6 +409,7 @@ export class NrfutilSandbox {
392
409
  closedHandlers.forEach(callback => callback());
393
410
  })
394
411
  .catch(error => {
412
+ usageData.sendErrorReport(describeError(error));
395
413
  running = false;
396
414
  closedHandlers.forEach(callback => callback(error));
397
415
  });
@@ -471,7 +489,9 @@ export class NrfutilSandbox {
471
489
  throw new Error('Unexpected result');
472
490
  };
473
491
 
474
- public onLogging = (handler: (logging: LogMessage) => void) => {
492
+ public onLogging = (
493
+ handler: (logging: LogMessage, pid?: number) => void
494
+ ) => {
475
495
  this.onLoggingHandlers.push(handler);
476
496
 
477
497
  return () =>
@@ -5,7 +5,7 @@
5
5
  */
6
6
 
7
7
  export interface BackgroundTask<T> {
8
- onError: (error: Error) => void;
8
+ onError: (error: Error, pid?: number) => void;
9
9
  onData: (data: T) => void;
10
10
  }
11
11
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nordicsemiconductor/pc-nrfconnect-shared",
3
- "version": "122.0.0",
3
+ "version": "123.0.0",
4
4
  "description": "Shared commodities for developing pc-nrfconnect-* packages",
5
5
  "repository": {
6
6
  "type": "git",
@@ -33,7 +33,7 @@
33
33
  "@mdi/font": "7.2.96",
34
34
  "@mdi/js": "^7.2.96",
35
35
  "@mdi/react": "^1.6.1",
36
- "@microsoft/applicationinsights-web": "^3.0.2",
36
+ "@microsoft/applicationinsights-web": "^3.0.4",
37
37
  "@reduxjs/toolkit": "1.9.3",
38
38
  "@svgr/core": "^7.0.0",
39
39
  "@svgr/plugin-jsx": "7.0.0",
@@ -57,6 +57,7 @@
57
57
  "@typescript-eslint/eslint-plugin": "5.57.1",
58
58
  "@typescript-eslint/parser": "5.57.1",
59
59
  "adm-zip": "^0.5.5",
60
+ "applicationinsights": "^2.9.0",
60
61
  "autoprefixer": "10.4.14",
61
62
  "bootstrap": "4.6.2",
62
63
  "commander": "10.0.0",
@@ -10,7 +10,7 @@ import { execSync } from 'child_process';
10
10
  import { existsSync, readdirSync, readFileSync } from 'fs';
11
11
  import property from 'lodash/property';
12
12
 
13
- import { PackageJson, parsePackageJson } from '../ipc/schema/packageJson';
13
+ import { PackageJsonApp, parsePackageJsonApp } from '../ipc/schema/packageJson';
14
14
 
15
15
  const format = (strings: string[]) =>
16
16
  strings.map(string => `\`${string}\``).join(', ');
@@ -61,7 +61,7 @@ const mustContainOneOf = (
61
61
  }
62
62
  };
63
63
 
64
- const checkRepoUrl = (packageJson: PackageJson) => {
64
+ const checkRepoUrl = (packageJson: PackageJsonApp) => {
65
65
  if (!existsSync('./.git')) {
66
66
  return;
67
67
  }
@@ -88,7 +88,7 @@ const checkRepoUrl = (packageJson: PackageJson) => {
88
88
  }
89
89
  };
90
90
 
91
- const checkOptionalProperties = (packageJson: PackageJson) => {
91
+ const checkOptionalProperties = (packageJson: PackageJsonApp) => {
92
92
  if (propertyIsMissing(packageJson)('homepage')) {
93
93
  warn('Please provide a property `homepage` in package.json.');
94
94
  }
@@ -100,7 +100,7 @@ const checkOptionalProperties = (packageJson: PackageJson) => {
100
100
  }
101
101
  };
102
102
 
103
- const checkFileProperty = (packageJson: PackageJson) => {
103
+ const checkFileProperty = (packageJson: PackageJsonApp) => {
104
104
  mustContain(
105
105
  packageJson.files ?? [],
106
106
  ['LICENSE', 'dist/', 'Changelog.md'],
@@ -115,7 +115,7 @@ const checkFileProperty = (packageJson: PackageJson) => {
115
115
  };
116
116
 
117
117
  const readAndCheckPackageJson = () => {
118
- const packageJsonResult = parsePackageJson(
118
+ const packageJsonResult = parsePackageJsonApp(
119
119
  readFileSync('./package.json', 'utf8')
120
120
  );
121
121
 
@@ -136,7 +136,7 @@ const changelogEntryRegexp = (version?: string) =>
136
136
  new RegExp(`^## ${version}`, 'mi');
137
137
 
138
138
  const checkChangelog = (
139
- packageJson: PackageJson,
139
+ packageJson: PackageJsonApp,
140
140
  checkChangelogHasCurrentEntry: boolean
141
141
  ) => {
142
142
  if (!existsSync('./Changelog.md')) {
@@ -8,11 +8,11 @@
8
8
  import * as fs from 'node:fs';
9
9
  import * as path from 'node:path';
10
10
 
11
- import { parsePackageJson } from '../ipc/schema/packageJson';
11
+ import { parsePackageJsonApp } from '../ipc/schema/packageJson';
12
12
  import { build } from './esbuild-renderer';
13
13
 
14
14
  const validate = (packageJson: string) => {
15
- const result = parsePackageJson(packageJson);
15
+ const result = parsePackageJsonApp(packageJson);
16
16
 
17
17
  if (!result.success) {
18
18
  console.log(result.error.message);
@@ -42,7 +42,7 @@ const bundle = () => {
42
42
 
43
43
  build({
44
44
  define: {
45
- 'process.env.PACKAGE_JSON_OF_APP': JSON.stringify(packageJson),
45
+ 'process.env.PACKAGE_JSON': JSON.stringify(packageJson),
46
46
  },
47
47
  entryPoints: [entry()],
48
48
  });