chore(gatsby-source-medusa): Cleanup plugin setup (#4419)
* chore(gatsby-source-medusa): Cleanup plugin setup * fix process-node * Create gentle-cups-crash.md
This commit is contained in:
1 parent
85eb12883e
commit
627bdb689f
14 files changed
+74
-92
No files matched your search
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"gatsby-source-medusa": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
chore(gatsby-source-medusa): Cleanup plugin setup
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
{
|
|
||||||
"presets": [["babel-preset-gatsby-package"]],
|
|
||||||
"overrides": [
|
|
||||||
{
|
|
||||||
"test": [],
|
|
||||||
"presets": [
|
|
||||||
["babel-preset-gatsby-package", { "browser": true, "esm": true }]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,13 +1,6 @@
|
|||||||
|
/dist
|
||||||
node_modules
|
node_modules
|
||||||
|
.DS_store
|
||||||
.DS_Store
|
.env*
|
||||||
|
.env
|
||||||
utils
|
*.sql
|
||||||
|
|
||||||
|
|
||||||
*.js
|
|
||||||
*.js.map
|
|
||||||
*.d.ts
|
|
||||||
!/types/*.d.ts
|
|
||||||
|
|
||||||
!jest.config.js
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
src
|
|
||||||
.prettierrc
|
|
||||||
.env
|
|
||||||
.babelrc.js
|
|
||||||
.eslintrc
|
|
||||||
.gitignore
|
|
||||||
|
|
||||||
.yarn
|
|
||||||
.turbo
|
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
module.exports = {
|
||||||
|
globals: {
|
||||||
|
"ts-jest": {
|
||||||
|
tsconfig: "tsconfig.spec.json",
|
||||||
|
isolatedModules: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
transform: {
|
||||||
|
"^.+\\.[jt]s?$": "ts-jest",
|
||||||
|
},
|
||||||
|
testEnvironment: `node`,
|
||||||
|
moduleFileExtensions: [`js`, `jsx`, `ts`, `tsx`, `json`],
|
||||||
|
}
|
||||||
@@ -4,9 +4,12 @@
|
|||||||
"description": "Gatsby source plugin for building websites using Medusa Commerce as a data source",
|
"description": "Gatsby source plugin for building websites using Medusa Commerce as a data source",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "jest --passWithNoTests",
|
"test": "jest --passWithNoTests",
|
||||||
"watch": "tsc-watch --outDir .",
|
"watch": "tsc-watch",
|
||||||
"build": "tsc --outDir ."
|
"build": "tsc"
|
||||||
},
|
},
|
||||||
|
"files": [
|
||||||
|
"dist"
|
||||||
|
],
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"gatsby",
|
"gatsby",
|
||||||
"gatsby-plugin",
|
"gatsby-plugin",
|
||||||
@@ -27,16 +30,15 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^0.24.0",
|
"axios": "^0.24.0",
|
||||||
"babel-preset-gatsby-package": "^2.0.0",
|
|
||||||
"gatsby-core-utils": "^3.3.0",
|
"gatsby-core-utils": "^3.3.0",
|
||||||
"gatsby-plugin-image": "^2.3.0",
|
"gatsby-plugin-image": "^2.3.0",
|
||||||
"gatsby-source-filesystem": "^4.3.0"
|
"gatsby-source-filesystem": "^4.3.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^27.0.1",
|
"@types/jest": "^27.0.1",
|
||||||
"babel-plugin-polyfill-corejs2": "^0.3.0",
|
|
||||||
"gatsby": "^4.1.0",
|
"gatsby": "^4.1.0",
|
||||||
"jest": "^27.0.6",
|
"jest": "^27.0.6",
|
||||||
|
"ts-jest": "^27.1.5",
|
||||||
"tsc-watch": "^4.5.0",
|
"tsc-watch": "^4.5.0",
|
||||||
"typescript": "^4.5.2"
|
"typescript": "^4.5.2"
|
||||||
},
|
},
|
||||||
|
|||||||
File renamed without changes.
+9
-9
@@ -1,20 +1,20 @@
|
|||||||
const { processNode } = require("../src/process-node.ts");
|
const { processNode } = require("../process-node.ts")
|
||||||
|
|
||||||
describe("helper functions", () => {
|
describe("helper functions", () => {
|
||||||
it("should return return a new node from processNode", () => {
|
it("should return return a new node from processNode", () => {
|
||||||
const fieldName = "product";
|
const fieldName = "product"
|
||||||
const node = {
|
const node = {
|
||||||
id: "prod_test_1234",
|
id: "prod_test_1234",
|
||||||
title: "Test Shirt",
|
title: "Test Shirt",
|
||||||
description: "A test product",
|
description: "A test product",
|
||||||
unit_price: 2500,
|
unit_price: 2500,
|
||||||
};
|
}
|
||||||
|
|
||||||
const createContentDigest = jest.fn(() => "digest_string");
|
const createContentDigest = jest.fn(() => "digest_string")
|
||||||
const processNodeResult = processNode(node, fieldName, createContentDigest);
|
const processNodeResult = processNode(node, fieldName, createContentDigest)
|
||||||
|
|
||||||
expect(createContentDigest).toBeCalled();
|
expect(createContentDigest).toBeCalled()
|
||||||
|
|
||||||
expect(processNodeResult).toMatchSnapshot();
|
expect(processNodeResult).toMatchSnapshot()
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
File renamed without changes.
@@ -1,5 +1,3 @@
|
|||||||
import { capitalize } from "./utils/capitalize"
|
|
||||||
|
|
||||||
export const processNode = (
|
export const processNode = (
|
||||||
node: any,
|
node: any,
|
||||||
fieldName: string,
|
fieldName: string,
|
||||||
@@ -34,12 +32,14 @@ export const processNode = (
|
|||||||
delete node.images
|
delete node.images
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: use upperFirstCase from medusajs/utils when it's available
|
||||||
|
const type = `Medusa${fieldName[0].toUpperCase() + fieldName.slice(1)}`
|
||||||
const nodeData = Object.assign({}, node, {
|
const nodeData = Object.assign({}, node, {
|
||||||
id: nodeId,
|
id: nodeId,
|
||||||
parent: null,
|
parent: null,
|
||||||
children: [],
|
children: [],
|
||||||
internal: {
|
internal: {
|
||||||
type: `Medusa${capitalize(fieldName)}`,
|
type,
|
||||||
content: nodeContent,
|
content: nodeContent,
|
||||||
contentDigest: nodeContentDigest,
|
contentDigest: nodeContentDigest,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
export function capitalize(s: string): string {
|
|
||||||
return s[0].toUpperCase() + s.slice(1)
|
|
||||||
}
|
|
||||||
@@ -1,19 +1,29 @@
|
|||||||
{
|
{
|
||||||
"include": ["src/**/*.ts", "types"],
|
|
||||||
"exclude": ["node_modules"],
|
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"strict": true,
|
"lib": ["es2020"],
|
||||||
"noUnusedLocals": true,
|
"target": "es2020",
|
||||||
"noUnusedParameters": true,
|
"outDir": "./dist",
|
||||||
"noImplicitReturns": true,
|
|
||||||
"module": "commonjs",
|
|
||||||
"removeComments": false,
|
|
||||||
"preserveConstEnums": true,
|
|
||||||
"skipLibCheck": true,
|
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"sourceMap": true,
|
|
||||||
"target": "es2017",
|
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
"lib": ["es2017", "dom", "esnext.asynciterable"]
|
"module": "commonjs",
|
||||||
}
|
"moduleResolution": "node",
|
||||||
|
"emitDecoratorMetadata": true,
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"sourceMap": true,
|
||||||
|
"noImplicitReturns": true,
|
||||||
|
"strictNullChecks": true,
|
||||||
|
"strictFunctionTypes": true,
|
||||||
|
"noImplicitThis": true,
|
||||||
|
"allowJs": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"downlevelIteration": true // to use ES5 specific tooling
|
||||||
|
},
|
||||||
|
"include": ["src"],
|
||||||
|
"exclude": [
|
||||||
|
"dist",
|
||||||
|
"./src/**/__tests__",
|
||||||
|
"./src/**/__mocks__",
|
||||||
|
"./src/**/__fixtures__",
|
||||||
|
"node_modules"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"extends": "./tsconfig.json",
|
||||||
|
"include": ["src"],
|
||||||
|
"exclude": ["node_modules"]
|
||||||
|
}
|
||||||
@@ -2294,7 +2294,7 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"@babel/plugin-transform-typescript@npm:^7.13.0, @babel/plugin-transform-typescript@npm:^7.15.4, @babel/plugin-transform-typescript@npm:^7.18.6":
|
"@babel/plugin-transform-typescript@npm:^7.13.0, @babel/plugin-transform-typescript@npm:^7.18.6":
|
||||||
version: 7.18.8
|
version: 7.18.8
|
||||||
resolution: "@babel/plugin-transform-typescript@npm:7.18.8"
|
resolution: "@babel/plugin-transform-typescript@npm:7.18.8"
|
||||||
dependencies:
|
dependencies:
|
||||||
@@ -2504,7 +2504,7 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"@babel/preset-flow@npm:^7.12.1, @babel/preset-flow@npm:^7.14.0":
|
"@babel/preset-flow@npm:^7.12.1":
|
||||||
version: 7.18.6
|
version: 7.18.6
|
||||||
resolution: "@babel/preset-flow@npm:7.18.6"
|
resolution: "@babel/preset-flow@npm:7.18.6"
|
||||||
dependencies:
|
dependencies:
|
||||||
@@ -15057,7 +15057,7 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"babel-plugin-polyfill-corejs2@npm:^0.3.0, babel-plugin-polyfill-corejs2@npm:^0.3.1":
|
"babel-plugin-polyfill-corejs2@npm:^0.3.1":
|
||||||
version: 0.3.1
|
version: 0.3.1
|
||||||
resolution: "babel-plugin-polyfill-corejs2@npm:0.3.1"
|
resolution: "babel-plugin-polyfill-corejs2@npm:0.3.1"
|
||||||
dependencies:
|
dependencies:
|
||||||
@@ -15272,28 +15272,6 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"babel-preset-gatsby-package@npm:^2.0.0":
|
|
||||||
version: 2.18.0
|
|
||||||
resolution: "babel-preset-gatsby-package@npm:2.18.0"
|
|
||||||
dependencies:
|
|
||||||
"@babel/plugin-proposal-nullish-coalescing-operator": ^7.14.5
|
|
||||||
"@babel/plugin-proposal-optional-chaining": ^7.14.5
|
|
||||||
"@babel/plugin-syntax-dynamic-import": ^7.8.3
|
|
||||||
"@babel/plugin-transform-runtime": ^7.15.0
|
|
||||||
"@babel/plugin-transform-typescript": ^7.15.4
|
|
||||||
"@babel/preset-env": ^7.15.4
|
|
||||||
"@babel/preset-flow": ^7.14.0
|
|
||||||
"@babel/preset-react": ^7.14.0
|
|
||||||
"@babel/runtime": ^7.15.4
|
|
||||||
babel-plugin-dynamic-import-node: ^2.3.3
|
|
||||||
babel-plugin-lodash: ^3.3.4
|
|
||||||
core-js: ^3.22.3
|
|
||||||
peerDependencies:
|
|
||||||
"@babel/core": ^7.11.6
|
|
||||||
checksum: 1c3aeda5169728507258d35e06da3dbb0559a132c8c6e82f6fbd9535aa76ce691451b0bc91398e5381f2c1484b5125dd8bb9473e06ead07bfe03af7d76891492
|
|
||||||
languageName: node
|
|
||||||
linkType: hard
|
|
||||||
|
|
||||||
"babel-preset-gatsby@npm:^2.18.0":
|
"babel-preset-gatsby@npm:^2.18.0":
|
||||||
version: 2.18.0
|
version: 2.18.0
|
||||||
resolution: "babel-preset-gatsby@npm:2.18.0"
|
resolution: "babel-preset-gatsby@npm:2.18.0"
|
||||||
@@ -22912,13 +22890,12 @@ __metadata:
|
|||||||
dependencies:
|
dependencies:
|
||||||
"@types/jest": ^27.0.1
|
"@types/jest": ^27.0.1
|
||||||
axios: ^0.24.0
|
axios: ^0.24.0
|
||||||
babel-plugin-polyfill-corejs2: ^0.3.0
|
|
||||||
babel-preset-gatsby-package: ^2.0.0
|
|
||||||
gatsby: ^4.1.0
|
gatsby: ^4.1.0
|
||||||
gatsby-core-utils: ^3.3.0
|
gatsby-core-utils: ^3.3.0
|
||||||
gatsby-plugin-image: ^2.3.0
|
gatsby-plugin-image: ^2.3.0
|
||||||
gatsby-source-filesystem: ^4.3.0
|
gatsby-source-filesystem: ^4.3.0
|
||||||
jest: ^27.0.6
|
jest: ^27.0.6
|
||||||
|
ts-jest: ^27.1.5
|
||||||
tsc-watch: ^4.5.0
|
tsc-watch: ^4.5.0
|
||||||
typescript: ^4.5.2
|
typescript: ^4.5.2
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
|
|||||||
Reference in new issue
Block a user