Skip to content

Commit 3284d23

Browse files
authored
Merge pull request #6 from devdotnetorg/dev
Dev => Master
2 parents ba852e1 + 70536a9 commit 3284d23

12 files changed

+147
-68
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## v0.3.1 (27-02-2023)
4+
5+
- Bugs fixed.
6+
37
## v0.3.0 (24-02-2023)
48

59
- Added support for using templates for projects, including custom ones.

CHANGELOG_ru.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## v0.3.1 (27-02-2023)
4+
5+
- Исправлены ошибки.
6+
37
## v0.3.0 (24-02-2023)
48

59
- Добавлена поддержка использования шаблонов для проектов, включая пользовательские.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ Devices supported: Raspberry Pi, Banana Pi, Orange Pi, Radxa, Tinkerboard, Odroi
1212

1313
*.NET FastIoT Extension UI*
1414

15-
![.NET FastIoT title](https://raw.githubusercontent.com/devdotnetorg/vscode-extension-dotnet-fastiot/dev/docs/vscode-dotnet-fastiot.png)
15+
![.NET FastIoT title](docs/vscode-dotnet-fastiot.png)
1616

17-
![.NET FastIoT interface](https://raw.githubusercontent.com/devdotnetorg/vscode-extension-dotnet-fastiot/dev/docs/vscode-dotnet-fastiot-interface.png)
17+
![.NET FastIoT interface](docs/vscode-dotnet-fastiot-interface.png)
1818

1919
## Features
2020

bashscript/installpackagemono.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# chmod +x installpackagemono.sh
44
# ./installpackagemono.sh
55

6+
#Page - https://www.mono-project.com/download/stable/#download-lin
7+
68
set -e #Exit immediately if a comman returns a non-zero status
79

810
echo "Run: installpackagemono.sh"

bashscript/uninstallpackagemono.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,14 @@ sudo apt-get purge -y mono-complete
1515
sudo apt-get autoremove -y --purge mono-complete
1616
#
1717

18+
#file exist $filename
19+
declare filename="/etc/apt/sources.list.d/mono-official-stable.list"
20+
21+
#removal
22+
if [ -f $filename ]; then
23+
#rm
24+
sudo rm $filename
25+
fi
26+
#
27+
1828
echo "Successfully"

package.json

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,25 @@
55
"icon": "assets/fastiot-logo-256.png",
66
"license": "LGPL-3.0-only",
77
"preview": true,
8-
"version": "0.3.0",
9-
"overview": "assets/marketplace/vscode-marketplace-overview.md",
10-
"priceCategory": "free",
8+
"version": "0.3.1",
119
"publisher": "devdotnetorg",
1210
"private": "false",
1311
"identity": {
1412
"internalName": "vscode-extension-dotnet-fastiot"
1513
},
14+
"categories": [
15+
"Programming Languages",
16+
"Other"
17+
],
1618
"keywords": [
1719
"dotnet",
1820
"C#",
1921
"IoT",
20-
"Board",
22+
"Linux",
23+
"Embedded",
2124
"Raspberry",
2225
"Remote",
23-
"Debugging",
24-
"SBC"
26+
"Debugging"
2527
],
2628
"engines": {
2729
"vscode": "^1.70.3"
@@ -35,10 +37,6 @@
3537
"url": "https://github.com/devdotnetorg/vscode-extension-dotnet-fastiot/issues",
3638
"email": "[email protected]"
3739
},
38-
"categories": [
39-
"Programming Languages",
40-
"Other"
41-
],
4240
"activationEvents": [
4341
"onView:viewDevices",
4442
"onCommand:vscode-extension-dotnet-fastiot.helloWorld"

src/Entity/EntityBase.ts

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,17 @@ export abstract class EntityBase<T extends EntityBaseAttribute> {
7373
public Move(destDir:string):IotResult {
7474
let result:IotResult;
7575
try {
76-
//clear
77-
if (fs.existsSync(destDir)) fs.emptyDirSync(destDir);
78-
//mkdir
79-
IoTHelper.MakeDirSync(destDir);
76+
//delete
77+
if (fs.existsSync(destDir))
78+
{
79+
fs.emptyDirSync(destDir);
80+
fs.removeSync(destDir);
81+
}
82+
//destDir - no need to create a folder
8083
fs.moveSync(this.ParentDir,destDir);
8184
//replace fields
82-
this._descFilePath=`${destDir}\\${this.ParentNameDir}`;
85+
const fileName=this._descFilePath.substring(this.ParentDir.length+1);
86+
this._descFilePath= path.join(destDir, fileName);
8387
result = new IotResult(StatusResult.Ok,undefined,undefined);
8488
} catch (err: any){
8589
result = new IotResult(StatusResult.Error,`Unable to move ${this._entityIntLabel} from folder ${this.ParentDir} to folder ${destDir}`,err);
@@ -88,6 +92,23 @@ export abstract class EntityBase<T extends EntityBaseAttribute> {
8892
return result;
8993
}
9094

95+
public Remove ():IotResult {
96+
let result:IotResult;
97+
try {
98+
//delete
99+
if (fs.existsSync(this.ParentDir))
100+
{
101+
fs.emptyDirSync(this.ParentDir);
102+
fs.removeSync(this.ParentDir);
103+
}
104+
result = new IotResult(StatusResult.Ok,`Folder has been deleted: ${this.ParentDir}`);
105+
} catch (err: any){
106+
result = new IotResult(StatusResult.Error,`Unable to delete template folder: ${this.ParentDir}`,err);
107+
}
108+
//result
109+
return result;
110+
}
111+
91112
public Compare1(entityBase:EntityBase<T>):number{
92113
//0 - equal, 1 - entityBase up, -1 - entityBase down
93114
return this.Compare2(entityBase.Type,entityBase.Attributes.Version);

src/Entity/EntityDownloader.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ export abstract class EntityDownloader {
2121
await networkHelper.DownloadFileHttp(item.Url,fileZipPath);
2222
//unpack
2323
let unpackPath=`${destPath}\\${item.Id}`;
24+
//delete
25+
if (fs.existsSync(unpackPath))
26+
{
27+
fs.emptyDirSync(unpackPath);
28+
fs.removeSync(unpackPath);
29+
}
2430
var AdmZip = require("adm-zip");
2531
var zip = new AdmZip(fileZipPath);
2632
// extracts everything

src/IotDevicePackage.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,11 @@ export class IotDevicePackage extends BaseTreeItem {
198198
element = new IotDevicePackage(vscode.TreeItemCollapsibleState.None,this,this.Device);
199199
element.InitPackage(TypePackage.dotnetruntimes,undefined);
200200
this.Childs.push(element);
201+
/* Mono
201202
element = new IotDevicePackage(vscode.TreeItemCollapsibleState.None,this,this.Device);
202203
element.InitPackage(TypePackage.mono,undefined);
203204
this.Childs.push(element);
205+
*/
204206
element = new IotDevicePackage(vscode.TreeItemCollapsibleState.None,this,this.Device);
205207
element.InitPackage(TypePackage.debugger,undefined);
206208
this.Childs.push(element);

src/Templates/IotTemplate.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ export class IotTemplate extends EntityBase<IotTemplateAttribute> {
4646
let result = filesValidator.ValidateFiles(this.ParentDir,"template.files.schema.json");
4747
const validationErrors=<Array<string>>result.returnObject;
4848
this._validationErrors = validationErrors.slice();
49-
49+
//check id=""
50+
if (this.Attributes.Id=="") this._validationErrors.push("id cannot be empty");
5051
// TODO: проверка наличия файлов для dotnetapp.csproj которые внутри
5152
}
5253

@@ -144,12 +145,11 @@ export class IotTemplate extends EntityBase<IotTemplateAttribute> {
144145
this.Attributes.FileNameReplacement.forEach((value,key) => {
145146
const oldPath=dstPath+"\\"+IoTHelper.ReverseSeparatorLinuxToWin(key);
146147
value=IoTHelper.MergeWithDictionary(this._mergeDictionary,value);
148+
const newPath=dstPath+"\\"+IoTHelper.ReverseSeparatorLinuxToWin(value);
149+
fs.renameSync(oldPath,newPath);
147150
//replace in FilesToProcess
148151
let indexItem=this.Attributes.FilesToProcess.indexOf(key);
149152
if(indexItem>-1) this.Attributes.FilesToProcess[indexItem]=value;
150-
//
151-
const newPath=dstPath+"\\"+IoTHelper.ReverseSeparatorLinuxToWin(value);
152-
fs.renameSync(oldPath,newPath);
153153
//tracking the renaming of the main project file
154154
if(IoTHelper.GetFileExtensions(newPath)==this.Attributes.ExtMainFileProj)
155155
{

src/Templates/IotTemplateAttribute.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export class IotTemplateAttribute extends EntityBaseAttribute {
6868
//arrays
6969
let index=0;
7070
//filesToProcess
71+
this._filesToProcess=[];
7172
index=0;
7273
do {
7374
let item=obj.filesToProcess[index];
@@ -79,6 +80,7 @@ export class IotTemplateAttribute extends EntityBaseAttribute {
7980
}
8081
while(true)
8182
//fileNameReplacement
83+
this._fileNameReplacement= new Map<string,string>();
8284
index=0;
8385
do {
8486
let item=obj.fileNameReplacement[index];

src/Templates/IotTemplateCollection.ts

Lines changed: 77 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export class IotTemplateCollection extends EntityCollection<IotTemplateAttribute
7070
//checking all folders
7171
listFolders.forEach(dir => {
7272
const filePath=`${dir}\\template.fastiot.yaml`;
73-
this.LogCallback(`Template initialization: ${filePath}`);
73+
//this.LogCallback(`Template initialization: ${filePath}`);
7474
let template = new IotTemplate(this._pathFolderSchemas);
7575
template.Init(type,filePath,recoverySourcePath);
7676
if(!template.IsValid&&type==EntityType.system)
@@ -82,7 +82,7 @@ export class IotTemplateCollection extends EntityCollection<IotTemplateAttribute
8282
{
8383
template.Init(type,filePath,recoverySourcePath);
8484
}else{
85-
this.LogCallback(`${result.Status}. ${result.Message}. ${result.SystemMessage}`);
85+
this.LogCallback(`Error. Template restore error. ${result.Message}. ${result.SystemMessage}`);
8686
}
8787
}
8888
//main
@@ -96,7 +96,7 @@ export class IotTemplateCollection extends EntityCollection<IotTemplateAttribute
9696
switch(isContains) {
9797
case ContainsType.no: {
9898
this.Add(template.Attributes.Id,template);
99-
this.LogCallback(`Template added: ${filePath}`);
99+
this.LogCallback(`Template added: [${template.Attributes.Id}] ${filePath}`);
100100
break;
101101
}
102102
case ContainsType.yesVersionSmaller: {
@@ -116,6 +116,11 @@ export class IotTemplateCollection extends EntityCollection<IotTemplateAttribute
116116
}else{
117117
this.LogCallback(`Error. The template ${template.DescriptionFilePath} has not been validated`);
118118
this.LogValidationErrors(template.ValidationErrors);
119+
//delete system template
120+
if(type==EntityType.system) {
121+
result= template.Remove();
122+
this.LogCallback(`${result.Status}. ${result.Message}. ${result.SystemMessage}`);
123+
}
119124
}
120125
});
121126
//result
@@ -152,54 +157,79 @@ export class IotTemplateCollection extends EntityCollection<IotTemplateAttribute
152157
return Promise.resolve(result);
153158
}
154159
//next
155-
listDownload.forEach(async (item) => {
156-
if(this.IsCompatible2(item.ForVersionExt,item.platform))
157-
{
158-
const isContains=this.Contains2(item.Id,EntityType.system,item.Version);
159-
switch(isContains) {
160-
case ContainsType.no: {
161-
result= await downloader.DownloadTemplate(item,tempPath);
162-
if(result.Status==StatusResult.Ok)
163-
{
164-
const unpackPath= <string> result.returnObject;
165-
let template=new IotTemplate(this._pathFolderSchemas);
166-
template.Init(EntityType.system,unpackPath,undefined);
167-
if(template.IsValid)
168-
{
169-
template.Move(destPath);
170-
this.Add(template.Attributes.Id,template);
171-
} else {
172-
this.LogCallback(`Error. The template ${template.DescriptionFilePath} has not been validated`);
173-
this.LogValidationErrors(template.ValidationErrors);
160+
let index:number=0;
161+
do{
162+
let item = listDownload[index];
163+
if(item)
164+
{
165+
//parse
166+
if(this.IsCompatible2(item.ForVersionExt,item.platform))
167+
{
168+
const isContains=this.Contains2(item.Id,EntityType.system,item.Version);
169+
switch(isContains) {
170+
case ContainsType.no: {
171+
result= await downloader.DownloadTemplate(item,tempPath);
172+
if(result.Status==StatusResult.Ok)
173+
{
174+
const unpackPath= <string> result.returnObject;
175+
const filePath = path.join(unpackPath, "template.fastiot.yaml");
176+
let template=new IotTemplate(this._pathFolderSchemas);
177+
template.Init(EntityType.system,filePath,undefined);
178+
if(template.IsValid)
179+
{
180+
result=template.Move(path.join(destPath, template.Attributes.Id));
181+
if(result.Status==StatusResult.Error)
182+
{
183+
this.LogCallback(`Error. The template ${template.DescriptionFilePath}. ${result.Message}. ${result.SystemMessage}`);
184+
break;
185+
}
186+
this.Add(template.Attributes.Id,template);
187+
this.LogCallback(`Template added: [${template.Attributes.Id}] ${template.DescriptionFilePath}`);
188+
} else {
189+
this.LogCallback(`Error. The template ${template.DescriptionFilePath} has not been validated`);
190+
this.LogValidationErrors(template.ValidationErrors);
191+
}
192+
}
193+
break;
174194
}
175-
}
176-
break;
177-
}
178-
case ContainsType.yesVersionSmaller: {
179-
result= await downloader.DownloadTemplate(item,tempPath);
180-
if(result.Status==StatusResult.Ok)
181-
{
182-
const unpackPath= <string> result.returnObject;
183-
let template=new IotTemplate(this._pathFolderSchemas);
184-
template.Init(EntityType.system,unpackPath,undefined);
185-
if(template.IsValid)
186-
{
187-
template.Move(destPath);
188-
this.Update(template.Attributes.Id,template);
195+
case ContainsType.yesVersionSmaller: {
196+
result= await downloader.DownloadTemplate(item,tempPath);
197+
if(result.Status==StatusResult.Ok)
198+
{
199+
const unpackPath= <string> result.returnObject;
200+
const filePath = path.join(unpackPath, "template.fastiot.yaml");
201+
let template=new IotTemplate(this._pathFolderSchemas);
202+
template.Init(EntityType.system,filePath,undefined);
203+
if(template.IsValid)
204+
{
205+
result=template.Move(path.join(destPath, template.Attributes.Id));
206+
if(result.Status==StatusResult.Error)
207+
{
208+
this.LogCallback(`Error. The template ${template.DescriptionFilePath}. ${result.Message}. ${result.SystemMessage}`);
209+
break;
210+
}
211+
this.Update(template.Attributes.Id,template);
212+
this.LogCallback(`Template updated: [${template.Attributes.Id}] ${template.DescriptionFilePath}`);
213+
} else {
214+
this.LogCallback(`Error. The template ${template.DescriptionFilePath} has not been validated`);
215+
this.LogValidationErrors(template.ValidationErrors);
216+
}
217+
}
218+
break;
189219
}
220+
default: {
221+
//statements;
222+
break;
223+
}
190224
}
191-
break;
192-
}
193-
default: {
194-
//statements;
195-
break;
196-
}
225+
}else{
226+
this.LogCallback(`Error. The template ${item.Url} is for a newer version of the extension.` +
227+
`Update the extension.`);
197228
}
198-
}else{
199-
this.LogCallback(`Error. The template ${item.Url} is for a newer version of the extension.` +
200-
`Update the extension.`);
201-
}
202-
});
229+
//
230+
}else break;
231+
index++;
232+
}while(true)
203233
//result
204234
result= new IotResult(StatusResult.Ok,undefined,undefined);
205235
return Promise.resolve(result);

0 commit comments

Comments
 (0)