Skip to content

Commit

Permalink
Migration for 1.42.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieudutour committed Oct 26, 2022
1 parent 40cc6ce commit 28c362e
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 24 deletions.
4 changes: 2 additions & 2 deletions migrations/1.31.0/index.ts
Original file line number Diff line number Diff line change
@@ -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") {
Expand Down Expand Up @@ -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]);
Expand Down
2 changes: 2 additions & 0 deletions migrations/1.42.0/command.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Update node types
npm install --save-dev @types/node@18.8.3 --force
11 changes: 11 additions & 0 deletions migrations/1.42.0/index.ts
Original file line number Diff line number Diff line change
@@ -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();
}
32 changes: 16 additions & 16 deletions migrations/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions migrations/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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"
}
}
6 changes: 3 additions & 3 deletions migrations/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand All @@ -58,11 +58,11 @@ export function addImport(j: JSCodeshift, root: Collection<any>, 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
);
Expand Down

0 comments on commit 28c362e

Please sign in to comment.