Skip to content

Commit 3a33f12

Browse files
author
Jakob Rosenberg
authored
Merge pull request #192 from pycom/develop
New release
2 parents 5466574 + 7960852 commit 3a33f12

File tree

6 files changed

+110
-134
lines changed

6 files changed

+110
-134
lines changed

CHANGELOG.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# Changelog
22

3-
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
3+
## [1.1.17](https://github.com/pycom/pymakr-vsc/compare/v1.1.16...v1.1.17) (2022-01-04)
4+
- better handling for unavailable bindings (3b4a57e)
5+
- github action error for deploy script (1e2b9c5)
6+
- reduce requirements for fallback builds (6b05f12)
7+
8+
## [1.1.16](https://github.com/pycom/pymakr-vsc/compare/v1.1.15...v1.1.16) (2021-10-27)
9+
- binding: updated serialport to 9.2.4 (d4a8934)
410

511
## [1.1.15](https://github.com/pycom/pymakr-vsc/compare/v1.1.14...v1.1.15) (2021-10-15)
612
- better handling for unavailable bindings ([3b4a57e](https://github.com/pycom/pymakr-vsc/commit/3b4a57ec7ae85695ac1a830eb2b4737b16fbeab5))

README.md

+8-4
Original file line numberDiff line numberDiff line change
@@ -113,18 +113,22 @@ This may be the case if your board is a generic micropython board.
113113
3) re-run 'pymakr > Extra > List Serial ports'
114114
4) is the board is not detected as the first , you may need to move it to the front of the list.
115115

