{"_id":"@benwatsonuk/govuk-versioning-plugin","_rev":"2-85bc962399def4c07804fc180f384e04","name":"@benwatsonuk/govuk-versioning-plugin","dist-tags":{"latest":"1.1.0"},"versions":{"1.0.0":{"name":"@benwatsonuk/govuk-versioning-plugin","version":"1.0.0","author":{"name":"BenWatsonUK"},"license":"MIT","_id":"@benwatsonuk/govuk-versioning-plugin@1.0.0","maintainers":[{"name":"benwatsonuk","email":"hello@benwatson.eu"}],"homepage":"https://github.com/benwatsonuk/govuk-versioning-plugin","bugs":{"url":"https://github.com/benwatsonuk/govuk-versioning-plugin/issues"},"dist":{"shasum":"1d33c6bc0bddd6fa84023b7dcfc6ead67a4e4d2c","tarball":"https://registry.npmjs.org/@benwatsonuk/govuk-versioning-plugin/-/govuk-versioning-plugin-1.0.0.tgz","fileCount":47,"integrity":"sha512-TDoGvkhSN4DrlwLDiEB6Uso3yQ8jh73z1Hel3I+WbRt0mzwt+DQiegBvr2LdoHz2Iow/Iu9krfoH+h1gr8NBMA==","signatures":[{"sig":"MEUCIQC9uw9/56JrxUuITxAQlrh4emnc3gS1/OXDY850xB1D9QIgCXcIJT2hI40ggYEo8nF0LrNOtRrxFeWy4qB3aPLYHR0=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":49711},"main":"dist/index.js","gitHead":"3967f1bb910c21a0d38e91824b2f84034a128f2e","scripts":{"test":"mocha --require ts-node/register","build":"npm run clean && tsc && cpx \"src/templates/**/*\" dist/templates","clean":"rimraf dist"},"_npmUser":{"name":"benwatsonuk","email":"hello@benwatson.eu"},"repository":{"url":"git+https://github.com/benwatsonuk/govuk-versioning-plugin.git","type":"git"},"_npmVersion":"11.6.2","description":"A plugin to programmatically create new versions of an opinionated directory structure within the GOVUK prototype kit.","directories":{},"_nodeVersion":"25.2.1","dependencies":{"ajv":"^8.17.1","cpx":"^1.5.0","express":"^4.18.2","nunjucks":"^3.2.4"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"nyc":"^15.1.0","chai":"^4.3.7","mocha":"^10.2.0","rimraf":"^6.1.2","ts-node":"^10.9.2","typescript":"^5.9.3","@types/node":"^25.6.0","@types/mocha":"^10.0.10","@types/express":"^5.0.6","json-schema-to-typescript":"^15.0.4"},"_npmOperationalInternal":{"tmp":"tmp/govuk-versioning-plugin_1.0.0_1778233357088_0.31350858821718086","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"@benwatsonuk/govuk-versioning-plugin","author":{"name":"BenWatsonUK"},"description":"A plugin to programmatically create new versions of an opinionated directory structure within the GOVUK prototype kit.","version":"1.1.0","main":"dist/index.js","homepage":"https://github.com/benwatsonuk/govuk-versioning-plugin","bugs":{"url":"https://github.com/benwatsonuk/govuk-versioning-plugin/issues"},"repository":{"type":"git","url":"git+https://github.com/benwatsonuk/govuk-versioning-plugin.git"},"scripts":{"test":"mocha --require ts-node/register","clean":"rimraf dist","build":"npm run clean && tsc && cpx \"app/**/*\" dist/app/"},"dependencies":{"ajv":"^8.17.1","cpx":"^1.5.0","express":"^4.18.2","nunjucks":"^3.2.4"},"devDependencies":{"@types/express":"^5.0.6","@types/mocha":"^10.0.10","@types/node":"^25.6.0","chai":"^4.3.7","json-schema-to-typescript":"^15.0.4","mocha":"^10.2.0","nyc":"^15.1.0","rimraf":"^6.1.2","ts-node":"^10.9.2","typescript":"^5.9.3"},"license":"MIT","publishConfig":{"access":"public"},"gitHead":"f4a9868f8c4bf5f3b9dce65530dd95771c0a2117","_id":"@benwatsonuk/govuk-versioning-plugin@1.1.0","_nodeVersion":"25.2.1","_npmVersion":"11.6.2","dist":{"integrity":"sha512-jInxnf4lNvQx0c6CWAoCsfEoDp8tnYjlpCTdlO41+5BiihBnK1Hj2pV24a1Pka+gDfuWBpK1Uq/qEi/rsDdZhA==","shasum":"4d5a1df7f9b29a16a78bc7826b2aeed9e36c764f","tarball":"https://registry.npmjs.org/@benwatsonuk/govuk-versioning-plugin/-/govuk-versioning-plugin-1.1.0.tgz","fileCount":51,"unpackedSize":56052,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQC0yZgrtqSw4cqpdZUUkB6qzIDJx51TsBLIH+vDgfwhXQIgKvtb5vTWeHCOa2EEbQVLVEF5k1tifLjxb35wG6yuSUg="}]},"_npmUser":{"name":"benwatsonuk","email":"hello@benwatson.eu"},"directories":{},"maintainers":[{"name":"benwatsonuk","email":"hello@benwatson.eu"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/govuk-versioning-plugin_1.1.0_1778243041187_0.8765773641169168"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-08T09:42:36.980Z","modified":"2026-05-08T12:24:01.740Z","1.0.0":"2026-05-08T09:42:37.229Z","1.1.0":"2026-05-08T12:24:01.340Z"},"bugs":{"url":"https://github.com/benwatsonuk/govuk-versioning-plugin/issues"},"author":{"name":"BenWatsonUK"},"license":"MIT","homepage":"https://github.com/benwatsonuk/govuk-versioning-plugin","repository":{"type":"git","url":"git+https://github.com/benwatsonuk/govuk-versioning-plugin.git"},"description":"A plugin to programmatically create new versions of an opinionated directory structure within the GOVUK prototype kit.","maintainers":[{"name":"benwatsonuk","email":"hello@benwatson.eu"}],"readme":"# govuk-versioning-plugin\nA plugin for GOVUK Prototype Kit that allows authors to programmatically create new versions (iterations) within the prototype based upon a specified series of source directories.\n\nYou'll be able to duplicate specified files and directories and update necessary parts of them e.g directory names, file names, variables or strings within the files themselves.\n\nYou'll be able to do this all from the terminal.\n\n## Install the plugin: \n\n`npm install --save @benwatsonuk/govuk-versioning-plugin`\n\n## Create a 'versions.js' file\n\nYou will need to set up a file in the root directory named `versions.js`, this will contain the different versions within the prototype (and be automatically updated in future) and also contain the configuration details for the plugin. \n\nThe plugin itself will validate these before executing the update, but it is important that the settings are correct\n\nSee the types file to see what is required... https://github.com/benwatsonuk/govuk-versioning-plugin/blob/main/src/types.ts\n\nOr take a look at the sample file and copy and paste this... https://github.com/benwatsonuk/govuk-versioning-plugin/blob/main/stest/example-versions.js \n\n### Versions array\n\nThis is an array of current versions, each version must have the following structure:\n\n```\nexport type Version = {\n  iteration: number;\n  version: string;\n  phase?: string;\n  name?: string;\n  notes?: string | null;\n  createdOn: string;\n}\n```\n\n### Config object\n\nThis in an object with the following structure:\n\n```\nexport type Config = {\n  phase?: string;\n  version: string;\n  itemsToClone: ItemToClone[];\n  itemsToUpdate?: ItemToUpdate[];\n}\n```\n\nFor reference, here are the objects for the `itemsToClone` and `itemsToUpdate` arrays:\n\n```\nexport type ItemToClone = {\n  type: \"file\" | \"directory\";\n  path: string;\n}\n\nexport type ItemToUpdate = {\n  path: string;\n  find: string;\n  type: \"add\" | \"replace\";\n  value: string;\n}\n```\n\nThe `phase` and `version` are the current/most recent versions and phase and this is automatically updated by the plugin after setup.\n\n`itemsToClone` specify the files and directories that the plugin will duplicate for the next version.\n\n`itemsToUpdate` specify the items that need to be modified and details the rules that are to be applied. Target items use `find` to identify a point in a file and use the `type` to identify whether to replace the string or add the `value` after the target.\n\nHere is an example of the full file (version.js):\n\n```\n// This file is used by the govuk-versioning-plugin\n// Do not delete or modify this file unless you know what you are doing! Read the plugin's ReadMe for more information\n\nexport const versions = [\n  {\n    iteration: 0,\n    phase: 'private-beta',\n    version: 'v0',\n    name: 'Baseline Version',\n    notes: 'The initial version of the service, scrape of the production interfaces as of December 2025.',\n    createdOn: '2025-12-10T00:00:00.000Z'\n  }\n]\n\nexport const config = {\n  phase: 'private-beta',\n  version: 'v0',\n  itemsToClone: [\n    {\n      type: 'directory',\n      path: 'app/views/${oldPhase}/${oldVersion}/'\n    },\n    {\n      type: 'file',\n      path: 'app/routes/${oldPhase}/${oldVersion}.js'\n    }\n  ],\n  itemsToUpdate: [\n    {\n      path: 'app/routes.js',\n      type: 'add',\n      find: \"router.use('/', ${oldVersion}Routes)\",\n      value: \"router.use('/', ${newVersion}Routes)\"\n    },\n    {\n      path: 'app/routes/${newPhase}/${newVersion}.js',\n      type: 'replace',\n      find: \"const verNum = ${oldVersion.replace('v', '')}\",\n      value: \"const verNum = ${newVersion.replace('v', '')}\"\n    }\n  ]\n}\n```\n\n## Add the script to execute the plugin\n\nYou will need to a script to your project, which you will call in the next steps.\n\nSee https://github.com/benwatsonuk/govuk-versioning-plugin/blob/main/test/example-version-plugin.js for the file to copy.\n\nPlace this somewhere that suits you, for example `scripts/version-plugin.js` and make sure that you are correctly referencing your `versions.js` file.\n\nHere is what the example file uses:\n\n```\nconst versionPlugin = require('@benwatsonuk/govuk-versioning-plugin').default\nconst { config, versions } = require('../versions')\n\nasync function main () {\n  const tool = versionPlugin(config, versions)\n\n  await tool.run()\n}\n\nmain().catch(console.error)\n```\n\n\n## Add a command to package.json to run the script\n\nAdd something similar to the following to your `package.json`, what you call the script is up to you and you must reference the correct path to the script in your project.\n\n`\"scripts\": {\n    \"plugin:version\": \"node scripts/version-plugin.js\"\n}`\n\n## Run the script\n\nThen you run:\n\n`npm run plugin:version` \n\nOr whatever you have named the script.\n\nThe plugin will validate the `versions.js` file before anything is executed.\n\nThen you will be prompted to enter a number of values, the plugin will make suggestions which you can except or alter.\n\nThat's it... once it is running, it should save you some time when bumping prototype versions.\n\n\n# Using the components to dynamicallty display an index\n\nYou can use a provided component to display the versions for example on the protoype index page. The index component has three flavours, `list`, `table` and `accordion`.\n\nThe `hrefPrefix` informs the component of the path to use for links.\n\n`versions` must provide the verions object from your `versions.js` file.\n\n`type` is a list by default, but can be configured `accordion` and `table` also.\n\nYou can use it as follows:\n\n```\n    {% from \"govuk-versioning-plugin/components/version-list/macro.njk\" import versionList %}\n\n    {{ versionList({\n        type: 'table',\n        hrefPrefix: '/${phase}/${version}/',\n        versions: versions.versions\n    }) }}\n```","readmeFilename":"README.md"}