feat: unifica lo smistamento CAD su destinazione unica configurabile da UI
This commit is contained in:
83
sop.md
83
sop.md
@@ -3,7 +3,7 @@
|
||||
## Obiettivo
|
||||
Realizzare un'app desktop (.exe) che:
|
||||
- accetti una cartella o uno ZIP
|
||||
- legga file CAD (.prt .asm .drw)
|
||||
- legga file CAD (.prt .asm .dwr)
|
||||
- analizzi nome file ed estensione
|
||||
- applichi regole di routing
|
||||
- copi i file verso destinazioni configurate (anche share di rete)
|
||||
@@ -65,78 +65,18 @@ cad-file-router
|
||||
├── services
|
||||
│ ├── router.js
|
||||
│ ├── zipProcessor.js
|
||||
│ ├── folderProcessor.js
|
||||
│ └── configService.js
|
||||
│
|
||||
└── config
|
||||
└── defaultConfig.json
|
||||
│ └── folderProcessor.js
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 4. Configurazione iniziale
|
||||
## 4. Configurazione runtime
|
||||
|
||||
`config/defaultConfig.json`
|
||||
|
||||
```
|
||||
{
|
||||
"rules": [
|
||||
{
|
||||
"ext": "prt",
|
||||
"pattern": "^1",
|
||||
"destination": "\\\\SERVER-CAD\\clienti1\\PRT"
|
||||
},
|
||||
{
|
||||
"ext": "prt",
|
||||
"pattern": "^6",
|
||||
"destination": "\\\\SERVER-CAD\\clienti2\\PRT"
|
||||
},
|
||||
{
|
||||
"ext": "asm",
|
||||
"destination": "\\\\SERVER-CAD\\assembly"
|
||||
},
|
||||
{
|
||||
"ext": "drw",
|
||||
"destination": "\\\\SERVER-CAD\\drawing"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
La destinazione viene gestita in memoria in `main.js` e modificata dalla UI durante l'esecuzione.
|
||||
|
||||
---
|
||||
|
||||
## 5. Config Service
|
||||
|
||||
`services/configService.js`
|
||||
|
||||
```
|
||||
const fs = require("fs-extra")
|
||||
const path = require("path")
|
||||
const os = require("os")
|
||||
|
||||
const configPath = path.join(os.homedir(), ".cad-router-config.json")
|
||||
|
||||
function loadConfig(){
|
||||
|
||||
if(fs.existsSync(configPath)){
|
||||
return fs.readJsonSync(configPath)
|
||||
}
|
||||
|
||||
const defaultConfig = fs.readJsonSync(
|
||||
path.join(__dirname,"../config/defaultConfig.json")
|
||||
)
|
||||
|
||||
fs.writeJsonSync(configPath, defaultConfig)
|
||||
|
||||
return defaultConfig
|
||||
}
|
||||
|
||||
module.exports = { loadConfig }
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 6. Motore di routing
|
||||
## 5. Motore di routing
|
||||
|
||||
`services/router.js`
|
||||
|
||||
@@ -248,9 +188,13 @@ const path = require("path")
|
||||
|
||||
const { processFolder } = require("./services/folderProcessor")
|
||||
const { processZip } = require("./services/zipProcessor")
|
||||
const { loadConfig } = require("./services/configService")
|
||||
const CAD_EXTENSIONS = ["prt", "asm", "dwr"]
|
||||
const DEFAULT_DESTINATION = "./output/cad"
|
||||
|
||||
let config = loadConfig()
|
||||
let config = {
|
||||
destination: DEFAULT_DESTINATION,
|
||||
rules: CAD_EXTENSIONS.map((ext) => ({ ext, destination: DEFAULT_DESTINATION }))
|
||||
}
|
||||
|
||||
function createWindow(){
|
||||
|
||||
@@ -380,7 +324,7 @@ dist/
|
||||
|
||||
- l'app si avvia
|
||||
- si seleziona ZIP o cartella
|
||||
- i file .prt .asm .drw vengono analizzati
|
||||
- i file .prt .asm .dwr vengono analizzati
|
||||
- i file vengono copiati nelle destinazioni configurate
|
||||
|
||||
---
|
||||
@@ -389,8 +333,7 @@ dist/
|
||||
|
||||
- progress bar
|
||||
- drag and drop ZIP
|
||||
- modifica regole da UI
|
||||
- modifica regole avanzate da UI
|
||||
- logging operazioni
|
||||
- parallelismo file
|
||||
- watch folder automatico
|
||||
|
||||
|
||||
Reference in New Issue
Block a user