format is not the same for fixtures
authorymh <ymh.work@gmail.com>
Thu, 25 Feb 2016 11:21:09 +0100
changeset 131 31a5c314d575
parent 130 fac22d8c2df8
child 132 d97eda8bc8ec
format is not the same for fixtures
cms/app-client/app/mirage/fixtures/documents.js
cms/app-client/package.json
common/corpus-common-addon/lib/commands/dl-fixtures.js
server/bo_client/package.json
--- a/cms/app-client/app/mirage/fixtures/documents.js	Thu Feb 25 10:20:01 2016 +0100
+++ b/cms/app-client/app/mirage/fixtures/documents.js	Thu Feb 25 11:21:09 2016 +0100
@@ -1,4 +1,4 @@
-module.exports = [
+export default [
   {
     "id": "corpusparole:crdo-09-CAYCHAX_SOUND",
     "uri": "http://corpusdelaparole.huma-num.fr/corpus/res/crdo-09-CAYCHAX_SOUND",
--- a/cms/app-client/package.json	Thu Feb 25 10:20:01 2016 +0100
+++ b/cms/app-client/package.json	Thu Feb 25 11:21:09 2016 +0100
@@ -11,7 +11,7 @@
     "build": "ember build --environment=production",
     "start": "ember serve --environment=development",
     "test": "ember test",
-    "dl-fixtures": "ember dl-fixtures -u http://127.0.0.1:8000/api/v1/documents/ -d app/mirage/fixtures/documents.js -p 2"
+    "dl-fixtures": "ember dl-fixtures -u http://127.0.0.1:8000/api/v1/documents/ -d app/mirage/fixtures/documents.js -p 2 -f es6"
   },
   "repository": "",
   "engines": {
--- a/common/corpus-common-addon/lib/commands/dl-fixtures.js	Thu Feb 25 10:20:01 2016 +0100
+++ b/common/corpus-common-addon/lib/commands/dl-fixtures.js	Thu Feb 25 11:21:09 2016 +0100
@@ -45,12 +45,14 @@
     { name: 'url',  type: String, aliases: ['u'], description: "Source url" },
     { name: 'dest', type: String, aliases: ['d'], description: "File destination"  },
     { name: 'page', type: Number, default: 1 , aliases: ['p'], description: "number of page to download"},
+    { name: 'format', type: String, default: 'es6' , aliases: ['f'], description: "Format for module export, es6 or require"},
   ],
   run: function(commandOptions, rawArgs) {
 
     //TODO: check that commandOptions.url is not empty
 
     var dest = commandOptions.dest || "." + path.sep + commandOptions.type + ".js"
+    var format = commandOptions.format || 'es6';
 
     var ids = [];
     var pageIndex = 1;
@@ -100,7 +102,8 @@
       }));
     }).then(function(res) {
       var deferred = Q.defer();
-      fs.writeFile(dest, "module.exports = " + JSON.stringify(res,null,2) + ";", function(err) {
+      var prefix = (format==='es6')?'export default ':"module.exports = ";
+      fs.writeFile(dest, prefix + JSON.stringify(res,null,2) + ";", function(err) {
         if(err) {
           return deferred.reject(err);
         }
--- a/server/bo_client/package.json	Thu Feb 25 10:20:01 2016 +0100
+++ b/server/bo_client/package.json	Thu Feb 25 11:21:09 2016 +0100
@@ -11,7 +11,7 @@
     "build": "ember build",
     "start": "ember server",
     "test": "ember test",
-    "dl-fixtures": "ember dl-fixtures -u http://127.0.0.1:8000/api/v1/documents/ -d server/fixtures/documents.js -p 2"
+    "dl-fixtures": "ember dl-fixtures -u http://127.0.0.1:8000/api/v1/documents/ -d server/fixtures/documents.js -p 2 -f require"
   },
   "repository": "",
   "engines": {