Skip to content
This repository was archived by the owner on Oct 1, 2024. It is now read-only.

Commit cb15db9

Browse files
authored
Merge pull request #1 from Microsoft/master
merge latest code
2 parents 87d1cb5 + e3b9c5e commit cb15db9

File tree

133 files changed

+1553
-1691
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+1553
-1691
lines changed

.editorconfig

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
# EditorConfig is awesome: http://EditorConfig.org
2-
3-
# top-most EditorConfig file
4-
root = true
5-
6-
# Tab indentation
7-
[*]
8-
indent_style = space
9-
indent_size = 4
10-
11-
# The indent size used in the `package.json` file cannot be changed
12-
# https://github.com/npm/npm/pull/3180#issuecomment-16336516
13-
[{.travis.yml,npm-shrinkwrap.json,package.json}]
14-
indent_size = 2
1+
# EditorConfig is awesome: http://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
# Tab indentation
7+
[*]
8+
indent_style = space
9+
indent_size = 2
10+
11+
# The indent size used in the `package.json` file cannot be changed
12+
# https://github.com/npm/npm/pull/3180#issuecomment-16336516
13+
[{.travis.yml,npm-shrinkwrap.json,package.json}]
14+
indent_size = 2

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ out
33
node_modules
44
.vscode-test
55
.idea
6-
html/app/sprites-generated
6+
src/views/app/sprites-generated

CHANGELOG.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,45 @@
11
# Change Log
22
All notable changes to this project will be documented in this file.
33

4+
## Version 0.1.3
5+
- Release date: May 12, 2017
6+
7+
### Added
8+
- Support auto-discovery of AZ3166 board
9+
10+
### Changed
11+
- Make activation condition to activate always for keeping USB auto-detection work background
12+
- Auto-resolve arduino path from Registry on windows
13+
- Well handle the case when vscode has no workspace
14+
15+
### Fixed
16+
- Fix the issue of HTML view showing weird background color in vscode 1.12.1
17+
- Fix arduino board installation failure on Mac after usb detection
18+
19+
20+
## Version 0.1.2
21+
- Release date: April 28, 2017
22+
23+
### Added
24+
- Support manually imported library in libraries manager
25+
- Support 3rd-party boards
26+
- Add more devices (Arduino M0 Pro/Arduino Yún/Arduino Due) for auto discovery
27+
- Add native binaries version for electron 1.6.6 to unblock VSCode's future upgrade
28+
- Scaffold an empty sketch under current workspace folder
29+
30+
### Changed
31+
- Make the arduino.json configurable through UI
32+
- Refine extension activation events
33+
- Restore previous active serial monitor after upload is completed
34+
- Auto-resolve the sketch file path when the file is not existing for verify/upload
35+
- Search custom libraries and examples in the path of sketchbook.path preference rather than default windows Document path
36+
37+
### Fixed
38+
- Fix preferences.txt not found issue
39+
- Fix verify command NPE issue when no serial port is selected
40+
- Fix the error handling issue when opening serial monitor failed
41+
- Avoid verify/upload reentry issue
42+
443
## Version 0.1.1
544
- HotFix: Update display tag.
645

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ Welcome to **Arduino** <sup>preview</sup> for Visual Studio Code! The Arduino ex
1515

1616
## Prerequisites
1717
Arduino IDE is required. Please install it from [here](https://www.arduino.cc/en/main/software#download).
18+
- The supported Arduino IDE versions are 1.6.x and later.
19+
- The Windows Store's version of Arduino IDE is not supported because of the sandbox environment of Windows app.
1820

1921
## Installation
2022
Open VS Code and press `F1` or `Ctrl + Shift + P` to open command palette, select **Install Extension** and type `vscode-arduino`.
@@ -35,7 +37,7 @@ This extension provides several commands in the Command Palette (**F1** or **Ctr
3537
- **Arduino: Initialize**:Scaffold a VS Code project with an Arduino sketch.
3638
- **Arduino: Libraries Manager**: Explore and manage libraries.
3739
- **Arduino: Open Serial Monitor**: Open serial monitor in the intergrated output window.
38-
- **Arduino: Select Serial Port**: Change the current serial port.
40+
- **Arduino: Select Serial Port**: Change the current serial port.
3941
- **Arduino: Send Text to Serial Port**: Send a line of text via the current serial port.
4042
- **Arduino: Upload**: Build sketch and upload to Arduino board.
4143
- **Arduino: Verify**: Build sketch.
@@ -62,6 +64,7 @@ Currently this extension supports the following operatings systems:
6264
- Windows 7 and later (32-bit and 64-bit)
6365
- macOS 10.10 and later
6466
- Ubuntu 16.04
67+
- The extension might work on other Linux distro as some user reported but without gurantee.
6568

6669
## Contact Us
6770
If you'd like to help us build the best Arduino experience with VS Code, you can talk directly to the product team in our [gitter chat room](https://gitter.im/Microsoft/vscode-arduino).

gulpfile.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const gulp = require("gulp");
2+
const eslint = require('gulp-eslint');
23
const tslint = require("gulp-tslint");
34
const gutil = require("gulp-util");
45
const ts = require("gulp-typescript");
@@ -13,14 +14,21 @@ const childProcess = require("child_process");
1314

1415
//...
1516
gulp.task("tslint", () => {
16-
return gulp.src(["**/*.ts", "**/*.tsx", "!**/*.d.ts", "!node_modules/**", "!./html/node_modules/**"])
17+
return gulp.src(["**/*.ts", "**/*.tsx", "!**/*.d.ts", "!node_modules/**", "!./src/views/node_modules/**"])
1718
.pipe(tslint())
1819
.pipe(tslint.report());
1920
});
2021

22+
gulp.task("eslint", () => {
23+
return gulp.src(["./vendor/**/*.js", "!**/node_modules/**"])
24+
.pipe(eslint())
25+
.pipe(eslint.format())
26+
.pipe(eslint.failAfterError());
27+
});
28+
2129
gulp.task("html-webpack", (done) => {
22-
const config = require("./html/webpack.config.js");
23-
config.context = `${__dirname}/html`;
30+
const config = require("./src/views/webpack.config.js");
31+
config.context = `${__dirname}/src/views`;
2432
return webpack(config, (err, stats) => {
2533
const statsJson = stats.toJson();
2634
if (err || (statsJson.errors && statsJson.errors.length)) {
@@ -83,7 +91,7 @@ gulp.task("test", (done) => {
8391
}
8492

8593
// When using cli command "npm test" to exec test, the depended extensions (cpptools) are not available so that
86-
// the extension cannot be activated. As a workaround, remove extensionDependencies from package.json before running test
94+
// the extension cannot be activated. As a workaround, remove extensionDependencies from package.json before running test
8795
// and restore extensionDependencies after test exited.
8896
removeExtensionDependencies();
8997

@@ -119,6 +127,6 @@ gulp.task("build", (done) => {
119127
});
120128

121129
gulp.task("watch", () => {
122-
gulp.watch(["./src/**/*", "./test/**/*"], ["ts-compile"]);
123-
gulp.watch(["./html/**/*", "!./html/node_modules/**"], ["html-webpack"]);
130+
gulp.watch(["./src/**/*", "./test/**/*", "!./src/views/**/*"], ["ts-compile"]);
131+
gulp.watch(["./src/views/**/*", "!./src/views/node_modules/**"], ["html-webpack"]);
124132
});

misc/usbmapping.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,14 @@
6363
"architecture": "samd",
6464
"id": "adafruit_feather_m0"
6565
}]
66+
}, {
67+
"index_file": "https://raw.githubusercontent.com/VSChina/azureiotdevkit_tools/master/package_azureboard_index.json",
68+
"boards": [{
69+
"vid": "0483",
70+
"pid": "374b",
71+
"name": "MXCHIP AZ3166",
72+
"package": "AZ3166",
73+
"architecture": "stm32f4",
74+
"id": "MXCHIP_AZ3166"
75+
}]
6676
}]

package.json

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "vscode-arduino",
33
"displayName": "Arduino",
44
"description": "Arduino for Visual Studio Code",
5-
"version": "0.1.1",
5+
"version": "0.1.3",
66
"publisher": "vsciot-vscode",
77
"aiKey": "83dd2c27-6594-41d3-85a9-bdb22070eb42",
88
"preview": true,
@@ -23,17 +23,7 @@
2323
"C++"
2424
],
2525
"activationEvents": [
26-
"onLanguage:c",
27-
"onLanguage:cpp",
28-
"workspaceContains:.vscode/arduino.json",
29-
"onCommand:arduino.initialize",
30-
"onCommand:arduino.verify",
31-
"onCommand:arduino.upload",
32-
"onCommand:arduino.selectSerialPort",
33-
"onCommand:arduino.changeBoardType",
34-
"onCommand:arduino.showBoardManager",
35-
"onCommand:arduino.showLibraryManager",
36-
"onCommand:arduino.showExamples"
26+
"*"
3727
],
3828
"main": "./out/src/extension",
3929
"contributes": {
@@ -177,7 +167,7 @@
177167
},
178168
"scripts": {
179169
"vscode:prepublish": "gulp build",
180-
"postinstall": "node ./node_modules/vscode/bin/install && cd ./html && npm install",
170+
"postinstall": "node ./node_modules/vscode/bin/install && cd ./src/views && npm install",
181171
"test": "gulp test"
182172
},
183173
"extensionDependencies": [
@@ -188,7 +178,15 @@
188178
"@types/node": "^6.0.40",
189179
"@types/winreg": "^1.2.30",
190180
"del": "^2.2.2",
181+
"eslint": "^3.19.0",
182+
"eslint-config-standard": "^10.2.1",
183+
"eslint-plugin-import": "^2.2.0",
184+
"eslint-plugin-node": "^4.2.2",
185+
"eslint-plugin-promise": "^3.5.0",
186+
"eslint-plugin-require-path-exists": "^1.1.7",
187+
"eslint-plugin-standard": "^3.0.1",
191188
"gulp": "^3.9.1",
189+
"gulp-eslint": "^3.0.1",
192190
"gulp-sourcemaps": "^2.4.1",
193191
"gulp-tslint": "^7.0.1",
194192
"gulp-typescript": "^3.1.5",

src/arduino/arduino.ts

Lines changed: 25 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ import * as vscode from "vscode";
1212
import * as constants from "../common/constants";
1313
import * as util from "../common/util";
1414
import * as Logger from "../logger/logger";
15-
import * as settings from "./settings";
1615

1716
import { DeviceContext, IDeviceContext } from "../deviceContext";
17+
import { IArduinoSettings } from "./arduinoSettings";
1818
import { BoardManager } from "./boardManager";
1919
import { ExampleManager } from "./exampleManager";
2020
import { LibraryManager } from "./libraryManager";
21+
import { VscodeSettings } from "./vscodeSettings";
2122

2223
import { arduinoChannel } from "../common/outputChannel";
2324
import { SerialMonitor } from "../serialmonitor/serialMonitor";
@@ -27,8 +28,6 @@ import { SerialMonitor } from "../serialmonitor/serialMonitor";
2728
*/
2829
export class ArduinoApp {
2930

30-
private _preferences: Map<string, string>;
31-
3231
private _boardManager: BoardManager;
3332

3433
private _libraryManager: LibraryManager;
@@ -38,18 +37,19 @@ export class ArduinoApp {
3837
/**
3938
* @param {IArduinoSettings} ArduinoSetting object.
4039
*/
41-
constructor(private _settings: settings.IArduinoSettings) {
40+
constructor(private _settings: IArduinoSettings) {
4241
}
4342

4443
/**
4544
* Need refresh Arduino IDE's setting when starting up.
4645
* @param {boolean} force - Whether force initialzie the arduino
4746
*/
4847
public async initialize(force: boolean = false) {
49-
if (!util.fileExistsSync(path.join(this._settings.packagePath, "preferences.txt"))) {
48+
if (!util.fileExistsSync(this._settings.preferencePath)) {
5049
try {
5150
// Use empty pref value to initialize preference.txt file
5251
await this.setPref("boardsmanager.additional.urls", "");
52+
this._settings.loadPreferences(); // reload preferences.
5353
} catch (ex) {
5454
}
5555
}
@@ -96,6 +96,12 @@ export class ArduinoApp {
9696
if (!boardDescriptor) {
9797
return;
9898
}
99+
100+
if (!vscode.workspace.rootPath) {
101+
vscode.window.showWarningMessage("Cannot find the sketch file.");
102+
return;
103+
}
104+
99105
if (!dc.sketch || !util.fileExistsSync(path.join(vscode.workspace.rootPath, dc.sketch))) {
100106
await this.getMainSketch(dc);
101107
}
@@ -114,7 +120,7 @@ export class ArduinoApp {
114120

115121
const appPath = path.join(vscode.workspace.rootPath, dc.sketch);
116122
const args = ["--upload", "--board", boardDescriptor, "--port", dc.port, appPath];
117-
if (this._settings.logLevel === "verbose") {
123+
if (VscodeSettings.getIntance().logLevel === "verbose") {
118124
args.push("--verbose");
119125
}
120126
await util.spawn(this._settings.commandPath, arduinoChannel.channel, args).then(async (result) => {
@@ -134,6 +140,11 @@ export class ArduinoApp {
134140
return;
135141
}
136142

143+
if (!vscode.workspace.rootPath) {
144+
vscode.window.showWarningMessage("Cannot find the sketch file.");
145+
return;
146+
}
147+
137148
if (!dc.sketch || !util.fileExistsSync(path.join(vscode.workspace.rootPath, dc.sketch))) {
138149
await this.getMainSketch(dc);
139150
}
@@ -143,7 +154,7 @@ export class ArduinoApp {
143154
arduinoChannel.start(`Verify sketch - ${dc.sketch}`);
144155
const appPath = path.join(vscode.workspace.rootPath, dc.sketch);
145156
const args = ["--verify", "--board", boardDescriptor, appPath];
146-
if (this._settings.logLevel === "verbose") {
157+
if (VscodeSettings.getIntance().logLevel === "verbose") {
147158
args.push("--verbose");
148159
}
149160
arduinoChannel.show();
@@ -162,7 +173,9 @@ export class ArduinoApp {
162173
} else {
163174
libPaths = this.getDefaultPackageLibPaths();
164175
}
165-
176+
if (!vscode.workspace.rootPath) {
177+
return;
178+
}
166179
const configFilePath = path.join(vscode.workspace.rootPath, constants.CPP_CONFIG_FILE);
167180
let deviceContext = null;
168181
if (!util.fileExistsSync(configFilePath)) {
@@ -213,6 +226,9 @@ export class ArduinoApp {
213226

214227
// Include the *.h header files from selected library to the arduino sketch.
215228
public async includeLibrary(libraryPath: string) {
229+
if (!vscode.workspace.rootPath) {
230+
return;
231+
}
216232
const dc = DeviceContext.getIntance();
217233
const appPath = path.join(vscode.workspace.rootPath, dc.sketch);
218234
if (util.fileExistsSync(appPath)) {
@@ -350,7 +366,7 @@ export class ArduinoApp {
350366
}
351367

352368
// Step 1: Copy the example project to a temporary directory.
353-
const sketchPath = this.preferences.get("sketchbook.path") || path.dirname(this._settings.libPath);
369+
const sketchPath = path.join(this._settings.sketchbookPath, "generated_examples");
354370
if (!util.directoryExistsSync(sketchPath)) {
355371
util.mkdirRecursivelySync(sketchPath);
356372
}
@@ -404,13 +420,6 @@ export class ArduinoApp {
404420
return destExample;
405421
}
406422

407-
public get preferences() {
408-
if (!this._preferences) {
409-
this.loadPreferences();
410-
}
411-
return this._preferences;
412-
}
413-
414423
public get settings() {
415424
return this._settings;
416425
}
@@ -439,22 +448,6 @@ export class ArduinoApp {
439448
this._exampleManager = value;
440449
}
441450

442-
private loadPreferences() {
443-
this._preferences = new Map<string, string>();
444-
const lineRegex = /(\S+)=(\S+)/;
445-
446-
const rawText = fs.readFileSync(path.join(this._settings.packagePath, "preferences.txt"), "utf8");
447-
const lines = rawText.split("\n");
448-
lines.forEach((line) => {
449-
if (line) {
450-
const match = lineRegex.exec(line);
451-
if (match && match.length > 2) {
452-
this._preferences.set(match[1], match[2]);
453-
}
454-
}
455-
});
456-
}
457-
458451
private getBoardBuildString(deviceContext: IDeviceContext): string {
459452
const selectedBoard = this.boardManager.currentBoard;
460453
if (!selectedBoard) {

0 commit comments

Comments
 (0)