Skip to content

Commit

Permalink
Merge branch 'release' into feat/eslint/eslint-package
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushpahwa committed Nov 21, 2024
2 parents 23543c3 + b113cf7 commit 22e7cc8
Show file tree
Hide file tree
Showing 42 changed files with 976 additions and 385 deletions.
34 changes: 19 additions & 15 deletions app/client/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,23 @@ module.exports = {
],
roots: ["<rootDir>/src"],
transform: {
"^.+\\.(png|js|ts|tsx)$": "ts-jest",
"^.+\\.(png|js|ts|tsx)$": [
"ts-jest",
{
isolatedModules: true,
diagnostics: {
ignoreCodes: [1343],
},
astTransformers: {
before: [
{
path: "node_modules/ts-jest-mock-import-meta",
options: { metaObjectReplacement: { url: "https://www.url.com" } },
},
],
},
}
],
},
testEnvironment: "jsdom",
testTimeout: 9000,
Expand Down Expand Up @@ -52,22 +68,10 @@ module.exports = {
"<rootDir>/node_modules/@blueprintjs/select/lib/esnext",
"@appsmith/ads": "<rootDir>/node_modules/@appsmith/ads",
"^canvas$": "jest-canvas-mock",
"^entities/(.*)$": "<rootDir>/src/entities/$1", // Match 'entities/*'

},
globals: {
"ts-jest": {
isolatedModules: true,
diagnostics: {
ignoreCodes: [1343],
},
astTransformers: {
before: [
{
path: "node_modules/ts-jest-mock-import-meta",
options: { metaObjectReplacement: { url: "https://www.url.com" } },
},
],
},
},
APPSMITH_FEATURE_CONFIGS: {
sentry: {
dsn: parseConfig("__APPSMITH_SENTRY_DSN__"),
Expand Down
8 changes: 4 additions & 4 deletions app/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@
"@types/deep-diff": "^1.0.0",
"@types/dom-view-transitions": "^1.0.5",
"@types/downloadjs": "^1.4.2",
"@types/jest": "^27.4.1",
"@types/jest": "^29.5.3",
"@types/jshint": "^2.12.0",
"@types/lodash": "^4.14.120",
"@types/mixpanel-browser": "^2.50.1",
Expand Down Expand Up @@ -330,9 +330,9 @@
"eslint-plugin-testing-library": "^6.2.0",
"factory.ts": "^0.5.1",
"husky": "^8.0.0",
"jest": "^27.4.1",
"jest": "^29.6.1",
"jest-canvas-mock": "^2.3.1",
"jest-environment-jsdom": "^27.4.1",
"jest-environment-jsdom": "^29.6.1",
"jest-styled-components": "^7.0.8",
"json5": "^2.2.3",
"knip": "^5.30.2",
Expand All @@ -355,7 +355,7 @@
"redux-devtools-extension": "^2.13.8",
"redux-mock-store": "^1.5.4",
"redux-saga-test-plan": "^4.0.6",
"ts-jest": "29.1.0",
"ts-jest": "^29.1.0",
"ts-jest-mock-import-meta": "^0.12.0",
"ts-node": "^10.9.1",
"xlsx": "https://cdn.sheetjs.com/xlsx-0.19.3/xlsx-0.19.3.tgz"
Expand Down
16 changes: 8 additions & 8 deletions app/client/packages/ast/src/actionCreator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ export const setCallbackFunctionField = (
currentValueAstWithComments,
0,
undefined,
(type, node) => isCallExpressionNode(node),
(_type, node) => isCallExpressionNode(node),
);

if (found) {
Expand Down Expand Up @@ -717,7 +717,7 @@ export const replaceActionInQuery = (
});

simple(astWithComments, {
CallExpression(node) {
CallExpression(node: Node) {
if (
isCallExpressionNode(node) &&
isMemberExpressionNode(node.callee) &&
Expand Down Expand Up @@ -989,7 +989,7 @@ export function getThenCatchBlocksFromQuery(
astWithComments,
0,
undefined,
function (type, node) {
function (_type, node) {
if (isCallExpressionNode(node)) {
if (isMemberExpressionNode(node.callee)) {
if (node.callee.object === rootCallExpression) {
Expand Down Expand Up @@ -1020,7 +1020,7 @@ export function getThenCatchBlocksFromQuery(
}

const secondBlockType = firstBlockType === "then" ? "catch" : "then";
const secondBlock = findNodeAt(ast, 0, undefined, function (type, node) {
const secondBlock = findNodeAt(ast, 0, undefined, function (_type, node) {
if (isCallExpressionNode(node)) {
if (isMemberExpressionNode(node.callee)) {
if (node.callee.object === firstBlock) {
Expand Down Expand Up @@ -1073,7 +1073,7 @@ export function setThenBlockInQuery(
astWithComments,
0,
undefined,
function (type, node) {
function (_type, node) {
if (isCallExpressionNode(node)) {
if (isMemberExpressionNode(node.callee)) {
if (node.callee.object === rootCallExpression) {
Expand Down Expand Up @@ -1117,7 +1117,7 @@ export function setThenBlockInQuery(
astWithComments,
0,
undefined,
function (type, node) {
function (_type, node) {
if (isCallExpressionNode(node)) {
if (isMemberExpressionNode(node.callee)) {
if (node.callee.object === rootCallExpression) {
Expand Down Expand Up @@ -1393,7 +1393,7 @@ function findNodeWithCalleeAndProperty(
) {
if (!ast || !callee || !property) return undefined;

return findNodeAt(ast, 0, undefined, function (type, node) {
return findNodeAt(ast, 0, undefined, function (_type, node) {
if (isCallExpressionNode(node)) {
if (isMemberExpressionNode(node.callee)) {
if (node.callee.object === callee) {
Expand Down Expand Up @@ -1431,7 +1431,7 @@ export function getFunctionParams(code: string, evaluationVersion: number) {

export function getQueryParam(
code: string,
number: number,
_number: number,
evaluationVersion: number,
) {
try {
Expand Down
2 changes: 1 addition & 1 deletion app/client/packages/ast/src/jsObject/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const parseJSObject = (code: string) => {
let JSObjectProperties: NodeWithLocation<PropertyNode>[] = [];

simple(ast, {
ExportDefaultDeclaration(node) {
ExportDefaultDeclaration(node: Node) {
if (
!isExportDefaultDeclarationNode(node) ||
!isObjectExpression(node.declaration)
Expand Down
3 changes: 3 additions & 0 deletions app/client/packages/git/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": ["../../.eslintrc.base.json"]
}
15 changes: 15 additions & 0 deletions app/client/packages/git/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "@appsmith/git",
"description": "This package contains all the git related functionality for Appsmith UI",
"private": true,
"version": "1.0.0",
"main": "src/index.ts",
"scripts": {
"lint": "yarn g:lint",
"prettier": "yarn g:prettier",
"test:unit": "yarn g:jest --passWithNoTests"
},
"dependencies": {
"@reduxjs/toolkit": "^2.3.0"
}
}
26 changes: 26 additions & 0 deletions app/client/packages/git/src/actions/commitActions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { createSingleArtifactAction } from "./helpers/createSingleArtifactAction";
import type { GitArtifactPayloadAction } from "../types";

export const commitInitAction = createSingleArtifactAction((state) => {
state.commit.loading = true;
state.commit.error = null;

return state;
});

export const commitSuccessAction = createSingleArtifactAction((state) => {
state.commit.loading = false;

return state;
});

export const commitErrorAction = createSingleArtifactAction(
(state, action: GitArtifactPayloadAction<{ error: string }>) => {
const { error } = action.payload;

state.commit.loading = false;
state.commit.error = error;

return state;
},
);
26 changes: 26 additions & 0 deletions app/client/packages/git/src/actions/connectActions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { createSingleArtifactAction } from "./helpers/createSingleArtifactAction";
import type { GitArtifactPayloadAction } from "../types";

export const connectInitAction = createSingleArtifactAction((state) => {
state.connect.loading = true;
state.connect.error = null;

return state;
});

export const connectSuccessAction = createSingleArtifactAction((state) => {
state.connect.loading = false;

return state;
});

export const connectErrorAction = createSingleArtifactAction(
(state, action: GitArtifactPayloadAction<{ error: string }>) => {
const { error } = action.payload;

state.connect.loading = false;
state.connect.error = error;

return state;
},
);
29 changes: 29 additions & 0 deletions app/client/packages/git/src/actions/fetchBranchesActions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import type { GitArtifactPayloadAction, GitBranches } from "../types";
import { createSingleArtifactAction } from "./helpers/createSingleArtifactAction";

export const fetchBranchesInitAction = createSingleArtifactAction((state) => {
state.branches.loading = true;
state.branches.error = null;

return state;
});

export const fetchBranchesSuccessAction = createSingleArtifactAction(
(state, action: GitArtifactPayloadAction<{ branches: GitBranches }>) => {
state.branches.loading = false;
state.branches.value = action.payload.branches;

return state;
},
);

export const fetchBranchesErrorAction = createSingleArtifactAction(
(state, action: GitArtifactPayloadAction<{ error: string }>) => {
const { error } = action.payload;

state.branches.loading = false;
state.branches.error = error;

return state;
},
);
29 changes: 29 additions & 0 deletions app/client/packages/git/src/actions/fetchMetadataActions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import type { GitArtifactPayloadAction, GitMetadata } from "../types";
import { createSingleArtifactAction } from "./helpers/createSingleArtifactAction";

export const fetchMetadataInitAction = createSingleArtifactAction((state) => {
state.metadata.loading = true;
state.metadata.error = null;

return state;
});

export const fetchMetadataSuccessAction = createSingleArtifactAction(
(state, action: GitArtifactPayloadAction<{ metadata: GitMetadata }>) => {
state.metadata.loading = false;
state.metadata.value = action.payload.metadata;

return state;
},
);

export const fetchMetadataErrorAction = createSingleArtifactAction(
(state, action: GitArtifactPayloadAction<{ error: string }>) => {
const { error } = action.payload;

state.metadata.loading = false;
state.metadata.error = error;

return state;
},
);
29 changes: 29 additions & 0 deletions app/client/packages/git/src/actions/fetchStatusActions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import type { GitArtifactPayloadAction, GitStatus } from "../types";
import { createSingleArtifactAction } from "./helpers/createSingleArtifactAction";

export const fetchStatusInitAction = createSingleArtifactAction((state) => {
state.status.loading = true;
state.status.error = null;

return state;
});

export const fetchStatusSuccessAction = createSingleArtifactAction(
(state, action: GitArtifactPayloadAction<{ status: GitStatus }>) => {
state.status.loading = false;
state.status.value = action.payload.status;

return state;
},
);

export const fetchStatusErrorAction = createSingleArtifactAction(
(state, action: GitArtifactPayloadAction<{ error: string }>) => {
const { error } = action.payload;

state.status.loading = false;
state.status.error = error;

return state;
},
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import type {
GitArtifactPayloadAction,
GitArtifactReduxState,
GitSingleArtifactReduxState,
} from "../../types";

type SingleArtifactStateCb<T> = (
singleArtifactState: GitSingleArtifactReduxState,
action: GitArtifactPayloadAction<T>,
) => GitSingleArtifactReduxState;

export const gitSingleArtifactInitialState: GitSingleArtifactReduxState = {
metadata: {
value: null,
loading: false,
error: null,
},
connect: {
loading: false,
error: null,
},
branches: {
value: null,
loading: false,
error: null,
},
status: {
value: null,
loading: false,
error: null,
},
commit: {
loading: false,
error: null,
},
pull: {
loading: false,
error: null,
},
};

export const createSingleArtifactAction = <T>(
singleArtifactStateCb: SingleArtifactStateCb<T>,
) => {
return (
state: GitArtifactReduxState,
action: GitArtifactPayloadAction<T>,
) => {
const { artifactType, baseArtifactId } = action.payload;

state[artifactType] ??= {};
state[artifactType][baseArtifactId] ??= gitSingleArtifactInitialState;

const singleArtifactState = state[artifactType][baseArtifactId];

state[artifactType][baseArtifactId] = singleArtifactStateCb(
singleArtifactState,
action,
);

return state;
};
};
Loading

0 comments on commit 22e7cc8

Please sign in to comment.