@kvaser/canking-api 7.1.0-beta.231 → 7.1.0-beta.241
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/README.md +101 -37
- package/dist/controls/CanIdentifierControl.d.ts +21 -3
- package/dist/controls/ColumnItemControl.d.ts +36 -0
- package/dist/controls/OneLineButton.d.ts +1 -1
- package/dist/controls/index.d.ts +2 -0
- package/dist/controls.js +1 -1
- package/dist/controls.mjs +1385 -1141
- package/dist/grpc.mjs +114 -114
- package/dist/index.js +1 -1
- package/dist/measurement_settings.js +1 -1
- package/dist/measurement_settings.mjs +449 -403
- package/dist/models.js +1 -1
- package/dist/models.mjs +30 -30
- package/dist/protos/app_service.d.ts +1 -1
- package/dist/protos/device_service.d.ts +1 -1
- package/dist/protos/frame_params.d.ts +6 -0
- package/dist/protos/measurement_service.d.ts +1 -1
- package/dist/status_params.js +1 -1
- package/dist/status_params.mjs +1780 -1780
- package/doc/assets/material-style.css +105 -14
- package/doc/assets/navigation.js +1 -1
- package/doc/assets/search.js +1 -1
- package/doc/functions/controls.ColumnItemControl.html +175 -0
- package/doc/functions/controls.OneLineButton.html +4 -4
- package/doc/functions/controls.useColumnItem.html +176 -0
- package/doc/functions/controls.useColumnItems.html +177 -0
- package/doc/index.html +87 -43
- package/doc/interfaces/controls.CanIdentifierFrameControlProps.html +4 -2
- package/doc/interfaces/controls.CanIdentifierGeneratorControlProps.html +6 -2
- package/doc/interfaces/controls.CanIdentifierGeneratorSettingsControlProps.html +6 -2
- package/doc/interfaces/controls.ColumnItemControlProps.html +177 -0
- package/doc/interfaces/models.SignalValue.html +4 -2
- package/doc/interfaces/models.WriteFrame.html +6 -2
- package/doc/modules/controls.html +4 -0
- package/index.js +14 -0
- package/licenses/ELECTRON-TOOLKIT-PRELOAD_MIT.TXT +21 -0
- package/licenses/FAST-DEEP-EQUAL_MIT.TXT +21 -0
- package/licenses/GOOGLE-PROTOBUF_(BSD-3-CLAUSE AND APACHE-2.0).TXT +29 -0
- package/licenses/REACT-DOM_MIT.TXT +21 -0
- package/licenses/REACT_MIT.TXT +21 -0
- package/licenses/UUID_MIT.TXT +9 -0
- package/licenses/licenses.css +22 -0
- package/licenses/licenses.html +67 -0
- package/package.json +10 -16
- package/scripts/createCanKingExtension.js +0 -403
- package/scripts/index.js +0 -39
- package/scripts/template/_.eslintrc.cjs +0 -38
- package/scripts/template/_.gitignore +0 -24
- package/scripts/template/_.npmrc +0 -2
- package/scripts/template/_.prettierrc +0 -8
- package/scripts/template/_.vscode/_launch.json +0 -28
- package/scripts/template/_index.html +0 -15
- package/scripts/template/_tsconfig.app.json +0 -27
- package/scripts/template/_tsconfig.json +0 -11
- package/scripts/template/_tsconfig.node.json +0 -13
- package/scripts/template/_vite.config.ts +0 -7
- package/scripts/template/src/App.tsx +0 -12
- package/scripts/template/src/WorkspaceView/index.tsx +0 -47
- package/scripts/template/src/main.css +0 -9
- package/scripts/template/src/main.tsx +0 -19
- package/scripts/template/src/vite-env.d.ts +0 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
table {
|
|
2
|
+
border-collapse: collapse;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
table, th, td {
|
|
6
|
+
border: 1px solid navy;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
th {
|
|
10
|
+
text-align: left;
|
|
11
|
+
background-color: #BCC6CC;
|
|
12
|
+
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
th, td {
|
|
16
|
+
padding: 2px;
|
|
17
|
+
text-align: left;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
tr:nth-child(even) {
|
|
21
|
+
background-color: #f2f2f2;
|
|
22
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
<html>
|
|
2
|
+
<head>
|
|
3
|
+
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
|
|
4
|
+
<link rel="stylesheet" type="text/css" href="licenses.css">
|
|
5
|
+
</head>
|
|
6
|
+
<body>
|
|
7
|
+
<h2>@kvaser/canking-api</h2>
|
|
8
|
+
<table>
|
|
9
|
+
<tr>
|
|
10
|
+
<th>Package Group</th>
|
|
11
|
+
<th>Package Artifact</th>
|
|
12
|
+
<th>Package Version</th>
|
|
13
|
+
<th>Remote Licenses</th>
|
|
14
|
+
<th>Local Licenses</th>
|
|
15
|
+
</tr>
|
|
16
|
+
<tr>
|
|
17
|
+
<td>N/A</td>
|
|
18
|
+
<td>@electron-toolkit/preload</td>
|
|
19
|
+
<td>3.0.1</td>
|
|
20
|
+
<td>http://www.opensource.org/licenses/MIT</td>
|
|
21
|
+
<td><a href=ELECTRON-TOOLKIT-PRELOAD_MIT.TXT>ELECTRON-TOOLKIT-PRELOAD_MIT.TXT</a></td>
|
|
22
|
+
</tr>
|
|
23
|
+
<tr>
|
|
24
|
+
<td>N/A</td>
|
|
25
|
+
<td>fast-deep-equal</td>
|
|
26
|
+
<td>3.1.3</td>
|
|
27
|
+
<td>http://www.opensource.org/licenses/MIT</td>
|
|
28
|
+
<td><a href=FAST-DEEP-EQUAL_MIT.TXT>FAST-DEEP-EQUAL_MIT.TXT</a></td>
|
|
29
|
+
</tr>
|
|
30
|
+
<tr>
|
|
31
|
+
<td>N/A</td>
|
|
32
|
+
<td>google-protobuf</td>
|
|
33
|
+
<td>3.21.4</td>
|
|
34
|
+
<td>http://www.opensource.org/licenses/BSD-3-Clause</td>
|
|
35
|
+
<td><a href=GOOGLE-PROTOBUF_(BSD-3-CLAUSE%20AND%20APACHE-2.0).TXT>GOOGLE-PROTOBUF_(BSD-3-CLAUSE AND APACHE-2.0).TXT</a></td>
|
|
36
|
+
</tr>
|
|
37
|
+
<tr>
|
|
38
|
+
<td>N/A</td>
|
|
39
|
+
<td>google-protobuf</td>
|
|
40
|
+
<td>3.21.4</td>
|
|
41
|
+
<td>http://www.apache.org/licenses/LICENSE-2.0</td>
|
|
42
|
+
<td><a href=GOOGLE-PROTOBUF_(BSD-3-CLAUSE%20AND%20APACHE-2.0).TXT>GOOGLE-PROTOBUF_(BSD-3-CLAUSE AND APACHE-2.0).TXT</a></td>
|
|
43
|
+
</tr>
|
|
44
|
+
<tr>
|
|
45
|
+
<td>N/A</td>
|
|
46
|
+
<td>react</td>
|
|
47
|
+
<td>18.3.1</td>
|
|
48
|
+
<td>http://www.opensource.org/licenses/MIT</td>
|
|
49
|
+
<td><a href=REACT_MIT.TXT>REACT_MIT.TXT</a></td>
|
|
50
|
+
</tr>
|
|
51
|
+
<tr>
|
|
52
|
+
<td>N/A</td>
|
|
53
|
+
<td>react-dom</td>
|
|
54
|
+
<td>18.3.1</td>
|
|
55
|
+
<td>http://www.opensource.org/licenses/MIT</td>
|
|
56
|
+
<td><a href=REACT-DOM_MIT.TXT>REACT-DOM_MIT.TXT</a></td>
|
|
57
|
+
</tr>
|
|
58
|
+
<tr>
|
|
59
|
+
<td>N/A</td>
|
|
60
|
+
<td>uuid</td>
|
|
61
|
+
<td>10.0.0</td>
|
|
62
|
+
<td>http://www.opensource.org/licenses/MIT</td>
|
|
63
|
+
<td><a href=UUID_MIT.TXT>UUID_MIT.TXT</a></td>
|
|
64
|
+
</tr>
|
|
65
|
+
</table>
|
|
66
|
+
</body>
|
|
67
|
+
</html>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kvaser/canking-api",
|
|
3
|
-
"version": "7.1.0-beta.
|
|
3
|
+
"version": "7.1.0-beta.241",
|
|
4
4
|
"description": "CanKing API to communicate with the CanKing service using Node.js.",
|
|
5
5
|
"author": "Kvaser AB",
|
|
6
6
|
"license": "SEE LICENSE IN EULA.pdf",
|
|
@@ -45,17 +45,17 @@
|
|
|
45
45
|
"types": "./dist/grpc/index.d.ts"
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
|
+
"bin": {
|
|
49
|
+
"create-extension": "index.js"
|
|
50
|
+
},
|
|
48
51
|
"files": [
|
|
49
52
|
"dist",
|
|
50
53
|
"doc",
|
|
51
|
-
"scripts",
|
|
52
54
|
"licenses",
|
|
53
55
|
"EULA.pdf",
|
|
54
|
-
"REDISTRIBUTABLES.txt"
|
|
56
|
+
"REDISTRIBUTABLES.txt",
|
|
57
|
+
"index.js"
|
|
55
58
|
],
|
|
56
|
-
"bin": {
|
|
57
|
-
"create-extension": "scripts/index.js"
|
|
58
|
-
},
|
|
59
59
|
"scripts": {
|
|
60
60
|
"build": "tsc -b && vite build && npm run build:types && npm run build:doc",
|
|
61
61
|
"build:types": "tsc src/index.ts src/models/index.ts src/controls/index.ts src/ipc/index.ts src/hooks/index.ts src/icons/index.tsx src/grpc/index.ts --target es2020 --module esnext --moduleResolution bundler --jsx react-jsx --declaration --emitDeclarationOnly --declarationDir dist/",
|
|
@@ -63,32 +63,25 @@
|
|
|
63
63
|
"build:doc": "typedoc",
|
|
64
64
|
"prebuild:protos": "rimraf ./src/protos && npx mkdirp ./src/protos",
|
|
65
65
|
"prebuild": "rimraf ./dist && npm run build:protos",
|
|
66
|
+
"prepublishOnly": "npx license-reporter report --only=prod",
|
|
66
67
|
"lint": "cross-env NODE_ENV=development eslint . --ext .js,.jsx,.ts,.tsx",
|
|
67
68
|
"package": "npm pack --pack-destination=./out",
|
|
68
|
-
"prepackage": "rimraf ./out && npx mkdirp ./out && npm run build
|
|
69
|
+
"prepackage": "rimraf ./out && npx mkdirp ./out && npm run build"
|
|
69
70
|
},
|
|
70
71
|
"dependencies": {
|
|
71
|
-
"@commander-js/extra-typings": "^12.1.0",
|
|
72
72
|
"@electron-toolkit/preload": "^3.0.1",
|
|
73
73
|
"@emotion/react": "^11.13.3",
|
|
74
74
|
"@emotion/styled": "^11.13.0",
|
|
75
75
|
"@fontsource/roboto": "^5.1.0",
|
|
76
76
|
"@grpc/grpc-js": "^1.12.2",
|
|
77
77
|
"@mui/material": "^6.1.3",
|
|
78
|
-
"chalk": "^4.1.2",
|
|
79
|
-
"commander": "^12.1.0",
|
|
80
|
-
"cross-spawn": "^7.0.3",
|
|
81
78
|
"electron": "^33.0.0",
|
|
82
79
|
"fast-deep-equal": "^3.1.3",
|
|
83
|
-
"fs-extra": "^11.2.0",
|
|
84
80
|
"google-protobuf": "^3.21.4",
|
|
85
81
|
"long": "^5.2.3",
|
|
86
|
-
"open": "^10.1.0",
|
|
87
82
|
"react": "^18.3.1",
|
|
88
83
|
"react-dom": "^18.3.1",
|
|
89
|
-
"
|
|
90
|
-
"uuid": "^10.0.0",
|
|
91
|
-
"validate-npm-package-name": "^6.0.0"
|
|
84
|
+
"uuid": "^10.0.0"
|
|
92
85
|
},
|
|
93
86
|
"devDependencies": {
|
|
94
87
|
"@types/google-protobuf": "^3.15.12",
|
|
@@ -111,6 +104,7 @@
|
|
|
111
104
|
"prettier": "^3.3.3",
|
|
112
105
|
"prop-types": "^15.8.1",
|
|
113
106
|
"protolint": "^0.50.5",
|
|
107
|
+
"react-resize-detector": "^11.0.1",
|
|
114
108
|
"rimraf": "^6.0.1",
|
|
115
109
|
"ts-proto": "^2.2.3",
|
|
116
110
|
"typedoc": "^0.26.7",
|
|
@@ -1,403 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const https = require('https');
|
|
4
|
-
const chalk = require('chalk');
|
|
5
|
-
const commander = require('@commander-js/extra-typings');
|
|
6
|
-
const execSync = require('child_process').execSync;
|
|
7
|
-
const fs = require('fs-extra');
|
|
8
|
-
const os = require('os');
|
|
9
|
-
const path = require('path');
|
|
10
|
-
const semver = require('semver');
|
|
11
|
-
const spawn = require('cross-spawn');
|
|
12
|
-
const validateProjectName = require('validate-npm-package-name');
|
|
13
|
-
|
|
14
|
-
const packageJson = require('../package.json');
|
|
15
|
-
|
|
16
|
-
const kvaserRegistry = 'http://artifact.kvaser.se/artifactory/api/npm/libs-npm';
|
|
17
|
-
|
|
18
|
-
function init() {
|
|
19
|
-
let projectName;
|
|
20
|
-
|
|
21
|
-
const program = new commander.Command(`npx ${packageJson.name}`)
|
|
22
|
-
.description('Script for creating a new CanKing extension project')
|
|
23
|
-
.version(packageJson.version)
|
|
24
|
-
.argument(
|
|
25
|
-
'<project-name>',
|
|
26
|
-
'The project name. A new project folder with this name will be created in the current folder.',
|
|
27
|
-
)
|
|
28
|
-
.action(name => (projectName = name))
|
|
29
|
-
.usage(`${chalk.green('<project-name>')} [options]`)
|
|
30
|
-
.option('--view-name <string>', 'workspace view name', '')
|
|
31
|
-
.option('--desc <string>', 'project description', 'A CanKing GUI extension.')
|
|
32
|
-
.option('--author <string>', 'project author', '')
|
|
33
|
-
.option('--verbose', 'print additional logs')
|
|
34
|
-
.option('--force', 'use installed script even if a newer version exists')
|
|
35
|
-
.option('--show-doc', 'opens the documentation')
|
|
36
|
-
.allowUnknownOption()
|
|
37
|
-
.showHelpAfterError()
|
|
38
|
-
.parse(process.argv);
|
|
39
|
-
|
|
40
|
-
const options = program.opts();
|
|
41
|
-
|
|
42
|
-
if (options.viewName === '') {
|
|
43
|
-
options.viewName = projectName
|
|
44
|
-
.split('-')
|
|
45
|
-
.map(n => n.charAt(0).toUpperCase() + n.slice(1))
|
|
46
|
-
.join('');
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// Set correct register for @kvaser scope
|
|
50
|
-
try {
|
|
51
|
-
execSync(`npm config set @kvaser:registry ${kvaserRegistry}`);
|
|
52
|
-
} catch {}
|
|
53
|
-
|
|
54
|
-
// We first check the registry directly via the API, and if that fails, we try
|
|
55
|
-
// the slower `npm view [package] version` command.
|
|
56
|
-
//
|
|
57
|
-
// This is important for users in environments where direct access to npm is
|
|
58
|
-
// blocked by a firewall, and packages are provided exclusively via a private
|
|
59
|
-
// registry.
|
|
60
|
-
checkForLatestVersion()
|
|
61
|
-
.catch(() => {
|
|
62
|
-
try {
|
|
63
|
-
return execSync('npm view @kvaser/create-canking-extension version').toString().trim();
|
|
64
|
-
} catch (e) {
|
|
65
|
-
return null;
|
|
66
|
-
}
|
|
67
|
-
})
|
|
68
|
-
.then(latest => {
|
|
69
|
-
if (!options.force && latest && semver.lt(packageJson.version, latest)) {
|
|
70
|
-
console.log();
|
|
71
|
-
console.error(
|
|
72
|
-
chalk.yellow(
|
|
73
|
-
`You are running \`create-canking-extension\` ${packageJson.version}, which is behind the latest release (${latest}).\n\n` +
|
|
74
|
-
'We recommend always using the latest version of create-canking-extension if possible.\n\n' +
|
|
75
|
-
'Use --force option to override if you want to use the old version.',
|
|
76
|
-
),
|
|
77
|
-
);
|
|
78
|
-
console.log();
|
|
79
|
-
} else {
|
|
80
|
-
try {
|
|
81
|
-
createExtension(projectName, options.viewName, options.desc, options.author, options.verbose);
|
|
82
|
-
} catch (e) {
|
|
83
|
-
console.error(chalk.red(e));
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function createExtension(name, viewName, description, author, verbose) {
|
|
90
|
-
const root = path.resolve(name);
|
|
91
|
-
const extensionName = path.basename(root);
|
|
92
|
-
|
|
93
|
-
checkExtensionName(extensionName);
|
|
94
|
-
fs.ensureDirSync(name);
|
|
95
|
-
if (!isSafeToCreateProjectIn(root, name)) {
|
|
96
|
-
process.exit(1);
|
|
97
|
-
}
|
|
98
|
-
console.log();
|
|
99
|
-
|
|
100
|
-
console.log(`Creating a new CanKing extension in ${chalk.green(root)}.`);
|
|
101
|
-
console.log();
|
|
102
|
-
|
|
103
|
-
const packageJson = {
|
|
104
|
-
name: extensionName,
|
|
105
|
-
version: '1.0.0',
|
|
106
|
-
description: description,
|
|
107
|
-
author: author,
|
|
108
|
-
canking: {
|
|
109
|
-
workspaceViewName: viewName,
|
|
110
|
-
types: ['WorkspaceView'],
|
|
111
|
-
},
|
|
112
|
-
private: true,
|
|
113
|
-
license: 'UNLICENSED',
|
|
114
|
-
type: 'module',
|
|
115
|
-
files: ['dist'],
|
|
116
|
-
scripts: {
|
|
117
|
-
start: 'npm-run-all --parallel dev canking',
|
|
118
|
-
startpreview: 'npm-run-all --parallel preview canking',
|
|
119
|
-
dev: 'vite --port 4000',
|
|
120
|
-
canking:
|
|
121
|
-
'cross-env "C:/Program Files/Kvaser CanKing/Kvaser CanKing.exe" --ck-debug-pkg "./package.json" --ck-debug-port 4000',
|
|
122
|
-
build: 'tsc -b && vite build',
|
|
123
|
-
lint: 'eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0',
|
|
124
|
-
prettier: 'prettier --config .prettierrc **/*.ts* --write',
|
|
125
|
-
preview: 'vite preview --port 4000',
|
|
126
|
-
prepack: 'npm run build',
|
|
127
|
-
prebuild: 'rimraf dist',
|
|
128
|
-
},
|
|
129
|
-
};
|
|
130
|
-
fs.writeFileSync(path.join(root, 'package.json'), JSON.stringify(packageJson, null, 2) + os.EOL);
|
|
131
|
-
|
|
132
|
-
process.chdir(root);
|
|
133
|
-
|
|
134
|
-
// Copy templates
|
|
135
|
-
fs.copySync(path.join(__dirname, 'template', '_.vscode', '_launch.json'), path.join(root, '.vscode', 'launch.json'));
|
|
136
|
-
fs.copySync(
|
|
137
|
-
path.join(__dirname, 'template', 'src', 'WorkspaceView', 'index.tsx'),
|
|
138
|
-
path.join(root, 'src', 'WorkspaceView', 'index.tsx'),
|
|
139
|
-
);
|
|
140
|
-
fs.copySync(path.join(__dirname, 'template', 'src', 'App.tsx'), path.join(root, 'src', 'App.tsx'));
|
|
141
|
-
fs.copySync(path.join(__dirname, 'template', 'src', 'main.css'), path.join(root, 'src', 'main.css'));
|
|
142
|
-
fs.copySync(path.join(__dirname, 'template', 'src', 'main.tsx'), path.join(root, 'src', 'main.tsx'));
|
|
143
|
-
fs.copySync(path.join(__dirname, 'template', 'src', 'vite-env.d.ts'), path.join(root, 'src', 'vite-env.d.ts'));
|
|
144
|
-
fs.copySync(path.join(__dirname, 'template', '_.eslintrc.cjs'), path.join(root, '.eslintrc.cjs'));
|
|
145
|
-
fs.copySync(path.join(__dirname, 'template', '_.gitignore'), path.join(root, '.gitignore'));
|
|
146
|
-
fs.copySync(path.join(__dirname, 'template', '_.npmrc'), path.join(root, '.npmrc'));
|
|
147
|
-
fs.copySync(path.join(__dirname, 'template', '_.prettierrc'), path.join(root, '.prettierrc'));
|
|
148
|
-
fs.copySync(path.join(__dirname, 'template', '_index.html'), path.join(root, 'index.html'));
|
|
149
|
-
fs.copySync(path.join(__dirname, 'template', '_tsconfig.app.json'), path.join(root, 'tsconfig.app.json'));
|
|
150
|
-
fs.copySync(path.join(__dirname, 'template', '_tsconfig.json'), path.join(root, 'tsconfig.json'));
|
|
151
|
-
fs.copySync(path.join(__dirname, 'template', '_tsconfig.node.json'), path.join(root, 'tsconfig.node.json'));
|
|
152
|
-
fs.copySync(path.join(__dirname, 'template', '_vite.config.ts'), path.join(root, 'vite.config.ts'));
|
|
153
|
-
|
|
154
|
-
installDependencies(verbose)
|
|
155
|
-
.then(() => {
|
|
156
|
-
console.log();
|
|
157
|
-
console.log(`A project for extension ${extensionName} has been created successfully.`);
|
|
158
|
-
console.log();
|
|
159
|
-
})
|
|
160
|
-
.catch(reason => {
|
|
161
|
-
console.log();
|
|
162
|
-
console.log('Aborting installation.');
|
|
163
|
-
console.log(chalk.red('Unexpected error. Please report it as a bug:'));
|
|
164
|
-
console.log(reason);
|
|
165
|
-
console.log();
|
|
166
|
-
|
|
167
|
-
// On 'exit' we will delete these files from target directory.
|
|
168
|
-
const knownGeneratedFiles = [
|
|
169
|
-
'package.json',
|
|
170
|
-
'node_modules',
|
|
171
|
-
'.vscode',
|
|
172
|
-
'src',
|
|
173
|
-
'.eslintrc.cjs',
|
|
174
|
-
'.gitignore',
|
|
175
|
-
'.npmrc',
|
|
176
|
-
'.prettierrc',
|
|
177
|
-
'index.html',
|
|
178
|
-
'tsconfig.app.json',
|
|
179
|
-
'tsconfig.json',
|
|
180
|
-
'tsconfig.node.json',
|
|
181
|
-
'vite.config.ts',
|
|
182
|
-
];
|
|
183
|
-
const currentFiles = fs.readdirSync(path.join(root));
|
|
184
|
-
currentFiles.forEach(file => {
|
|
185
|
-
knownGeneratedFiles.forEach(fileToMatch => {
|
|
186
|
-
// This removes all knownGeneratedFiles.
|
|
187
|
-
if (file === fileToMatch) {
|
|
188
|
-
console.log(`Deleting generated file... ${chalk.cyan(file)}`);
|
|
189
|
-
fs.removeSync(path.join(root, file));
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
});
|
|
193
|
-
const remainingFiles = fs.readdirSync(path.join(root));
|
|
194
|
-
if (!remainingFiles.length) {
|
|
195
|
-
// Delete target folder if empty
|
|
196
|
-
console.log(`Deleting ${chalk.cyan(`${extensionName}/`)} from ${chalk.cyan(path.resolve(root, '..'))}`);
|
|
197
|
-
process.chdir(path.resolve(root, '..'));
|
|
198
|
-
fs.removeSync(path.join(root));
|
|
199
|
-
}
|
|
200
|
-
console.log('Done.');
|
|
201
|
-
process.exit(1);
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
function installDev(dependencies, verbose) {
|
|
206
|
-
return new Promise((resolve, reject) => {
|
|
207
|
-
const command = 'npm';
|
|
208
|
-
const args = ['install', '--no-audit', '--no-fund', '--save-dev'].concat(dependencies);
|
|
209
|
-
|
|
210
|
-
if (verbose) {
|
|
211
|
-
args.push('--verbose');
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
const child = spawn(command, args, { stdio: 'inherit' });
|
|
215
|
-
child.on('close', code => {
|
|
216
|
-
if (code !== 0) {
|
|
217
|
-
reject({
|
|
218
|
-
command: `${command} ${args.join(' ')}`,
|
|
219
|
-
});
|
|
220
|
-
return;
|
|
221
|
-
}
|
|
222
|
-
resolve();
|
|
223
|
-
});
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
function install(dependencies, verbose) {
|
|
228
|
-
return new Promise((resolve, reject) => {
|
|
229
|
-
const command = 'npm';
|
|
230
|
-
const args = ['install', '--no-audit', '--no-fund', '--save'].concat(dependencies);
|
|
231
|
-
|
|
232
|
-
if (verbose) {
|
|
233
|
-
args.push('--verbose');
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
const child = spawn(command, args, { stdio: 'inherit' });
|
|
237
|
-
child.on('close', code => {
|
|
238
|
-
if (code !== 0) {
|
|
239
|
-
reject({
|
|
240
|
-
command: `${command} ${args.join(' ')}`,
|
|
241
|
-
});
|
|
242
|
-
return;
|
|
243
|
-
}
|
|
244
|
-
resolve();
|
|
245
|
-
});
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
function installDependencies(verbose) {
|
|
250
|
-
return Promise.resolve(
|
|
251
|
-
install(
|
|
252
|
-
[
|
|
253
|
-
'@emotion/react@^11.13.3',
|
|
254
|
-
'@emotion/styled@^11.13.0',
|
|
255
|
-
'@fontsource/roboto@^5.1.0',
|
|
256
|
-
'@kvaser/canking-api',
|
|
257
|
-
'@mui/material@^6.1.3',
|
|
258
|
-
'fast-deep-equal@^3.1.3',
|
|
259
|
-
'google-protobuf@^3.21.4',
|
|
260
|
-
'long@^5.2.3',
|
|
261
|
-
'react@^18.3.1',
|
|
262
|
-
'react-dom@^18.3.1',
|
|
263
|
-
'react-router-dom',
|
|
264
|
-
'uuid@^10.0.0',
|
|
265
|
-
],
|
|
266
|
-
verbose,
|
|
267
|
-
),
|
|
268
|
-
).then(() =>
|
|
269
|
-
installDev(
|
|
270
|
-
[
|
|
271
|
-
'@types/google-protobuf@^3.15.12',
|
|
272
|
-
'@types/node@^22.7.5',
|
|
273
|
-
'@types/react@^18.3.11',
|
|
274
|
-
'@types/react-dom@^18.3.1',
|
|
275
|
-
'@types/react-router-dom',
|
|
276
|
-
'@types/uuid@^10.0.0',
|
|
277
|
-
'@typescript-eslint/eslint-plugin@^8.9.0',
|
|
278
|
-
'@typescript-eslint/parser@^8.9.0',
|
|
279
|
-
'@vitejs/plugin-react-swc@^3.7.1',
|
|
280
|
-
'cross-env@^7.0.3',
|
|
281
|
-
'eslint@^9.12.0',
|
|
282
|
-
'eslint-config-prettier@^9.1.0',
|
|
283
|
-
'eslint-plugin-prettier@^5.2.1',
|
|
284
|
-
'eslint-plugin-react@^7.37.1',
|
|
285
|
-
'eslint-plugin-react-hooks@^5.0.0',
|
|
286
|
-
'npm-run-all',
|
|
287
|
-
'prettier@^3.3.3',
|
|
288
|
-
'rimraf@^6.0.1',
|
|
289
|
-
'typescript@^5.6.3',
|
|
290
|
-
'vite@^5.4.9',
|
|
291
|
-
],
|
|
292
|
-
verbose,
|
|
293
|
-
),
|
|
294
|
-
);
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
function checkExtensionName(extensionName) {
|
|
298
|
-
const validationResult = validateProjectName(extensionName);
|
|
299
|
-
if (!validationResult.validForNewPackages) {
|
|
300
|
-
console.error(
|
|
301
|
-
chalk.red(
|
|
302
|
-
`Cannot create a project named ${chalk.green(`"${extensionName}"`)} because of npm naming restrictions:\n`,
|
|
303
|
-
),
|
|
304
|
-
);
|
|
305
|
-
[...(validationResult.errors || []), ...(validationResult.warnings || [])].forEach(error => {
|
|
306
|
-
console.error(chalk.red(` * ${error}`));
|
|
307
|
-
});
|
|
308
|
-
console.error(chalk.red('\nPlease choose a different project name.'));
|
|
309
|
-
process.exit(1);
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
/**
|
|
314
|
-
* Checks if the destination folder is okay to use.
|
|
315
|
-
* @param root The project root folder
|
|
316
|
-
* @param name The project name
|
|
317
|
-
* @returns true if not conflicts exists
|
|
318
|
-
*/
|
|
319
|
-
function isSafeToCreateProjectIn(root, name) {
|
|
320
|
-
const validFiles = [
|
|
321
|
-
'.DS_Store',
|
|
322
|
-
'.git',
|
|
323
|
-
'.gitattributes',
|
|
324
|
-
'.gitignore',
|
|
325
|
-
'.gitlab-ci.yml',
|
|
326
|
-
'.hg',
|
|
327
|
-
'.hgcheck',
|
|
328
|
-
'.hgignore',
|
|
329
|
-
'.idea',
|
|
330
|
-
'.npmignore',
|
|
331
|
-
'.travis.yml',
|
|
332
|
-
'docs',
|
|
333
|
-
'LICENSE',
|
|
334
|
-
'README.md',
|
|
335
|
-
'mkdocs.yml',
|
|
336
|
-
'Thumbs.db',
|
|
337
|
-
];
|
|
338
|
-
// These files should be allowed to remain on a failed install, but then
|
|
339
|
-
// silently removed during the next create.
|
|
340
|
-
const errorLogFilePatterns = ['npm-debug.log'];
|
|
341
|
-
const isErrorLog = file => {
|
|
342
|
-
return errorLogFilePatterns.some(pattern => file.startsWith(pattern));
|
|
343
|
-
};
|
|
344
|
-
|
|
345
|
-
const conflicts = fs
|
|
346
|
-
.readdirSync(root)
|
|
347
|
-
.filter(file => !validFiles.includes(file))
|
|
348
|
-
// Don't treat log files from previous installation as conflicts
|
|
349
|
-
.filter(file => !isErrorLog(file));
|
|
350
|
-
|
|
351
|
-
if (conflicts.length > 0) {
|
|
352
|
-
console.log(`The directory ${chalk.green(name)} contains files that could conflict:`);
|
|
353
|
-
console.log();
|
|
354
|
-
for (const file of conflicts) {
|
|
355
|
-
try {
|
|
356
|
-
const stats = fs.lstatSync(path.join(root, file));
|
|
357
|
-
if (stats.isDirectory()) {
|
|
358
|
-
console.log(` ${chalk.blue(`${file}/`)}`);
|
|
359
|
-
} else {
|
|
360
|
-
console.log(` ${file}`);
|
|
361
|
-
}
|
|
362
|
-
} catch (e) {
|
|
363
|
-
console.log(` ${file}`);
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
console.log();
|
|
367
|
-
console.log('Either try using a new directory name, or remove the files listed above.');
|
|
368
|
-
|
|
369
|
-
return false;
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
// Remove any log files from a previous installation.
|
|
373
|
-
fs.readdirSync(root).forEach(file => {
|
|
374
|
-
if (isErrorLog(file)) {
|
|
375
|
-
fs.removeSync(path.join(root, file));
|
|
376
|
-
}
|
|
377
|
-
});
|
|
378
|
-
return true;
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
function checkForLatestVersion() {
|
|
382
|
-
return new Promise((resolve, reject) => {
|
|
383
|
-
https
|
|
384
|
-
.get(`${kvaserRegistry}/-/package/%40kvaser/create-canking-extension/dist-tags`, res => {
|
|
385
|
-
if (res.statusCode === 200) {
|
|
386
|
-
let body = '';
|
|
387
|
-
res.on('data', data => (body += data));
|
|
388
|
-
res.on('end', () => {
|
|
389
|
-
resolve(JSON.parse(body).latest);
|
|
390
|
-
});
|
|
391
|
-
} else {
|
|
392
|
-
reject();
|
|
393
|
-
}
|
|
394
|
-
})
|
|
395
|
-
.on('error', () => {
|
|
396
|
-
reject();
|
|
397
|
-
});
|
|
398
|
-
});
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
module.exports = {
|
|
402
|
-
init,
|
|
403
|
-
};
|
package/scripts/index.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
const lowestMajorNodeVersion = 18;
|
|
6
|
-
const currentNodeVersion = process.versions.node;
|
|
7
|
-
const semver = currentNodeVersion.split('.');
|
|
8
|
-
const major = semver[0];
|
|
9
|
-
|
|
10
|
-
const chalk = require('chalk');
|
|
11
|
-
|
|
12
|
-
if (major < lowestMajorNodeVersion) {
|
|
13
|
-
console.error(
|
|
14
|
-
chalk.red(
|
|
15
|
-
'You are running Node ' +
|
|
16
|
-
currentNodeVersion +
|
|
17
|
-
'.\n' +
|
|
18
|
-
`Create CanKing Extension requires Node ${lowestMajorNodeVersion} or higher. \n` +
|
|
19
|
-
'Please update your version of Node.',
|
|
20
|
-
),
|
|
21
|
-
);
|
|
22
|
-
process.exit(1);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (process.argv.length === 3 && process.argv[2] === '--show-doc') {
|
|
26
|
-
try {
|
|
27
|
-
(async () => {
|
|
28
|
-
const open = (await import('open')).default;
|
|
29
|
-
const path = require('path');
|
|
30
|
-
const filePath = path.join(__dirname, '../doc/index.html');
|
|
31
|
-
open(filePath);
|
|
32
|
-
})();
|
|
33
|
-
} catch (error) {
|
|
34
|
-
console.error(chalk.red(error));
|
|
35
|
-
}
|
|
36
|
-
} else {
|
|
37
|
-
const { init } = require('./createCanKingExtension');
|
|
38
|
-
init();
|
|
39
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
root: true,
|
|
3
|
-
env: { browser: true, es2020: true },
|
|
4
|
-
extends: ['plugin:@typescript-eslint/recommended', 'plugin:prettier/recommended', 'plugin:react/recommended'],
|
|
5
|
-
ignorePatterns: ['dist', '.eslintrc.cjs'],
|
|
6
|
-
parser: '@typescript-eslint/parser',
|
|
7
|
-
plugins: ['react', 'react-hooks', '@typescript-eslint', 'prettier'],
|
|
8
|
-
rules: {
|
|
9
|
-
'import/no-extraneous-dependencies': 'off',
|
|
10
|
-
'react/react-in-jsx-scope': 'off',
|
|
11
|
-
'react/jsx-filename-extension': 'off',
|
|
12
|
-
'import/extensions': 'off',
|
|
13
|
-
'import/no-unresolved': 'off',
|
|
14
|
-
'import/no-import-module-exports': 'off',
|
|
15
|
-
'no-shadow': 'off',
|
|
16
|
-
'@typescript-eslint/no-shadow': 'error',
|
|
17
|
-
'no-unused-vars': 'off',
|
|
18
|
-
'@typescript-eslint/no-unused-vars': 'error',
|
|
19
|
-
'lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: true }],
|
|
20
|
-
quotes: [2, 'single', { avoidEscape: true }],
|
|
21
|
-
'react/prop-types': 'off',
|
|
22
|
-
'react-hooks/rules-of-hooks': 'error',
|
|
23
|
-
'react-hooks/exhaustive-deps': 'warn',
|
|
24
|
-
'prettier/prettier': ['error', { endOfLine: 'auto' }],
|
|
25
|
-
},
|
|
26
|
-
settings: {
|
|
27
|
-
react: {
|
|
28
|
-
version: 'detect',
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
parserOptions: {
|
|
32
|
-
ecmaVersion: 'latest',
|
|
33
|
-
sourceType: 'module',
|
|
34
|
-
ecmaFeatures: {
|
|
35
|
-
jsx: true,
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
# Logs
|
|
2
|
-
logs
|
|
3
|
-
*.log
|
|
4
|
-
npm-debug.log*
|
|
5
|
-
yarn-debug.log*
|
|
6
|
-
yarn-error.log*
|
|
7
|
-
pnpm-debug.log*
|
|
8
|
-
lerna-debug.log*
|
|
9
|
-
|
|
10
|
-
node_modules
|
|
11
|
-
dist
|
|
12
|
-
dist-ssr
|
|
13
|
-
*.local
|
|
14
|
-
|
|
15
|
-
# Editor directories and files
|
|
16
|
-
.vscode/*
|
|
17
|
-
!.vscode/extensions.json
|
|
18
|
-
.idea
|
|
19
|
-
.DS_Store
|
|
20
|
-
*.suo
|
|
21
|
-
*.ntvs*
|
|
22
|
-
*.njsproj
|
|
23
|
-
*.sln
|
|
24
|
-
*.sw?
|
package/scripts/template/_.npmrc
DELETED