Repository: FHIR/sushi
Pull request #229 (2020-02-17 20:21:57)

Minor ig config changes
Renames the index page title to "Home" and sets the IG JSON `copyrightyear` and `releaselabel` parameters based on the `ig.ini` values for `copyrightyear` and `ballotstatus` (respectively).


Patch:
diff --git a/src/ig/IGExporter.ts b/src/ig/IGExporter.ts
index 8c8838f..917d960 100644
--- a/src/ig/IGExporter.ts
+++ b/src/ig/IGExporter.ts
@@ -102,11 +102,11 @@ export class IGExporter {
         parameter: [
           {
             code: 'copyrightyear',
-            value: `${new Date().getFullYear()}+` // TODO: Make this configurable
+            value: '' // Gets set when ig.ini is processed
           },
           {
             code: 'releaselabel',
-            value: 'CI Build' // TODO: Make this configurable
+            value: '' // Gets set when ig.ini is processed
           },
           {
             code: 'show-inherited-invariants',
@@ -206,7 +206,7 @@ export class IGExporter {
     // Add user-provided or generated index file to IG definition
     this.ig.definition.page.page.push({
       nameUrl: 'index.html',
-      title: this.ig.title,
+      title: 'Home',
       generation
     });
   }
@@ -461,6 +461,12 @@ export class IGExporter {
       }
     }
 
+    // Update the corresponding parameters in the ImplementationGuide JSON
+    const copyrightParam = this.ig.definition.parameter.find(p => p.code === 'copyrightyear');
+    copyrightParam.value = iniObj.copyrightyear;
+    const releaseParam = this.ig.definition.parameter.find(p => p.code === 'releaselabel');
+    releaseParam.value = iniObj.ballotstatus;
+
     // Finally, write it to disk
     outputFileSync(
       path.join(igPath, 'ig.ini'),


Test patch:
diff --git a/test/ig/IGExporter.test.ts b/test/ig/IGExporter.test.ts
index a86d4bd..f26f087 100644
--- a/test/ig/IGExporter.test.ts
+++ b/test/ig/IGExporter.test.ts
@@ -208,7 +208,7 @@ describe('IGExporter', () => {
             page: [
               {
                 nameUrl: 'index.html',
-                title: 'FSH Test IG',
+                title: 'Home',
                 generation: 'markdown'
               }
             ]
@@ -355,6 +355,20 @@ describe('IGExporter', () => {
       });
     });
 
+    it('should reflect the user-provided copyrightyear and ballotstatus as IG parameters', () => {
+      const igPath = path.join(tempOut, 'input', 'ImplementationGuide-sushi-test.json');
+      expect(fs.existsSync(igPath)).toBeTruthy();
+      const igContent = fs.readJSONSync(igPath);
+      expect(igContent.definition.parameter).toContainEqual({
+        code: 'copyrightyear',
+        value: '2018+'
+      });
+      expect(igContent.definition.parameter).toContainEqual({
+        code: 'releaselabel',
+        value: 'STU1'
+      });
+    });
+
     it('should use the user-provided index.md if it exists', () => {
       const indexPath = path.join(tempOut, 'input', 'pagecontent', 'index.md');
       expect(fs.existsSync(indexPath)).toBeTruthy();
@@ -367,7 +381,7 @@ describe('IGExporter', () => {
       const igContent = fs.readJSONSync(igPath);
       expect(igContent.definition.page.page).toContainEqual({
         nameUrl: 'index.html',
-        title: 'FSH Test IG',
+        title: 'Home',
         generation: 'markdown'
       });
     });
@@ -409,7 +423,7 @@ describe('IGExporter', () => {
       expect(igContent.definition.page.page).toEqual([
         {
           nameUrl: 'index.html',
-          title: 'FSH Test IG',
+          title: 'Home',
           generation: 'markdown'
         },
         {
@@ -461,7 +475,7 @@ describe('IGExporter', () => {
       expect(igContent.definition.page.page).toEqual([
         {
           nameUrl: 'index.html',
-          title: 'FSH Test IG',
+          title: 'Home',
           generation: 'html'
         }
       ]);
@@ -603,7 +617,7 @@ describe('IGExporter', () => {
       expect(igContent.definition.page.page).toEqual([
         {
           nameUrl: 'index.html',
-          title: 'FSH Test IG',
+          title: 'Home',
           generation: 'html'
         },
         {
@@ -693,7 +707,7 @@ describe('IGExporter', () => {
       expect(igContent.definition.page.page).toEqual([
         {
           nameUrl: 'index.html',
-          title: 'FSH Test IG',
+          title: 'Home',
           generation: 'html'
         },
         {