116+
### Binding errors for `serialport`
117+
`serialport` relies on a native module which needs to be downloaded or built at runtime. Sometimes this fails.
118+
119+
**Solutions:**
120+
- Install VSCode [manually](https://code.visualstudio.com/docs/setup/setup-overview) (we've had [issues](https://github.com/pycom/pymakr-vsc/issues/184#issuecomment-959293789) with package managers like Snap)
121+
- If a working binding can't be downloaded, PyMakr will try to build them locally with `node-gyp`. Please see requirements for your OS [here](https://github.com/nodejs/node-gyp#installation)
122+
116123
## Developing
117124
If you want to contribute to this project you can test the app the following way:
118125

119126
- Download the code or clone the repo
120-
- Install Babel by running `npm install --save-dev babel-core`
121127
- Open the folder in VSC
122-
- Press F1 and execute `Tasks: Run build task` to run the babel builder
123128
- Press F5 to run the plugin (opens a new VSC window)
124129

125130
Note: make sure you have the 'code' terminal command installed. See [code setup for Mac(https://code.visualstudio.com/docs/setup/mac)
126131

127132
## Create a local package
128-
- Install the vscode publishing tool by running `npm install -g vsce`
129-
- Create a .vsix package by running `vsce package`
133+
- Create a .vsix package by running `npm run package`
130134
- you can then install the .vsix package by running `code --install-extension pymakr-1.x.y.vsix`

lib/config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ module.exports = class Config {
159159
items: {
160160
type: 'string'
161161
},
162-
default: ['Pycom','Pycom Ltd.','FTDI','Microsoft','Microchip Technology, Inc.'],
162+
default: ['Pycom','Pycom Ltd.','FTDI','Microsoft','Microchip Technology, Inc.', '1a86'],
163163
order: 13
164164
},
165165
}

lib/main/settings-wrapper.js

-7
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,6 @@ module.exports = class SettingsWrapper extends EventEmitter {
3333
var _this = this
3434

3535

36-
37-
// this.refresh(function(){
38-
// _this.watchConfigFile()
39-
// _this.watchProjectChange()
40-
// cb(_this)
41-
// })
42-
4336
this.readConfigFile(this.global_config_file,true,function(contents){
4437
_this.global_config = contents
4538
_this.readConfigFile(_this.config_file,false,function(contents){

pymakr.js

+93-120
Original file line numberDiff line numberDiff line change
@@ -1,145 +1,118 @@
1-
var vscode = require('vscode');
2-
var { execSync } = require('child_process');
1+
const vscode = require('vscode');
2+
const { execSync } = require('child_process');
33
const { prepareSerialPort } = require('./lib/serialport')
4-
var PanelView, Pymakr, Pyboard, SettingsWrapper, pb, v, sw, pymakr
5-
4+
const destroyHandles = []
5+
6+
/**
7+
* same as vscode.commands.registerCommand but automatically pushes disposables to context subscriptions
8+
* @param {vscode.ExtensionContext} context
9+
* @param {Object.<string, (...args: any[]) => any>} commands
10+
*/
11+
const batchRegisterCommands = (context, commands) => {
12+
Object.entries(commands).forEach(([command, callback]) => {
13+
const disposable = vscode.commands.registerCommand(command, callback)
14+
context.subscriptions.push(disposable)
15+
})
16+
}
617

18+
/**
19+
* this method activates the extension
20+
* @param {vscode.ExtensionContext} context
21+
*/
722
async function activate(context) {
823
await prepareSerialPort()
9-
SettingsWrapper = require('./lib/main/settings-wrapper');
1024

11-
sw = new SettingsWrapper(function () {
25+
/**
26+
* we have to import SettingsWrapper after prepareSerialPort
27+
* since SettingsWrapper imports serialport
28+
*/
29+
const SettingsWrapper = require('./lib/main/settings-wrapper');
30+
31+
const settingsWrapper = new SettingsWrapper(function () {
1232
const nodejs_installed = execSync('node -v', { encoding: 'utf8' }).substr(0, 1) === "v"
1333

1434
if (!nodejs_installed) {
15-
vscode.window.showErrorMessage("NodeJS not detected on this machine, which is required for Pymakr to work. See the Pymakr readme for dependancies.")
35+
vscode.window.showErrorMessage("NodeJS not detected on this machine, which is required for Pymakr to work. See the Pymakr readme for dependencies.")
1636
} else {
37+
const PanelView = require('./lib/main/panel-view');
38+
const Pymakr = require('./lib/pymakr');
39+
const Pyboard = require('./lib/board/pyboard');
1740

1841

19-
PanelView = require('./lib/main/panel-view');
20-
Pymakr = require('./lib/pymakr');
21-
Pyboard = require('./lib/board/pyboard');
22-
23-
24-
pb = new Pyboard(sw)
25-
v = new PanelView(pb, sw)
26-
pymakr = new Pymakr({}, pb, v, sw)
27-
42+
const pyboard = new Pyboard(settingsWrapper)
43+
const panelView = new PanelView(pyboard, settingsWrapper)
44+
const pymakr = new Pymakr({}, pyboard, panelView, settingsWrapper)
45+
const { terminal } = panelView
2846

29-
var terminal = v.terminal
30-
31-
var disposable = vscode.commands.registerCommand('pymakr.help', function () {
32-
terminal.show()
33-
pymakr.writeHelpText()
34-
})
35-
context.subscriptions.push(disposable);
36-
37-
var disposable = vscode.commands.registerCommand('pymakr.listCommands', function () {
38-
v.showQuickPick()
39-
})
40-
context.subscriptions.push(disposable);
41-
42-
var disposable = vscode.commands.registerCommand('pymakr.connect', function () {
43-
terminal.show()
44-
pymakr.connect()
45-
})
46-
47-
var disposable = vscode.commands.registerCommand('pymakr.run', function () {
48-
terminal.show()
49-
pymakr.run()
50-
})
51-
context.subscriptions.push(disposable);
52-
53-
var disposable = vscode.commands.registerCommand('pymakr.runselection', function () {
54-
terminal.show()
55-
pymakr.runselection()
56-
})
57-
context.subscriptions.push(disposable);
58-
59-
var disposable = vscode.commands.registerCommand('pymakr.upload', function () {
60-
terminal.show()
61-
pymakr.upload()
62-
})
63-
context.subscriptions.push(disposable);
64-
65-
var disposable = vscode.commands.registerCommand('pymakr.uploadFile', function () {
66-
terminal.show()
67-
pymakr.uploadFile()
68-
})
69-
context.subscriptions.push(disposable);
70-
71-
var disposable = vscode.commands.registerCommand('pymakr.download', function () {
72-
terminal.show()
73-
pymakr.download()
74-
})
75-
context.subscriptions.push(disposable);
76-
77-
var disposable = vscode.commands.registerCommand('pymakr.globalSettings', function () {
78-
pymakr.openGlobalSettings()
79-
})
80-
context.subscriptions.push(disposable);
47+
destroyHandles.push(() => panelView.destroy())
8148

82-
var disposable = vscode.commands.registerCommand('pymakr.projectSettings', function () {
83-
pymakr.openProjectSettings()
84-
})
85-
context.subscriptions.push(disposable);
86-
87-
var disposable = vscode.commands.registerCommand('pymakr.disconnect', function () {
88-
pymakr.disconnect()
89-
});
90-
context.subscriptions.push(disposable);
91-
92-
// // not used. open/close terminal command is already available.
93-
// // not used. open/close terminal command is already available.
94-
// // not used. open/close terminal command is already available.
95-
// // Terminal opens automatically when doing a connect, run or sync action.
96-
// var disposable = vscode.commands.registerCommand('pymakr.toggleREPL', function () {
97-
// pymakr.toggleVisibility()
98-
// });
99-
// context.subscriptions.push(disposable);
100-
101-
var disposable = vscode.commands.registerCommand('pymakr.toggleConnect', function () {
102-
if (!pymakr.pyboard.connected) {
49+
batchRegisterCommands(context, {
50+
'pymakr.help': () => {
51+
terminal.show()
52+
pymakr.writeHelpText()
53+
},
54+
'pymakr.listCommands': () => {
55+
panelView.showQuickPick()
56+
},
57+
'pymakr.connect': () => {
58+
terminal.show()
59+
pymakr.connect()
60+
},
61+
'pymakr.run': () => {
62+
terminal.show()
63+
pymakr.run()
64+
},
65+
'pymakr.runselection': () => {
66+
terminal.show()
67+
pymakr.runselection()
68+
},
69+
'pymakr.upload': () => {
70+
terminal.show()
71+
pymakr.upload()
72+
},
73+
'pymakr.uploadFile': () => {
74+
terminal.show()
75+
pymakr.uploadFile()
76+
},
77+
'pymakr.download': () => {
78+
terminal.show()
79+
pymakr.download()
80+
},
81+
'pymakr.globalSettings': () => {
82+
pymakr.openGlobalSettings()
83+
},
84+
'pymakr.projectSettings': () => {
85+
pymakr.openProjectSettings()
86+
},
87+
'pymakr.disconnect': () => {
88+
pymakr.disconnect()
89+
},
90+
'pymakr.toggleConnect': () => {
91+
if (!pymakr.pyboard.connected)
92+
terminal.show()
93+
pymakr.toggleConnect()
94+
},
95+
'pymakr.extra.getVersion': () => {
96+
terminal.show()
97+
pymakr.getVersion()
98+
},
99+
'pymakr.extra.getWifiMac': () => {
103100
terminal.show()
101+
pymakr.getWifiMac()
102+
},
103+
'pymakr.extra.getSerial': () => {
104+
terminal.show()
105+
pymakr.getSerial()
104106
}
105-
pymakr.toggleConnect()
106-
});
107-
context.subscriptions.push(disposable);
108-
109-
110-
var disposable = vscode.commands.registerCommand('pymakr.extra.getVersion', function () {
111-
terminal.show()
112-
pymakr.getVersion()
113-
});
114-
context.subscriptions.push(disposable);
115-
116-
var disposable = vscode.commands.registerCommand('pymakr.extra.getWifiMac', function () {
117-
terminal.show()
118-
pymakr.getWifiMac()
119-
});
120-
context.subscriptions.push(disposable);
121-
122-
var disposable = vscode.commands.registerCommand('pymakr.extra.getSerial', function () {
123-
terminal.show()
124-
pymakr.getSerial()
125-
});
126-
context.subscriptions.push(disposable);
107+
})
127108

128109
}
129110

130111
})
131-
132-
}
133-
134-
135-
136-
function deactivate() {
137-
v.destroy()
138112
}
139113

140-
141114
module.exports = {
142115
activate,
143-
deactivate
116+
deactivate: () => destroyHandles.map(destroy => destroy())
144117
}
145118

settings.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The majority of the sessing can be specified in both the global config file as w
1010
| ctrl_c_on_connect| yes | yes | false | If true, executes a ctrl-c on connect to stop running programs
1111
||||
1212
| auto_connect | no | yes | true | Autoconnect on USB. Ignores any \'address\' setting and automatically connects to the top item in the serialport list
13-
| autoconnect_comport_manufacturers| no | yes | 'Pycom','Pycom Ltd.','FTDI', 'Microsoft','Microchip Technology, Inc.'| Comma separated list of all the comport manufacturers supported for the autoconnect feature. Defaults to all possible manufacturers that pycom boards can return.
13+
| autoconnect_comport_manufacturers| no | yes | 'Pycom','Pycom Ltd.','FTDI', 'Microsoft','Microchip Technology, Inc.', '1a86'| Comma separated list of all the comport manufacturers supported for the autoconnect feature. Defaults to all possible manufacturers that pycom boards can return.
1414
||||
1515
| sync_folder | yes | yes | "" | Folder to synchronize. Empty to sync projects main folder
1616
| sync_file_types | yes | yes | "py,txt,log,json,xml,html,js, css,mpy" | Types of files to be synchronized

0 commit comments

Comments
 (0)