-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
148 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
const fs = require('fs') | ||
const { resolve } = require('bluebird'); | ||
|
||
// récupère le nom du fichier de configuration | ||
sFichierConfig = process.argv[2] | ||
|
||
|
||
// Récupère la configuration du connecteur | ||
// stUnElement = JSON.parse(fs.readFileSync(sFichierConfig)) | ||
|
||
stUnElement = JSON.parse('{"source": "/Users/marcpolycarpe/Documents/Sources/Cozy/konnectors/plugins/aprr/src/index.js","folder_to_save": "/Users/marcpolycarpe/Documents/Documents/APRR/","login": "250091389862","password": "mp0682969580"}') | ||
|
||
stOptions = {} | ||
|
||
// Construit la structure avec les options | ||
stOptions.COZY_URL = "https://localhost" | ||
stOptions.fields = {} | ||
stOptions.fields.login = stUnElement.login | ||
stOptions.fields.password = stUnElement.password | ||
stOptions.folder_to_save = stUnElement.folder_to_save | ||
stOptions.fields.folderPath = stUnElement.folder_to_save | ||
if (stUnElement.others) | ||
{ | ||
stUnElement.others.forEach(stAddon => { | ||
stOptions.fields[stAddon.name] = stAddon.value | ||
}); | ||
} | ||
|
||
process.env.COZY_FIELDS = JSON.stringify(stOptions) | ||
|
||
// Importe le connecteur | ||
require(stUnElement.source) | ||
|
||
// Supprime le fichier | ||
// fs.unlinkSync(sFichierConfig) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,31 @@ | ||
const path = require('path') | ||
const fs = require('fs') | ||
const child_process = require('child_process') | ||
var uuid = require('uuid'); | ||
|
||
async function DownloadDocuments() | ||
function DownloadDocuments(sNomPlugin) | ||
{ | ||
// Liste les connecteurs | ||
ConnectorsList = JSON.parse(fs.readFileSync(__dirname + '/connectors_list.json')) | ||
|
||
// Chaque connecteur a son fichier JSON "konnector-dev-config.json" dans son répertoire | ||
// Ajoute les données de ce fichier a la variable d'environnement | ||
|
||
ConnectorsList.forEach(stUnElement => { | ||
stOptions = {} | ||
// Construit la structure avec les options | ||
stOptions.COZY_URL = "https://localhost" | ||
stOptions.fields = {} | ||
stOptions.fields.login = stUnElement.login | ||
stOptions.fields.password = stUnElement.password | ||
stOptions.folder_to_save = stUnElement.folder_to_save | ||
stOptions.fields.folderPath = stUnElement.folder_to_save | ||
if (stUnElement.others) | ||
{ | ||
stUnElement.others.forEach(stAddon => { | ||
stOptions.fields[stAddon.name] = stAddon.value | ||
}); | ||
} | ||
|
||
process.env.COZY_FIELDS = JSON.stringify(stOptions) | ||
if (sNomPlugin != '' && stUnElement.name != sNomPlugin) | ||
return | ||
|
||
// Sauvegarde un fichier de config | ||
|
||
// Charge l'élément et débute la récupération | ||
element = require(stUnElement.source) | ||
// Construit le nom du fichier | ||
sNomFichier = uuid.v4() + '.json' | ||
|
||
// On décharge l'élément pour pouvoir utiliser plusieurs fois le même connecteur | ||
var name = require.resolve(stUnElement.source); | ||
delete require.cache[name]; | ||
fs.writeFileSync(sNomFichier, JSON.stringify(stUnElement)) | ||
|
||
// Lancement d'un autre process | ||
|
||
child_process.execSync( | ||
'node ' + __dirname + '/DownloadDocument_StandAlone.js "'+sNomFichier + '"', | ||
{stdio: 'inherit'}) | ||
}) | ||
} | ||
|
||
} | ||
module.exports = DownloadDocuments |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters