From 28c362e92e68248e38403d9f6f063e4db2952fe9 Mon Sep 17 00:00:00 2001 From: mathieudutour Date: Wed, 26 Oct 2022 13:27:12 +0200 Subject: [PATCH] Migration for 1.42.0 --- migrations/1.31.0/index.ts | 4 ++-- migrations/1.42.0/command.sh | 2 ++ migrations/1.42.0/index.ts | 11 +++++++++++ migrations/package-lock.json | 32 ++++++++++++++++---------------- migrations/package.json | 6 +++--- migrations/utils.ts | 6 +++--- 6 files changed, 37 insertions(+), 24 deletions(-) create mode 100644 migrations/1.42.0/command.sh create mode 100644 migrations/1.42.0/index.ts diff --git a/migrations/1.31.0/index.ts b/migrations/1.31.0/index.ts index 46762556c4a..bd8a7f7fb64 100644 --- a/migrations/1.31.0/index.ts +++ b/migrations/1.31.0/index.ts @@ -1,4 +1,4 @@ -import { API, FileInfo, Transform } from "jscodeshift"; +import { API, FileInfo, Transform, ObjectProperty } from "jscodeshift"; const tryGetAccessoryTitle = (attribute) => { if (attribute?.name?.name === "accessoryTitle") { @@ -30,7 +30,7 @@ const transform: Transform = (file: FileInfo, api: API) => { return; } - const objectExpressionProperties = []; + const objectExpressionProperties: ObjectProperty[] = []; for (let i = 0; i < p.parent.node.attributes.length; i++) { let shouldDeleteNode = false; const textValue = tryGetAccessoryTitle(p.parent.node.attributes[i]); diff --git a/migrations/1.42.0/command.sh b/migrations/1.42.0/command.sh new file mode 100644 index 00000000000..f981bfeeaf3 --- /dev/null +++ b/migrations/1.42.0/command.sh @@ -0,0 +1,2 @@ +# Update node types +npm install --save-dev @types/node@18.8.3 --force diff --git a/migrations/1.42.0/index.ts b/migrations/1.42.0/index.ts new file mode 100644 index 00000000000..156eabddc6d --- /dev/null +++ b/migrations/1.42.0/index.ts @@ -0,0 +1,11 @@ +import { API, FileInfo } from "jscodeshift"; +import { renameJSXProp } from "../utils"; + +export default function transform(file: FileInfo, api: API) { + const j = api.jscodeshift; + const root = j(file.source); + + renameJSXProp(j, root, "Grid", "enableFiltering", "filtering"); + + return root.toSource(); +} diff --git a/migrations/package-lock.json b/migrations/package-lock.json index 91b232043e1..5edcd49188c 100644 --- a/migrations/package-lock.json +++ b/migrations/package-lock.json @@ -1,22 +1,22 @@ { "name": "@raycast/migration", - "version": "1.38.2", + "version": "1.42.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@raycast/migration", - "version": "1.38.2", + "version": "1.42.0", "license": "MIT", "dependencies": { "jscodeshift": "^0.13.1", - "semver": "^7.3.5" + "semver": "^7.3.8" }, "bin": { "migration": "bin/migrate.js" }, "devDependencies": { - "@types/jscodeshift": "^0.11.3" + "@types/jscodeshift": "^0.11.5" } }, "node_modules/@ampproject/remapping": { @@ -1718,9 +1718,9 @@ } }, "node_modules/@types/jscodeshift": { - "version": "0.11.3", - "resolved": "https://registry.npmjs.org/@types/jscodeshift/-/jscodeshift-0.11.3.tgz", - "integrity": "sha512-pM0JD9kWVDH9DQp5Y6td16924V3MwZHei8P3cTeuFhXpzpk0K+iWraBZz8wF61QkFs9fZeAQNX0q8SG0+TFm2w==", + "version": "0.11.5", + "resolved": "https://registry.npmjs.org/@types/jscodeshift/-/jscodeshift-0.11.5.tgz", + "integrity": "sha512-7JV0qdblTeWFigevmwFUgROXX395F+MQx6v0YqPn8Bx0B4Sng6alEejz9PENzgLYpG+zL0O4tGdBzc4gKZH8XA==", "dev": true, "dependencies": { "ast-types": "^0.14.1", @@ -3560,9 +3560,9 @@ } }, "node_modules/semver": { - "version": "7.3.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", - "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", + "version": "7.3.8", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", + "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", "dependencies": { "lru-cache": "^6.0.0" }, @@ -5346,9 +5346,9 @@ } }, "@types/jscodeshift": { - "version": "0.11.3", - "resolved": "https://registry.npmjs.org/@types/jscodeshift/-/jscodeshift-0.11.3.tgz", - "integrity": "sha512-pM0JD9kWVDH9DQp5Y6td16924V3MwZHei8P3cTeuFhXpzpk0K+iWraBZz8wF61QkFs9fZeAQNX0q8SG0+TFm2w==", + "version": "0.11.5", + "resolved": "https://registry.npmjs.org/@types/jscodeshift/-/jscodeshift-0.11.5.tgz", + "integrity": "sha512-7JV0qdblTeWFigevmwFUgROXX395F+MQx6v0YqPn8Bx0B4Sng6alEejz9PENzgLYpG+zL0O4tGdBzc4gKZH8XA==", "dev": true, "requires": { "ast-types": "^0.14.1", @@ -6751,9 +6751,9 @@ } }, "semver": { - "version": "7.3.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", - "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", + "version": "7.3.8", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", + "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", "requires": { "lru-cache": "^6.0.0" } diff --git a/migrations/package.json b/migrations/package.json index 0a1b9b5048c..e7c70ba6291 100644 --- a/migrations/package.json +++ b/migrations/package.json @@ -1,6 +1,6 @@ { "name": "@raycast/migration", - "version": "1.41.1", + "version": "1.42.0", "description": "Tool to automate the migration to a newer version of the @raycast/api", "main": "index.js", "bin": "./bin/migrate.js", @@ -15,9 +15,9 @@ }, "dependencies": { "jscodeshift": "^0.13.1", - "semver": "^7.3.5" + "semver": "^7.3.8" }, "devDependencies": { - "@types/jscodeshift": "^0.11.3" + "@types/jscodeshift": "^0.11.5" } } diff --git a/migrations/utils.ts b/migrations/utils.ts index d74aeeebab0..79e0e3ad125 100644 --- a/migrations/utils.ts +++ b/migrations/utils.ts @@ -47,7 +47,7 @@ export function removeImport( .find(j.ImportDeclaration, { source: { value: "@raycast/api" } }) .replaceWith((p) => j.importDeclaration( - p.node.specifiers.filter((x) => x.local?.name !== name), + p.node.specifiers?.filter((x) => x.local?.name !== name), p.node.source, p.node.importKind ) @@ -58,11 +58,11 @@ export function addImport(j: JSCodeshift, root: Collection, name: string) { root .find(j.ImportDeclaration, { source: { value: "@raycast/api" } }) .replaceWith((p) => { - if (p.node.specifiers.some((x) => x.local?.name === name)) { + if (p.node.specifiers?.some((x) => x.local?.name === name)) { return p.node; } return j.importDeclaration( - p.node.specifiers.concat(j.importSpecifier(j.identifier(name))), + p.node.specifiers?.concat(j.importSpecifier(j.identifier(name))), p.node.source, p.node.importKind );