Skip to content

Commit 6c47bde

Browse files
authored
Make package/library update as a manual operation (microsoft#350)
1 parent ea71cd0 commit 6c47bde

File tree

10 files changed

+89
-94
lines changed

10 files changed

+89
-94
lines changed

.vscode/launch.json

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,47 @@
77
"type": "extensionHost",
88
"request": "launch",
99
"runtimeExecutable": "${execPath}",
10-
"args": ["--extensionDevelopmentPath=${workspaceRoot}" ],
10+
"args": [
11+
"--extensionDevelopmentPath=${workspaceRoot}"
12+
],
1113
"stopOnEntry": false,
1214
"sourceMaps": true,
13-
"outFiles": [ "${workspaceRoot}/out/src/**/*.js" ],
15+
"outFiles": [
16+
"${workspaceRoot}/out/src/**/*.js"
17+
],
1418
"preLaunchTask": "build"
1519
},
1620
{
1721
"name": "Launch Tests",
1822
"type": "extensionHost",
1923
"request": "launch",
2024
"runtimeExecutable": "${execPath}",
21-
"args": ["${workspaceRoot}/test/resources/blink", "--extensionDevelopmentPath=${workspaceRoot}", "--extensionTestsPath=${workspaceRoot}/out/test" ],
25+
"args": [
26+
"${workspaceRoot}/test/resources/blink",
27+
"--extensionDevelopmentPath=${workspaceRoot}",
28+
"--extensionTestsPath=${workspaceRoot}/out/test"
29+
],
2230
"stopOnEntry": false,
2331
"sourceMaps": true,
24-
"outFiles": [ "${workspaceRoot}/out/test/**/*.js" ],
32+
"outFiles": [
33+
"${workspaceRoot}/out/test/**/*.js"
34+
],
2535
"preLaunchTask": "build"
36+
},
37+
{
38+
"name": "Launch Extension in Development",
39+
"type": "extensionHost",
40+
"request": "launch",
41+
"runtimeExecutable": "${execPath}",
42+
"args": [
43+
"--extensionDevelopmentPath=${workspaceRoot}"
44+
],
45+
"stopOnEntry": false,
46+
"sourceMaps": true,
47+
"outFiles": [
48+
"${workspaceRoot}/out/src/**/*.js"
49+
],
50+
"preLaunchTask": "build_without_view"
2651
}
2752
]
2853
}

.vscode/tasks.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@
55
// ${fileDirname}: the current opened file's dirname
66
// ${fileExtname}: the current opened file's extension
77
// ${cwd}: the current working directory of the spawned process
8-
98
// A task runner that calls a custom npm script that compiles the extension.
109
{
1110
"version": "0.1.0",
1211
"command": "gulp",
1312
"isShellCommand": true,
14-
"args":[
13+
"args": [
1514
"--no-color"
1615
],
1716
"tasks": [
@@ -23,6 +22,15 @@
2322
"problemMatcher": [
2423
"$tsc"
2524
]
25+
},
26+
{
27+
"taskName": "build_without_view",
28+
"args": [],
29+
"isBuildCommand": true,
30+
"isBackground": false,
31+
"problemMatcher": [
32+
"$tsc"
33+
]
2634
}
2735
]
2836
}

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,11 @@ The following Visual Studio Code settings are available for the Arduino extensio
5656
{
5757
"arduino.path": "C:/Program Files (x86)/Arduino",
5858
"arduino.additionalUrls": "",
59-
"arduino.autoUpdateIndexFiles": false,
6059
"arduino.logLevel": "info"
6160
}
6261
```
6362
- `arduino.path` - Path to Arduino, you can use a custom version of Arduino by modifying this setting to include the full path. Example: `C:\\Program Files\\Arduino` for Windows, `/Applications` for Mac, `/home/$user/Downloads/arduino-1.8.1` for Linux. (Requires a restart after change). The default value is automatically detected from your Arduino IDE installation path.
6463
- `arduino.additionalUrls` - Additional URLs for 3rd party packages. You can have multiple URLs in one string with comma(,) as separator, or have a string array. The default value is empty.
65-
- `arduino.autoUpdateIndexFiles` - Controls auto update of package_index.json and library_index.json index files. If enabled, each time when you open Boards Manager/Libraries Manager, download latest index files first. Otherwise, using index files cached on local disk for Boards Manager/Libraries Manager. The default value is `false`.
6664
- `arduino.logLevel` - CLI output log level. Could be info or verbose. The default value is `"info"`.
6765

6866
## Debugging Arduino Code <sup>preview</sup>

gulpfile.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ gulp.task("build", (done) => {
126126
return runSequence("clean", "ts-compile", "html-webpack", done);
127127
});
128128

129+
gulp.task("build_without_view", (done) => {
130+
return runSequence("clean", "ts-compile", done);
131+
});
132+
129133
gulp.task("watch", () => {
130134
gulp.watch(["./src/**/*", "./test/**/*", "!./src/views/**/*"], ["ts-compile"]);
131135
gulp.watch(["./src/views/**/*", "!./src/views/node_modules/**"], ["html-webpack"]);

package.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -455,11 +455,6 @@
455455
"info",
456456
"verbose"
457457
]
458-
},
459-
"arduino.autoUpdateIndexFiles": {
460-
"type": "boolean",
461-
"default": false,
462-
"description": "Controls auto update of package_index.json and library_index.json index files. If enabled, each time when you open Board Manager/Library Manager, download latest index files first. Otherwise, using index files cached on local disk for Board Manager/Library Manager."
463458
}
464459
}
465460
},

src/arduino/arduinoContentProvider.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,7 @@ export class ArduinoContentProvider implements vscode.TextDocumentContentProvide
107107
}
108108

109109
public async getBoardPackages(req, res) {
110-
const update = (VscodeSettings.getInstance().autoUpdateIndexFiles && req.query.update === "true");
111-
await ArduinoContext.boardManager.loadPackages(update);
110+
await ArduinoContext.boardManager.loadPackages(req.query.update === "true");
112111
return res.json({
113112
platforms: JSONHelper.decycle(ArduinoContext.boardManager.platforms, undefined),
114113
});
@@ -167,8 +166,7 @@ export class ArduinoContentProvider implements vscode.TextDocumentContentProvide
167166
}
168167

169168
public async getLibraries(req, res) {
170-
const update = (VscodeSettings.getInstance().autoUpdateIndexFiles && req.query.update === "true");
171-
await ArduinoContext.arduinoApp.libraryManager.loadLibraries(update);
169+
await ArduinoContext.arduinoApp.libraryManager.loadLibraries(req.query.update === "true");
172170
return res.json({
173171
libraries: ArduinoContext.arduinoApp.libraryManager.libraries,
174172
});

src/arduino/vscodeSettings.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ const configKeys = {
1313
export interface IVscodeSettings {
1414
arduinoPath: string;
1515
additionalUrls: string | string[];
16-
autoUpdateIndexFiles: boolean;
1716
logLevel: string;
1817
updateAdditionalUrls(urls: string | string[]): void;
1918
}
@@ -38,10 +37,6 @@ export class VscodeSettings implements IVscodeSettings {
3837
return this.getConfigValue<string | string[]>(configKeys.ADDITIONAL_URLS);
3938
}
4039

41-
public get autoUpdateIndexFiles(): boolean {
42-
return this.getConfigValue<boolean>(configKeys.AUTO_UPDATE_INDEX_FILES);
43-
}
44-
4540
public get logLevel(): string {
4641
return this.getConfigValue<string>(configKeys.LOG_LEVEL) || "info";
4742
}

src/views/app/components/BoardManager.tsx

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ interface IBoardManagerProps extends React.Props<any> {
1919
installErrorMessage: string;
2020
uninstallingBoardName: string;
2121
uninstallErrorMessage: string;
22-
loadBoardPackages: () => void;
22+
loadBoardPackages: (update: boolean) => void;
2323
installBoard: (boardName, packageName, arch, version) => void;
2424
uninstallBoard: (boardName, packagePath) => void;
2525
}
@@ -44,7 +44,7 @@ const mapStateToProps = (state) => {
4444

4545
const mapDispatchToProps = (dispatch) => {
4646
return {
47-
loadBoardPackages: () => actions.getBoardPackages(dispatch, true),
47+
loadBoardPackages: (update: boolean = false) => actions.getBoardPackages(dispatch, update),
4848
installBoard: (boardName, packageName, arch, version) => actions.installBoard(dispatch, boardName, packageName, arch, version, () => {
4949
actions.getBoardPackages(dispatch, false);
5050
}),
@@ -67,7 +67,7 @@ class BoardManager extends React.Component<IBoardManagerProps, IBoardManagerStat
6767
}
6868

6969
public componentWillMount() {
70-
this.props.loadBoardPackages();
70+
this.props.loadBoardPackages(false);
7171
}
7272

7373
public render() {
@@ -111,36 +111,40 @@ class BoardManager extends React.Component<IBoardManagerProps, IBoardManagerStat
111111

112112
const isOperating = this.props.installingBoardName || this.props.uninstallingBoardName;
113113
return (
114-
<div className={"boardmanager " + (!!isOperating ? "disabled" : "")}>
115-
{
116-
this.props.requesting && (
117-
<div className="mask theme-bgcolor">Loading...</div>
118-
)
119-
}
120-
<div className="arduinomanager-toolbar theme-bgcolor">
121-
<div className="dropdown-filter">
122-
<span className="dropdown-label">Type</span>
123-
<DropdownButton id="typeselector" title={this.state.category} onSelect={this.typeUpdate}>
124-
{ this.props.categories.map((c, index) => {
125-
return (<MenuItem key={index} eventKey={c} active={c === this.state.category}>{c}</MenuItem>);
126-
})}
127-
</DropdownButton>
128-
</div>
129-
<SearchInput className="search-input" placeholder="Filter your search..." onChange={this.searchUpdate} />
130-
</div>
131-
<div className="arduinomanager-container">
114+
<div className={"boardmanager " + (!!isOperating ? "disabled" : "")}>
132115
{
133-
filteredPlatforms.map((p, index) => {
134-
return (<BoardItemView key={p.name} platform={p} {...boardProps} />);
135-
})
116+
this.props.requesting && (
117+
<div className="mask theme-bgcolor">Loading...</div>
118+
)
136119
}
137-
</div>
138-
<div className="arduinomanager-footer theme-bgcolor">
139-
<span>{totalCountTips}</span>
140-
<a className="help-link right-side" title="Configure Additional Boards Manager URLs"
141-
onClick={() => API.openSettings()}>Additional URLs</a>
142-
</div>
143-
</div>);
120+
<div className="arduinomanager-toolbar theme-bgcolor">
121+
<div className="dropdown-filter">
122+
<span className="dropdown-label">Type</span>
123+
<DropdownButton id="typeselector" title={this.state.category} onSelect={this.typeUpdate}>
124+
{this.props.categories.map((c, index) => {
125+
return (<MenuItem key={index} eventKey={c} active={c === this.state.category}>{c}</MenuItem>);
126+
})}
127+
</DropdownButton>
128+
</div>
129+
<SearchInput className="search-input" placeholder="Filter your search..." onChange={this.searchUpdate} />
130+
<Button className="operation-btn" bsStyle="link" onClick={() => this.props.loadBoardPackages(true)}>
131+
Refresh Package Indexes
132+
</Button>
133+
</div>
134+
<div className="arduinomanager-container">
135+
{
136+
filteredPlatforms.map((p, index) => {
137+
return (<BoardItemView key={p.name} platform={p} {...boardProps} />);
138+
})
139+
}
140+
</div>
141+
<div className="arduinomanager-footer theme-bgcolor">
142+
<span>{totalCountTips}</span>
143+
<a className="help-link right-side" title="Configure Additional Boards Manager URLs"
144+
onClick={() => API.openSettings()}>Additional URLs</a>
145+
</div>
146+
147+
</div>);
144148
}
145149

146150
private typeUpdate(eventKey: any, event?: React.SyntheticEvent<{}>): void {

src/views/app/components/LibraryManager.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ interface ILibraryManagerProps extends React.Props<any> {
1818
errorMessage: string;
1919
installingLibraryName: string;
2020
uninstallingLibraryName: string;
21-
loadLibraries: () => void;
21+
loadLibraries: (update: boolean) => void;
2222
installLibrary: (libraryName, version, callback) => void;
2323
uninstallLibrary: (libraryName, libraryPath, callback) => void;
2424
}
@@ -44,7 +44,7 @@ const mapStateToProps = (store) => {
4444

4545
const mapDispatchToProps = (dispatch) => {
4646
return {
47-
loadLibraries: () => actions.getLibraries(dispatch, true),
47+
loadLibraries: (update: boolean = false) => actions.getLibraries(dispatch, update),
4848
installLibrary: (libraryName, version, callback) => actions.installLibrary(dispatch, libraryName, version, (error) => {
4949
if (!error) {
5050
// Refresh library manager view
@@ -81,7 +81,7 @@ class LibraryManager extends React.Component<ILibraryManagerProps, ILibraryManag
8181
}
8282

8383
public componentWillMount() {
84-
this.props.loadLibraries();
84+
this.props.loadLibraries(false);
8585
}
8686

8787
public render() {
@@ -168,6 +168,9 @@ class LibraryManager extends React.Component<ILibraryManagerProps, ILibraryManag
168168
</div>
169169
<SearchInput className="search-input" placeholder="Filter your search..." onChange={this.searchUpdate} />
170170
<Checkbox className="supported-checkbox" onChange={this.handleCheck}>Only show libraries supported by current board</Checkbox>
171+
<Button className="operation-btn" bsStyle="link" onClick={() => this.props.loadLibraries(true)}>
172+
Refresh Library Index
173+
</Button>
171174
</div>
172175
<div className="arduinomanager-container">
173176
<ReactList itemRenderer={itemRenderer} itemSizeEstimator={itemSizeEstimator} length={filteredLibraries.length} type="variable"/>

0 commit comments

Comments
 (0)