diff --git a/package.json b/package.json index 94e1ccf..760a04d 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,23 @@ "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "dev": "npx webpack --watch", - "build": "npx webpack --config webpack.config.prod.js" + "build": "npx webpack --config webpack.config.prod.js", + "compile": "pkg ." + }, + "pkg": { + "scripts": [ + "dist/**/*.js", + "node_modules/node-pty/**/*.js" + ], + "assets": [ + "dist/example.yaml", + "dist/ngi-sync-agent-linux.tar.gz" + ], + "targets": [ + "node14-win-x64", + "node14-linux" + ], + "outputPath": "dist_prod" }, "author": "", "license": "ISC", diff --git a/src/app/load_save/services/LoadSaveDataService.ts b/src/app/load_save/services/LoadSaveDataService.ts index 6b4b724..17781b3 100644 --- a/src/app/load_save/services/LoadSaveDataService.ts +++ b/src/app/load_save/services/LoadSaveDataService.ts @@ -228,14 +228,15 @@ export default BaseService.extend({ let _fileName = _config._filename; let bodyData: any = readFileSync(_fileName); bodyData = YAML.parse(bodyData.toString()) as any; - bodyData.saved_file_name = whatFileName + '.yaml'; - writeFileSync(this._baseAppPathFolder + '/.sync_collections/' + bodyData.saved_file_name, YAML.stringify(bodyData, null), 'utf8'); + bodyData.saved_file_name = whatFileName+'.yaml'; + whatFileName = upath.basename(whatFileName,".yaml"); + writeFileSync(this._baseAppPathFolder + '/.sync_collections/' + whatFileName+'.yaml', YAML.stringify(bodyData, null), 'utf8'); /* Add sync_ignore can self by owner ngi-sync */ if (existsSync(".sync_ignore")) { let syncIgnoreData = readFileSync(".sync_ignore").toString(); writeFileSync(this._baseAppPathFolder + '/.sync_collections/' + whatFileName + ".sync_ignore", syncIgnoreData, 'utf8'); } - console.log(`${this._baseAppPathFolder + '/.sync_collections/' + bodyData.saved_file_name} is created!`); + console.log(`${this._baseAppPathFolder + '/.sync_collections/' + whatFileName+'.yaml'} is created!`); } catch (ex) { console.error('createNewSave - ex ', ex); } @@ -262,12 +263,13 @@ export default BaseService.extend({ deleteDataSave: function () { try { let { target_delete } = this._completeData; - unlinkSync(this._baseAppPathFolder + '/.sync_collections/' + target_delete + '.yaml'); + let whatFileName = upath.basename(target_delete,".yaml"); + unlinkSync(this._baseAppPathFolder + '/.sync_collections/' + whatFileName + '.yaml'); /* Delete sync_ignore can self by owner ngi-sync */ - if (existsSync(this._baseAppPathFolder + "/.sync_collections/" + target_delete + ".sync_ignore")) { - unlinkSync(this._baseAppPathFolder + '/.sync_collections/' + target_delete + ".sync_ignore"); + if (existsSync(this._baseAppPathFolder + "/.sync_collections/" + whatFileName + ".sync_ignore")) { + unlinkSync(this._baseAppPathFolder + '/.sync_collections/' + whatFileName + ".sync_ignore"); } - console.log(`${this._baseAppPathFolder + '/.sync_collections/' + target_delete + '.yaml'} is deleted!`); + console.log(`${this._baseAppPathFolder + '/.sync_collections/' + whatFileName + '.yaml'} is deleted!`); } catch (ex) { console.error('deleteDataSave - ex ', ex); }