@nordicsemiconductor/pc-nrfconnect-shared 116.0.0 → 118.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 +23 -1
- package/coverage/cobertura-coverage.xml +108 -107
- package/ipc/MetaFiles.ts +15 -43
- package/ipc/device.ts +25 -0
- package/ipc/schema/packageJson.ts +69 -0
- package/ipc/schema/parseJson.ts +27 -0
- package/main/index.ts +14 -1
- package/nrfutil/device/program.ts +1 -0
- package/package.json +5 -3
- package/scripts/check-app-properties.ts +20 -52
- package/scripts/{esbuild-renderer.js → esbuild-renderer.ts} +42 -52
- package/scripts/esbuild.ts +79 -0
- package/scripts/nordic-publish.js +28 -26
- package/scripts/nordic-publish.ts +2 -1
- package/scripts/postinstall.ts +5 -5
- package/scripts/prepare-shared-release.ts +1 -1
- package/scripts/release-shared.ts +2 -2
- package/src/Device/deviceInfo/deviceInfo.ts +5 -19
- package/src/utils/appDirs.ts +1 -1
- package/src/utils/packageJson.ts +9 -5
- package/src/utils/usageData.ts +1 -2
- package/tsconfig.json +1 -0
- package/typings/generated/ipc/MetaFiles.d.ts +8 -40
- package/typings/generated/ipc/MetaFiles.d.ts.map +1 -1
- package/typings/generated/ipc/device.d.ts +3 -0
- package/typings/generated/ipc/device.d.ts.map +1 -0
- package/typings/generated/ipc/schema/packageJson.d.ts +267 -0
- package/typings/generated/ipc/schema/packageJson.d.ts.map +1 -0
- package/typings/generated/ipc/schema/parseJson.d.ts +6 -0
- package/typings/generated/ipc/schema/parseJson.d.ts.map +1 -0
- package/typings/generated/main/index.d.ts +2 -1
- package/typings/generated/main/index.d.ts.map +1 -1
- package/typings/generated/nrfutil/device/program.d.ts.map +1 -1
- package/typings/generated/nrfutil/sandbox.d.ts +8 -0
- package/typings/generated/nrfutil/sandbox.d.ts.map +1 -1
- package/typings/generated/scripts/check-app-properties.d.ts +6 -0
- package/typings/generated/scripts/check-app-properties.d.ts.map +1 -0
- package/typings/generated/scripts/check-for-typescript.d.ts +3 -0
- package/typings/generated/scripts/check-for-typescript.d.ts.map +1 -0
- package/typings/generated/scripts/esbuild-renderer.d.ts +7 -0
- package/typings/generated/scripts/esbuild-renderer.d.ts.map +1 -0
- package/typings/generated/scripts/esbuild.d.ts +3 -0
- package/typings/generated/scripts/esbuild.d.ts.map +1 -0
- package/typings/generated/scripts/installHusky.d.ts +3 -0
- package/typings/generated/scripts/installHusky.d.ts.map +1 -0
- package/typings/generated/scripts/nordic-publish.d.ts +3 -0
- package/typings/generated/scripts/nordic-publish.d.ts.map +1 -0
- package/typings/generated/scripts/nrfconnect-license.d.ts +3 -0
- package/typings/generated/scripts/nrfconnect-license.d.ts.map +1 -0
- package/typings/generated/scripts/postinstall.d.ts +3 -0
- package/typings/generated/scripts/postinstall.d.ts.map +1 -0
- package/typings/generated/scripts/prepare-shared-release.d.ts +3 -0
- package/typings/generated/scripts/prepare-shared-release.d.ts.map +1 -0
- package/typings/generated/scripts/release-shared.d.ts +30 -0
- package/typings/generated/scripts/release-shared.d.ts.map +1 -0
- package/typings/generated/scripts/release-shared.test.d.ts +2 -0
- package/typings/generated/scripts/release-shared.test.d.ts.map +1 -0
- package/typings/generated/src/Device/deviceInfo/deviceInfo.d.ts +0 -1
- package/typings/generated/src/Device/deviceInfo/deviceInfo.d.ts.map +1 -1
- package/typings/generated/src/utils/packageJson.d.ts +28 -2
- package/typings/generated/src/utils/packageJson.d.ts.map +1 -1
- package/typings/generated/src/utils/usageData.d.ts +8 -3
- package/typings/generated/src/utils/usageData.d.ts.map +1 -1
- package/scripts/esbuild.js +0 -53
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nordicsemiconductor/pc-nrfconnect-shared",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "118.0.0",
|
|
4
4
|
"description": "Shared commodities for developing pc-nrfconnect-* packages",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"check-for-typescript": "./scripts/check-for-typescript.ts",
|
|
13
13
|
"check-app-properties": "./scripts/check-app-properties.ts",
|
|
14
14
|
"nrfconnect-license": "./scripts/nrfconnect-license.ts",
|
|
15
|
-
"run-esbuild": "./scripts/esbuild.
|
|
15
|
+
"run-esbuild": "./scripts/esbuild.ts"
|
|
16
16
|
},
|
|
17
17
|
"main": "src",
|
|
18
18
|
"scripts": {
|
|
@@ -119,7 +119,9 @@
|
|
|
119
119
|
"util": "0.12.5",
|
|
120
120
|
"uuid": "8.3.2",
|
|
121
121
|
"winston": "3.8.2",
|
|
122
|
-
"xterm-headless": "^5.3.0"
|
|
122
|
+
"xterm-headless": "^5.3.0",
|
|
123
|
+
"zod": "^3.22.2",
|
|
124
|
+
"zod-validation-error": "^1.5.0"
|
|
123
125
|
},
|
|
124
126
|
"typings": "./typings/generated/src/index.d.ts",
|
|
125
127
|
"eslintConfig": {
|
|
@@ -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 } from '../ipc/
|
|
13
|
+
import { PackageJson, parsePackageJson } from '../ipc/schema/packageJson';
|
|
14
14
|
|
|
15
15
|
const format = (strings: string[]) =>
|
|
16
16
|
strings.map(string => `\`${string}\``).join(', ');
|
|
@@ -61,43 +61,6 @@ const mustContainOneOf = (
|
|
|
61
61
|
}
|
|
62
62
|
};
|
|
63
63
|
|
|
64
|
-
const checkMandatoryProperties = (packageJson: PackageJson) => {
|
|
65
|
-
const mandatoryProperties = [
|
|
66
|
-
`name`,
|
|
67
|
-
`version`,
|
|
68
|
-
`description`,
|
|
69
|
-
`displayName`,
|
|
70
|
-
`engines.nrfconnect`,
|
|
71
|
-
];
|
|
72
|
-
|
|
73
|
-
const missingProperties = mandatoryProperties.filter(
|
|
74
|
-
propertyIsMissing(packageJson)
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
mustBeEmpty(
|
|
78
|
-
missingProperties,
|
|
79
|
-
'package.json is missing these mandatory properties'
|
|
80
|
-
);
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
const checkNrfutilProperties = (packageJson: PackageJson) => {
|
|
84
|
-
const nrfutilModules = packageJson.nrfConnectForDesktop?.nrfutil;
|
|
85
|
-
if (nrfutilModules != null) {
|
|
86
|
-
Object.entries(nrfutilModules).forEach(
|
|
87
|
-
([moduleName, moduleVersions]) => {
|
|
88
|
-
if (
|
|
89
|
-
!Array.isArray(moduleVersions) ||
|
|
90
|
-
moduleVersions.length === 0
|
|
91
|
-
) {
|
|
92
|
-
fail(
|
|
93
|
-
`For each module in \`nrfConnectForDesktop.nrfutil\` in package.json at least one version must be specified, but for \`${moduleName}\` none was specified.`
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
);
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
|
|
101
64
|
const checkRepoUrl = (packageJson: PackageJson) => {
|
|
102
65
|
if (!existsSync('./.git')) {
|
|
103
66
|
return;
|
|
@@ -130,14 +93,6 @@ const checkOptionalProperties = (packageJson: PackageJson) => {
|
|
|
130
93
|
warn('Please provide a property `homepage` in package.json.');
|
|
131
94
|
}
|
|
132
95
|
|
|
133
|
-
if (propertyIsMissing(packageJson)('nrfConnectForDesktop')) {
|
|
134
|
-
warn(
|
|
135
|
-
'Please provide a property `nrfConnectForDesktop.html` in package.json'
|
|
136
|
-
);
|
|
137
|
-
} else {
|
|
138
|
-
checkNrfutilProperties(packageJson);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
96
|
if (propertyIsMissing(packageJson)('repository.url')) {
|
|
142
97
|
warn('Please provide a property `repository.url` in package.json.');
|
|
143
98
|
} else {
|
|
@@ -159,6 +114,24 @@ const checkFileProperty = (packageJson: PackageJson) => {
|
|
|
159
114
|
);
|
|
160
115
|
};
|
|
161
116
|
|
|
117
|
+
const readAndCheckPackageJson = () => {
|
|
118
|
+
const packageJsonResult = parsePackageJson(
|
|
119
|
+
readFileSync('./package.json', 'utf8')
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
if (!packageJsonResult.success) {
|
|
123
|
+
console.error(packageJsonResult.error.message);
|
|
124
|
+
process.exit(1);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const packageJson = packageJsonResult.data;
|
|
128
|
+
|
|
129
|
+
checkOptionalProperties(packageJson);
|
|
130
|
+
checkFileProperty(packageJson);
|
|
131
|
+
|
|
132
|
+
return packageJson;
|
|
133
|
+
};
|
|
134
|
+
|
|
162
135
|
const changelogEntryRegexp = (version?: string) =>
|
|
163
136
|
new RegExp(`^## ${version}`, 'mi');
|
|
164
137
|
|
|
@@ -211,13 +184,8 @@ const runChecks = ({
|
|
|
211
184
|
}: {
|
|
212
185
|
checkChangelogHasCurrentEntry: boolean;
|
|
213
186
|
}) => {
|
|
214
|
-
const packageJson =
|
|
215
|
-
JSON.parse(readFileSync('./package.json', 'utf8'))
|
|
216
|
-
);
|
|
187
|
+
const packageJson = readAndCheckPackageJson();
|
|
217
188
|
|
|
218
|
-
checkMandatoryProperties(packageJson);
|
|
219
|
-
checkOptionalProperties(packageJson);
|
|
220
|
-
checkFileProperty(packageJson);
|
|
221
189
|
checkChangelog(packageJson, checkChangelogHasCurrentEntry);
|
|
222
190
|
checkMandatoryResources();
|
|
223
191
|
};
|
|
@@ -4,21 +4,18 @@
|
|
|
4
4
|
* SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
import { transform as svgr } from '@svgr/core';
|
|
8
|
+
import autoprefixer from 'autoprefixer';
|
|
9
|
+
import esbuild, { BuildOptions } from 'esbuild';
|
|
10
|
+
import { postcssModules, sassPlugin } from 'esbuild-sass-plugin';
|
|
11
|
+
import postCssPlugin from 'esbuild-style-plugin';
|
|
12
|
+
import * as fs from 'node:fs';
|
|
13
|
+
import * as module from 'node:module';
|
|
14
|
+
import * as path from 'node:path';
|
|
15
|
+
import tailwindcss from 'tailwindcss';
|
|
16
|
+
|
|
17
|
+
const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8'));
|
|
17
18
|
|
|
18
|
-
const packageJsonOfApp = fs.readFileSync(
|
|
19
|
-
path.join(process.cwd(), 'package.json'),
|
|
20
|
-
'utf8'
|
|
21
|
-
);
|
|
22
19
|
const projectSpecificTailwindConfigPath = path.join(
|
|
23
20
|
process.cwd(),
|
|
24
21
|
'tailwind.config.js'
|
|
@@ -30,26 +27,21 @@ const tailwindConfig = () =>
|
|
|
30
27
|
'@nordicsemiconductor/pc-nrfconnect-shared/config/tailwind.config.js'
|
|
31
28
|
);
|
|
32
29
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
fs.readFileSync('package.json', 'utf8')
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
const outfile =
|
|
39
|
-
additionalOptions.entryPoints.length === 1
|
|
40
|
-
? './dist/bundle.js'
|
|
41
|
-
: undefined;
|
|
42
|
-
const outdir = outfile ? undefined : './dist';
|
|
30
|
+
type AdditionalOptions = Required<Pick<BuildOptions, 'entryPoints'>> &
|
|
31
|
+
Partial<BuildOptions>;
|
|
43
32
|
|
|
44
|
-
|
|
33
|
+
const outfileOrDir = (additionalOptions: AdditionalOptions) =>
|
|
34
|
+
additionalOptions.entryPoints.length === 1
|
|
35
|
+
? { outfile: './dist/bundle.js' }
|
|
36
|
+
: { outdir: './dist' };
|
|
45
37
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
38
|
+
const options = (
|
|
39
|
+
additionalOptions: AdditionalOptions,
|
|
40
|
+
externalReact: boolean
|
|
41
|
+
) =>
|
|
42
|
+
({
|
|
43
|
+
format: 'iife',
|
|
44
|
+
...outfileOrDir(additionalOptions),
|
|
53
45
|
target: 'chrome89',
|
|
54
46
|
sourcemap: true,
|
|
55
47
|
metafile: false,
|
|
@@ -57,16 +49,16 @@ function options(additionalOptions) {
|
|
|
57
49
|
bundle: true,
|
|
58
50
|
logLevel: 'info',
|
|
59
51
|
external: [
|
|
60
|
-
...builtinModules,
|
|
52
|
+
...module.builtinModules,
|
|
61
53
|
|
|
62
54
|
// launcher includes
|
|
63
55
|
'electron',
|
|
64
56
|
'serialport',
|
|
65
57
|
'@electron/remote',
|
|
66
|
-
...(
|
|
58
|
+
...(externalReact ? ['react', 'react-dom'] : []),
|
|
67
59
|
|
|
68
60
|
// App dependencies
|
|
69
|
-
...Object.keys(dependencies ?? {}),
|
|
61
|
+
...Object.keys(packageJson.dependencies ?? {}),
|
|
70
62
|
],
|
|
71
63
|
loader: {
|
|
72
64
|
'.json': 'json',
|
|
@@ -103,8 +95,8 @@ function options(additionalOptions) {
|
|
|
103
95
|
|
|
104
96
|
builder.onResolve({ filter }, args => {
|
|
105
97
|
// Rename file to .svgr to let this plugin handle it.
|
|
106
|
-
const [, shortpath] = filter.exec(args.path)
|
|
107
|
-
const resolvedPath = `${join(
|
|
98
|
+
const [, shortpath] = filter.exec(args.path)!; // eslint-disable-line @typescript-eslint/no-non-null-assertion
|
|
99
|
+
const resolvedPath = `${path.join(
|
|
108
100
|
args.resolveDir,
|
|
109
101
|
shortpath
|
|
110
102
|
)}r`;
|
|
@@ -118,7 +110,7 @@ function options(additionalOptions) {
|
|
|
118
110
|
'utf8'
|
|
119
111
|
);
|
|
120
112
|
const plugins = ['@svgr/plugin-jsx'];
|
|
121
|
-
const contents = await svgr(svg, {
|
|
113
|
+
const contents = await svgr(svg, { plugins });
|
|
122
114
|
return {
|
|
123
115
|
contents,
|
|
124
116
|
loader: 'jsx',
|
|
@@ -128,22 +120,20 @@ function options(additionalOptions) {
|
|
|
128
120
|
},
|
|
129
121
|
],
|
|
130
122
|
...additionalOptions,
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
const build = additionalOptions => esbuild.build(options(additionalOptions));
|
|
123
|
+
} satisfies BuildOptions);
|
|
135
124
|
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
await context.watch();
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
module.exports.build = additionalOptions => {
|
|
125
|
+
export const build = async (
|
|
126
|
+
additionalOptions: AdditionalOptions,
|
|
127
|
+
{ externalReact = false } = {}
|
|
128
|
+
) => {
|
|
144
129
|
if (process.argv.includes('--watch')) {
|
|
145
|
-
|
|
130
|
+
const context = await esbuild.context(
|
|
131
|
+
options(additionalOptions, externalReact)
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
await context.rebuild();
|
|
135
|
+
await context.watch();
|
|
146
136
|
} else {
|
|
147
|
-
build(additionalOptions);
|
|
137
|
+
esbuild.build(options(additionalOptions, externalReact));
|
|
148
138
|
}
|
|
149
139
|
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
#!/usr/bin/env ts-node
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2015 Nordic Semiconductor ASA
|
|
4
|
+
*
|
|
5
|
+
* SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import * as fs from 'node:fs';
|
|
9
|
+
import * as path from 'node:path';
|
|
10
|
+
|
|
11
|
+
import { parsePackageJson } from '../ipc/schema/packageJson';
|
|
12
|
+
import { build } from './esbuild-renderer';
|
|
13
|
+
|
|
14
|
+
const validate = (packageJson: string) => {
|
|
15
|
+
const result = parsePackageJson(packageJson);
|
|
16
|
+
|
|
17
|
+
if (!result.success) {
|
|
18
|
+
console.log(result.error.message);
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const entry = () => {
|
|
24
|
+
const result = [
|
|
25
|
+
'./src/index.jsx',
|
|
26
|
+
'./lib/index.jsx',
|
|
27
|
+
'./index.jsx',
|
|
28
|
+
'./src/index.tsx',
|
|
29
|
+
].find(fs.existsSync);
|
|
30
|
+
|
|
31
|
+
if (result == null) {
|
|
32
|
+
throw new Error('Found no entry point file');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const bundle = () => {
|
|
39
|
+
const packageJson = fs.readFileSync('package.json', 'utf8');
|
|
40
|
+
|
|
41
|
+
validate(packageJson);
|
|
42
|
+
|
|
43
|
+
build({
|
|
44
|
+
define: {
|
|
45
|
+
'process.env.PACKAGE_JSON_OF_APP': JSON.stringify(packageJson),
|
|
46
|
+
},
|
|
47
|
+
entryPoints: [entry()],
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const fileInShared = (file: string) =>
|
|
52
|
+
require.resolve(`@nordicsemiconductor/pc-nrfconnect-shared/${file}`);
|
|
53
|
+
|
|
54
|
+
const fileInDist = (file: string) => path.join('dist', path.basename(file));
|
|
55
|
+
|
|
56
|
+
const copyFileToDist = (file: string) =>
|
|
57
|
+
fs.copyFileSync(fileInShared(file), fileInDist(file));
|
|
58
|
+
|
|
59
|
+
const copyFiles = () => {
|
|
60
|
+
fs.mkdirSync('dist', { recursive: true });
|
|
61
|
+
|
|
62
|
+
copyFileToDist('scripts/nordic-publish.js');
|
|
63
|
+
copyFileToDist('dist/bootstrap.css');
|
|
64
|
+
copyFileToDist('src/index.html');
|
|
65
|
+
|
|
66
|
+
if (process.argv.includes('--include-bootloader')) {
|
|
67
|
+
fs.mkdirSync('fw', { recursive: true });
|
|
68
|
+
|
|
69
|
+
fs.copyFileSync(
|
|
70
|
+
fileInShared(
|
|
71
|
+
'fw/bootloader/graviton_bootloader_v1.0.1-[nRF5_SDK_15.0.1-1.alpha_f76d012].zip'
|
|
72
|
+
),
|
|
73
|
+
'./fw/graviton_bootloader_v1.0.1-[nRF5_SDK_15.0.1-1.alpha_f76d012].zip'
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
bundle();
|
|
79
|
+
copyFiles();
|