psi-header icon indicating copy to clipboard operation
psi-header copied to clipboard

change tracking not working

Open st-clair-clarke opened this issue 1 year ago • 4 comments

I am having some difficulty trying to get the change tracking to work: Below is my psi settings.json content

 "psi-header.config": {
   "author": "Dr St Clair S Clarke",
   "authorEmail": "[email protected]",
   "blankLinesAfter": 2,
   "company": "Medsoft (http://medsoft.healthcare)",
   "copyrightHolder": "Dr St Clair S Clarke",
   "creationDateZero": "asIs",
   "forceToTop": true,
   "initials": "SCSC",
   "license": "CustomUri"
 },
 "psi-header.templates": [
   {
     "language": "*",
     "template": [
       "* File: <<filename>>",
       "  File Relative Path: <<filerelativepath>>",
       "* Project: <<projectname>>",
       "  Project Version: <<projectversion>>",
       "* Created: <<filecreated('YYYY-MM-DD, H:mm:ss a')
       "* Author: <<author>> (<<authoremail>>)",
       "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       "* Last Modified: <<dateformat('YYYY-MM-DD, H:mm:s
       "* Modified By: <<author>> (<<authoremail>>>)",
       "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       "* Copyright © 2015 - <<yeartoyear(fc!P, now)>> | 
       "  All rights reserved.",
       "  Use of this source code is governed by the lice
       "  LICENSE file. Removal of or alteration of the L
       "  voids or negate its original contents."
     ]
   }
 ],
 "psi-header.variables": [
   [
     "projectCreationYear",
     "2015"
   ]
 ],
 "psi-header.changes-tracking": {
   "autoHeader": "autoSave",
   "enforceHeader": true,
   "exclude": [
     "jsonc",
     "json"
   ],
   "excludeGlob": [
     "**/settings.json",
     "./**/*/ignoreme.*"
   ],
   "include": [],
   "includeGlob": [],
   "isActive": true,
   "modAuthor": "Modified By:",
   "modDate": "* Last Modified: ",
   "modDateFormat": "<<dateformat('YYYY-MM-DD, H:mm:ss a'
   "replace": [
     "** Last Modified:",
     "filename",
     "filerelativepath",
     "projectname",
     "projectversion",
     "modAuthor",
     "modDate"
   ],
   "updateLicenseVariables": false
 },
 "psi-header.lang-config": [
   {
     "afterHeader": [],
     "beforeHeader": [],
     "begin": "/**",
     "blankLinesAfter": 2,
     "end": "*/",
     "forceToTop": true,
     "ignoreLines": [],
     "language": "javascript",
     "lineLength": 80,
     "modAuthor": "** Last Modified:",
     "modDate": "* Last Modified: ",
     "modDateFormat": "<<dateformat('YYYY-MM-DD, H:mm:ss 
     "prefix": "*",
     "replace": [
       "** Last Modified:",
       "filename",
       "filerelativepath",
       "projectname",
       "projectversion",
       "modAuthor",
       "modDate"
     ],
     "rootDirFileName": "package.json",
     "suffix": " *"
   },
   {
     "language": "typescript",
     "mapTo": "javascript"
   },
   {
     "language": "css",
     "mapTo": "javascript"
   },
   {
     "language": "scss",
     "mapTo": "javascript"
   },
   {
     "afterHeader": [],
     "beforeHeader": [],
     "begin": "##",
     "blankLinesAfter": 2,
     "end": "##",
     "forceToTop": true,
     "ignoreLines": [],
     "language": "python",
     "lineLength": 80,
     "modAuthor": "* Modified By:",
     "modDate": "* Last Modified: ",
     "modDateFormat": "<<dateformat('YYYY-MM-DD, H:mm:ss 
     "prefix": "#",
     "replace": [
       "filename",
       "filerelativepath",
       "projectname",
       "projectversion",
       "modAuthor",
       "modDate"
     ],
     "rootDirFileName": "package.json"
   },
   {
     "language": "plaintext",
     "mapTo": "python"
   },
   {
     "language": "elvish",
     "mapTo": "python"
   },
   {
     "language": "nushell",
     "mapTo": "python"
   },
   {
     "afterHeader": [],
     "beforeHeader": [],
     "begin": "<!--",
     "blankLinesAfter": 2,
     "end": "-->",
     "forceToTop": true,
     "ignoreLines": [],
     "language": "html",
     "lineLength": 80,
     "modAuthor": "* Modified By:",
     "modDate": "* Last Modified:",
     "modDateFormat": "yyyy-MM-dd hh:nn:ss",
     "prefix": " ",
     "replace": [
       "filename",
       "filerelativepath",
       "projectname",
       "projectversion",
       "modAuthor",
       "modDate"
     ],
     "rootDirFileName": "package.json"
   },
   {
     "language": "markdown",
     "mapTo": "html"
   }
 ],
 "psi-header.license-reference": {
   "uri": "/home/stclair/@workspace/pim/licence.md"
 },

Can you say why the contents of "psi-header.changes-tracking": is NOT working ie there is no update when the file is saved.

Thanks

st-clair-clarke avatar Jan 31 '24 00:01 st-clair-clarke

Hi,

As presented in this post, the JSON is not valid - it appears that lines longer than about 56 characters are truncated. So I am not sure if the problem is with your settings file or just with the cut & paste into this post.

But I did notice a few other things...

(1) You are using a single template (which is good), so you can simplify your settings somewhat by removing the following lang-config properties as they are not necessary: modAuthor, modDate, modDateFormat and replace. For your use case, they are just duplicating settings already in the changes-tracking section and they cloud the issues you are having because they are subtly (and I think unintentionally) inconsistent between changes-tracking and lang-config. If you do indeed want different replacement behaviour for different languages, you can include these, but it doesn't look to me like that is what you want.

(2) Ignoring the truncation issue mentioned above, the changes-tracking.modDateFormat property is not valid. It should just include a MomentJS date format string:

// actual
     "modDateFormat": "<<dateformat('YYYY-MM-DD, H:mm:ss
// should be 
     "modDateFormat": "YYYY-MM-DD, H:mm:ss a",

(3) Each item in the replace array should include the start text of the line in the template that is to be replaced (excluding the lang-config.prefix). You just need to provide enough of the line to ensure it is unique within the generated template. So (assuming you followed (1) and removed replace from each lang-config), based on your template:

// actual
"replace": [
     "** Last Modified:",
     "filename",
     "filerelativepath",
     "projectname",
     "projectversion",
     "modAuthor",
     "modDate"
   ],
// should be
"replace": [
     "* Last Modified:",
     "  File:",
     "  File Relative Path:",
     "  Project:",
     "  Project Version:",
     "* Modified By:"
   ],

(4) Because the "Last Modified" and "Modified By" lines are in the replace array, you could also remove the following properties from changes-tracking: modAuthor, modDate and modDateFormat as they are not required.

HTH D

davidquinn avatar Jan 31 '24 08:01 davidquinn

Thanks for your quick reply. However, I made the changes but the change tracking is not working. Below is my current settings as suggested:

 "psi-header.config": {
    "author": "Dr St Clair S Clarke",
    "authorEmail": "[email protected]",
    "blankLinesAfter": 2,
    "company": "Medsoft (http://medsoft.healthcare)",
    "copyrightHolder": "Dr St Clair S Clarke",
    "creationDateZero": "asIs",
    "forceToTop": true,
    "initials": "SCSC",
    "license": "CustomUri"
  },
  "psi-header.templates": [
    {
      "language": "*",
      "template": [
        "* File: <<filename>>",
        "  File Relative Path: <<filerelativepath>>",
        "* Project: <<projectname>>",
        "  Project Version: <<projectversion>>",
        "* Created: <<filecreated('YYYY-MM-DD, H:mm:ss a')>>",
        "* Author: <<author>> (<<authoremail>>)",
        "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~",
        "* Last Modified: <<dateformat('YYYY-MM-DD, H:mm:ss a')>>",
        "* Modified By: <<author>> (<<authoremail>>>)",
        "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~",
        "* Copyright © 2015 - <<yeartoyear(fc!P, now)>> | <<company>>",
        "  All rights reserved.",
        "  Use of this source code is governed by the license found in  the",
        "  LICENSE file. Removal of or alteration of the LICENSE file in no way",
        "  voids or negate its original contents."
      ]
    }
  ],
  "psi-header.variables": [
    [
      "projectCreationYear",
      "2015"
    ]
  ],
  "psi-header.changes-tracking": {
    "autoHeader": "autoSave",
    "enforceHeader": true,
    "exclude": [
      "jsonc",
      "json"
    ],
    "excludeGlob": [
      "**/settings.json",
      "./**/*/ignoreme.*"
    ],
    "include": [],
    "includeGlob": [],
    "isActive": true,
    "replace": [
      "* File:",
      "  File Relative Path:",
      "* Project:",
      "  Project Version:",
      "* Last Modified:",
      "* Modified By:",
    ],
    "updateLicenseVariables": false
  },
  "psi-header.lang-config": [
    {
      "afterHeader": [],
      "beforeHeader": [],
      "begin": "/**",
      "blankLinesAfter": 2,
      "end": "*/",
      "forceToTop": true,
      "ignoreLines": [],
      "language": "javascript",
      "lineLength": 80,
      "prefix": "*",
      "rootDirFileName": "package.json",
      "suffix": " *"
    },
    {
      "language": "typescript",
      "mapTo": "javascript"
    },
    {
      "language": "css",
      "mapTo": "javascript"
    },
    {
      "language": "scss",
      "mapTo": "javascript"
    },
    {
      "afterHeader": [],
      "beforeHeader": [],
      "begin": "##",
      "replace": [
        "* File:",
        "  File Relative Path:",
        "* Project:",
        "  Project Version:",
        "* Last Modified:",
        "* Modified By:",
      ],
      "blankLinesAfter": 2,
      "end": "##",
      "forceToTop": true,
      "ignoreLines": [],
      "language": "python",
      "lineLength": 80,
      "prefix": "#",
      "rootDirFileName": "package.json"
    },
    {
      "language": "plaintext",
      "mapTo": "python"
    },
    {
      "language": "elvish",
      "mapTo": "python"
    },
    {
      "language": "nushell",
      "mapTo": "python"
    },
    {
      "afterHeader": [],
      "beforeHeader": [],
      "begin": "<!--",
      "blankLinesAfter": 2,
      "end": "-->",
      "forceToTop": true,
      "ignoreLines": [],
      "language": "html",
      "lineLength": 80,
      "prefix": " ",
      "rootDirFileName": "package.json"
    },
    {
      "language": "markdown",
      "mapTo": "html"
    }
  ],
  "psi-header.license-reference": {
    "uri": "/home/stclair/@workspace/pim/licence.md"
  },

Thanks.

st-clair-clarke avatar Feb 01 '24 02:02 st-clair-clarke