Auto-upgrade TypeScript

JSON pattern

An example illustrating the upgrade_dependency utility function, which upgrades a dependency to a specified semantic version in package.json, or adds it if it is not present.

This example upgrades Typescript to v5.0.3.


Apply with the Grit CLI
grit apply auto_upgrade

Upgrades an existing dependency

BEFORE
{
  "name": "@getgrit/api",
  "version": "0.1.0",
  "license": "UNLICENSED",
  "description": "A shared API for interacting with Grit workflows.",
  "type": "commonjs",
  "exports": {
    ".": "./dist/index.js"
  },
  "private": true,
  "files": ["/dist"],
  "dependencies": {
    "diff": "^5.1.0",
    "@types/diff": "^5.0.2",
    "@getgrit/internal": "*",
    "typescript": "4.7.0",
    "winston": "^3.8.2"
  },
  "eslintConfig": {}
}
AFTER
{
  "name": "@getgrit/api",
  "version": "0.1.0",
  "license": "UNLICENSED",
  "description": "A shared API for interacting with Grit workflows.",
  "type": "commonjs",
  "exports": {
    ".": "./dist/index.js"
  },
  "private": true,
  "files": ["/dist"],
  "dependencies": {
    "diff": "^5.1.0",
    "@types/diff": "^5.0.2",
    "@getgrit/internal": "*",
    "typescript": "5.0.3",
    "winston": "^3.8.2"
  },
  "eslintConfig": {}
}

Adds a new dependency

BEFORE
{
  "name": "@getgrit/api",
  "version": "0.1.0",
  "license": "UNLICENSED",
  "description": "A shared API for interacting with Grit workflows.",
  "type": "commonjs",
  "exports": {
    ".": "./dist/index.js"
  },
  "private": true,
  "files": ["/dist"],
  "dependencies": {
    "diff": "^5.1.0",
    "@types/diff": "^5.0.2",
    "@getgrit/internal": "*",
    "winston": "^3.8.2"
  },
  "eslintConfig": {}
}
AFTER
{
  "name": "@getgrit/api",
  "version": "0.1.0",
  "license": "UNLICENSED",
  "description": "A shared API for interacting with Grit workflows.",
  "type": "commonjs",
  "exports": {
    ".": "./dist/index.js"
  },
  "private": true,
  "files": ["/dist"],
  "dependencies": {
    "typescript": "5.0.3",
"diff": "^5.1.0",
    "@types/diff": "^5.0.2",
    "@getgrit/internal": "*",
    "winston": "^3.8.2"
  },
  "eslintConfig": {}
}