diff --git a/.changeset/afraid-fishes-judge.md b/.changeset/afraid-fishes-judge.md new file mode 100644 index 0000000..12090d1 --- /dev/null +++ b/.changeset/afraid-fishes-judge.md @@ -0,0 +1,5 @@ +--- +"wpgraphql-ide": patch +--- + +- Remove npm workspaces and have webpack handle compiling of the main app and internal plugins. diff --git a/.gitignore b/.gitignore index e1a8683..891da77 100644 --- a/.gitignore +++ b/.gitignore @@ -64,4 +64,6 @@ wpgraphql-ide.zip /playwright-report/ /blob-report/ /playwright/.cache/ -/@wpgraphql/ \ No newline at end of file +/@wpgraphql/ + +**/package-lock.json \ No newline at end of file diff --git a/bin/start-plugins.js b/bin/start-plugins.js new file mode 100755 index 0000000..c408bb4 --- /dev/null +++ b/bin/start-plugins.js @@ -0,0 +1,24 @@ +#!/usr/bin/env node + +const { execSync } = require('child_process'); +const path = require('path'); +const glob = require('glob'); + +// Define the path to the plugins directory +const pluginsPath = path.resolve(__dirname, '../plugins'); + +// Use glob to find all plugin directories +const plugins = glob.sync(`${pluginsPath}/*`); + +// Function to start a plugin using wp-scripts +const startPlugin = (plugin) => { + const pluginName = path.basename(plugin); + console.log(`Starting plugin: ${pluginName}`); + execSync('wp-scripts start', { + cwd: plugin, + stdio: 'inherit', + }); +}; + +// Start each plugin +plugins.forEach(startPlugin); diff --git a/bin/versionPlugin.js b/bin/version-plugin.js old mode 100644 new mode 100755 similarity index 100% rename from bin/versionPlugin.js rename to bin/version-plugin.js diff --git a/package-lock.json b/package-lock.json index 1a40261..15c21db 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,17 +7,17 @@ "": { "name": "wpgraphql-ide", "version": "2.1.2", - "workspaces": [ - "plugins/*" - ], "dependencies": { "@changesets/cli": "^2.27.1", - "@graphiql/plugin-explorer": "^1.0.3", + "@graphiql/react": "^0.22.2", + "@graphiql/toolkit": "^0.9.1", "@wordpress/components": "^27.0.0", "@wordpress/data": "^9.22.0", "@wordpress/element": "^5.23.0", "@wordpress/hooks": "^3.49.0", "@wordpress/icons": "^9.43.0", + "@wpgraphql-ide/help-panel": "file:plugins/help-panel", + "@wpgraphql-ide/query-composer-panel": "file:plugins/query-composer-panel", "copy-to-clipboard": "^3.3.3", "graphiql": "^3.0.10", "graphql": "^16.8.1", @@ -2907,9 +2907,9 @@ "peer": true }, "node_modules/@codemirror/view": { - "version": "6.26.3", - "resolved": "https://registry.npmjs.org/@codemirror/view/-/view-6.26.3.tgz", - "integrity": "sha512-gmqxkPALZjkgSxIeeweY/wGQXBfwTUaLs8h7OKtSwfbj9Ct3L11lD+u1sS7XHppxFQoMDiMDp07P9f3I2jWOHw==", + "version": "6.27.0", + "resolved": "https://registry.npmjs.org/@codemirror/view/-/view-6.27.0.tgz", + "integrity": "sha512-8kqX1sHbVW1lVzWwrjAbh4dR7eKhV8eIQ952JKaBXOoXE04WncoqCy4DMU701LSrPZ3N2Q4zsTawz7GQ+2mrUw==", "peer": true, "dependencies": { "@codemirror/state": "^6.4.0", @@ -3275,34 +3275,10 @@ "resolved": "https://registry.npmjs.org/@floating-ui/utils/-/utils-0.2.1.tgz", "integrity": "sha512-9TANp6GPoMtYzQdt54kfAyMmz1+osLlXdg2ENroU7zzrtflTLrrC/lgrIfaSe+Wu0b89GKccT7vxXA0MoAIO+Q==" }, - "node_modules/@graphiql/plugin-explorer": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@graphiql/plugin-explorer/-/plugin-explorer-1.0.3.tgz", - "integrity": "sha512-dKgdNXut/CaxfU8lcFDi1Jb/5f7NnCHa62E7xlNUNYRzieZ7+Bka0rvspgxzXPYevviigzmrtPGtHd5SeaZ57g==", - "dependencies": { - "graphiql-explorer": "^0.9.0" - }, - "peerDependencies": { - "@graphiql/react": "^0.20.3", - "graphql": "^15.5.0 || ^16.0.0", - "react": "^16.8.0 || ^17 || ^18", - "react-dom": "^16.8.0 || ^17 || ^18" - } - }, - "node_modules/@graphiql/plugin-explorer/node_modules/graphiql-explorer": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/graphiql-explorer/-/graphiql-explorer-0.9.0.tgz", - "integrity": "sha512-fZC/wsuatqiQDO2otchxriFO0LaWIo/ovF/CQJ1yOudmY0P7pzDiP+l9CEHUiWbizk3e99x6DQG4XG1VxA+d6A==", - "peerDependencies": { - "graphql": "^0.6.0 || ^0.7.0 || ^0.8.0-b || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0", - "react": "^15.6.0 || ^16.0.0", - "react-dom": "^15.6.0 || ^16.0.0" - } - }, "node_modules/@graphiql/react": { - "version": "0.20.4", - "resolved": "https://registry.npmjs.org/@graphiql/react/-/react-0.20.4.tgz", - "integrity": "sha512-LDgIlHa65pSngk8G2O0hvohNz4B41VUa7Yg6iPwifa1XreXxHIXjhV6FC1qi5oSjdCIRp4T8dkZnHA6iI5eElg==", + "version": "0.22.2", + "resolved": "https://registry.npmjs.org/@graphiql/react/-/react-0.22.2.tgz", + "integrity": "sha512-46UV7CBQdZ0iU537uOkOU6HOOs7P1o7vQpFSUezB4VRem0Y3I4TDaYQADCOo7gFlwBs5Vb9YOup8r7cmXGIr7A==", "dependencies": { "@graphiql/toolkit": "^0.9.1", "@headlessui/react": "^1.7.15", @@ -3313,11 +3289,11 @@ "@types/codemirror": "^5.60.8", "clsx": "^1.2.1", "codemirror": "^5.65.3", - "codemirror-graphql": "^2.0.11", + "codemirror-graphql": "^2.0.12", "copy-to-clipboard": "^3.2.0", "framer-motion": "^6.5.1", - "graphql-language-service": "^5.2.0", - "markdown-it": "^12.2.0", + "graphql-language-service": "^5.2.1", + "markdown-it": "^14.1.0", "set-value": "^4.1.0" }, "peerDependencies": { @@ -3341,6 +3317,11 @@ "integrity": "sha512-Ja/Vfqe3HpuzRsG1oBtWTHk2PGZ7GR+2Vz5iYGelAw8dx32K0y7PjVuxK6z1nMpZOqAFsRUPCkK1YjJ56qJlgw==", "optional": true }, + "node_modules/@graphiql/react/node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" + }, "node_modules/@graphiql/react/node_modules/clsx": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/clsx/-/clsx-1.2.1.tgz", @@ -3369,6 +3350,40 @@ "react-dom": ">=16.8 || ^17.0.0 || ^18.0.0" } }, + "node_modules/@graphiql/react/node_modules/linkify-it": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-5.0.0.tgz", + "integrity": "sha512-5aHCbzQRADcdP+ATqnDuhhJ/MRIqDkZX5pyjFHRRysS8vZ5AbqGEoFIb6pYHPZ+L/OC2Lc+xT8uHVVR5CAK/wQ==", + "dependencies": { + "uc.micro": "^2.0.0" + } + }, + "node_modules/@graphiql/react/node_modules/markdown-it": { + "version": "14.1.0", + "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-14.1.0.tgz", + "integrity": "sha512-a54IwgWPaeBCAAsv13YgmALOF1elABB08FxO9i+r4VFk5Vl4pKokRPeX8u5TCgSsPi6ec1otfLjdOpVcgbpshg==", + "dependencies": { + "argparse": "^2.0.1", + "entities": "^4.4.0", + "linkify-it": "^5.0.0", + "mdurl": "^2.0.0", + "punycode.js": "^2.3.1", + "uc.micro": "^2.1.0" + }, + "bin": { + "markdown-it": "bin/markdown-it.mjs" + } + }, + "node_modules/@graphiql/react/node_modules/mdurl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-2.0.0.tgz", + "integrity": "sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w==" + }, + "node_modules/@graphiql/react/node_modules/uc.micro": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-2.1.0.tgz", + "integrity": "sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A==" + }, "node_modules/@graphiql/toolkit": { "version": "0.9.1", "resolved": "https://registry.npmjs.org/@graphiql/toolkit/-/toolkit-0.9.1.tgz", @@ -4391,9 +4406,9 @@ } }, "node_modules/@lezer/lr": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/@lezer/lr/-/lr-1.4.0.tgz", - "integrity": "sha512-Wst46p51km8gH0ZUmeNrtpRYmdlRHUpN1DQd3GFAyKANi8WVz8c2jHYTf1CVScFaCjQw1iO3ZZdqGDxQPRErTg==", + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/@lezer/lr/-/lr-1.4.1.tgz", + "integrity": "sha512-CHsKq8DMKBf9b3yXPDIU4DbH+ZJd/sJdYOW2llbW/HudP5u0VS6Bfq1hLYfgU7uAYGFIyGGQIsSOXGPEErZiJw==", "peer": true, "dependencies": { "@lezer/common": "^1.0.0" @@ -8160,6 +8175,14 @@ "node": ">=12" } }, + "node_modules/@wpgraphql-ide/help-panel": { + "resolved": "plugins/help-panel", + "link": true + }, + "node_modules/@wpgraphql-ide/query-composer-panel": { + "resolved": "plugins/query-composer-panel", + "link": true + }, "node_modules/@xtuc/ieee754": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/@xtuc/ieee754/-/ieee754-1.2.0.tgz", @@ -9973,10 +9996,9 @@ } }, "node_modules/clsx": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.0.tgz", - "integrity": "sha512-m3iNNWpd9rl3jvvcBnu70ylMdrXt8Vlq4HYadnU5fwcOtvkSQWPmj7amUcDT2qYI7risszBjI5AUIUox9D16pg==", - "dev": true, + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz", + "integrity": "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==", "engines": { "node": ">=6" } @@ -9997,12 +10019,12 @@ "integrity": "sha512-br21LjYmSlVL0vFCPWPfhzUCT34FM/pAdK7rRIZwa0rrtrIdotvP4Oh4GUHsu2E3IrQMCfRkL/fN3ytMNxVQvg==" }, "node_modules/codemirror-graphql": { - "version": "2.0.11", - "resolved": "https://registry.npmjs.org/codemirror-graphql/-/codemirror-graphql-2.0.11.tgz", - "integrity": "sha512-j1QDDXKVkpin2VsyS0ke2nAhKal6/N1UJtgnBGrPe3gj9ZSP6/K8Xytft94k0xW6giIU/JhZjvW0GwwERNzbFA==", + "version": "2.0.12", + "resolved": "https://registry.npmjs.org/codemirror-graphql/-/codemirror-graphql-2.0.12.tgz", + "integrity": "sha512-5UCqhWzck1jClCmRewFb8aSiabnAqiaRfsvIPfmbf6WJvOb8oiefJeHilclPPiZBzY8v/Et6EBMtOeKnWCoyng==", "dependencies": { "@types/codemirror": "^0.0.90", - "graphql-language-service": "5.2.0" + "graphql-language-service": "5.2.1" }, "peerDependencies": { "@codemirror/language": "6.0.0", @@ -11791,7 +11813,6 @@ "version": "4.5.0", "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", - "dev": true, "engines": { "node": ">=0.12" }, @@ -14329,6 +14350,76 @@ "react-dom": "^16.8.0 || ^17 || ^18" } }, + "node_modules/graphiql/node_modules/@emotion/is-prop-valid": { + "version": "0.8.8", + "resolved": "https://registry.npmjs.org/@emotion/is-prop-valid/-/is-prop-valid-0.8.8.tgz", + "integrity": "sha512-u5WtneEAr5IDG2Wv65yhunPSMLIpuKsbuOktRojfrEiEvRyC85LgPMZI63cr7NUqT8ZIGdSVg8ZKGxIug4lXcA==", + "optional": true, + "dependencies": { + "@emotion/memoize": "0.7.4" + } + }, + "node_modules/graphiql/node_modules/@emotion/memoize": { + "version": "0.7.4", + "resolved": "https://registry.npmjs.org/@emotion/memoize/-/memoize-0.7.4.tgz", + "integrity": "sha512-Ja/Vfqe3HpuzRsG1oBtWTHk2PGZ7GR+2Vz5iYGelAw8dx32K0y7PjVuxK6z1nMpZOqAFsRUPCkK1YjJ56qJlgw==", + "optional": true + }, + "node_modules/graphiql/node_modules/@graphiql/react": { + "version": "0.20.4", + "resolved": "https://registry.npmjs.org/@graphiql/react/-/react-0.20.4.tgz", + "integrity": "sha512-LDgIlHa65pSngk8G2O0hvohNz4B41VUa7Yg6iPwifa1XreXxHIXjhV6FC1qi5oSjdCIRp4T8dkZnHA6iI5eElg==", + "dependencies": { + "@graphiql/toolkit": "^0.9.1", + "@headlessui/react": "^1.7.15", + "@radix-ui/react-dialog": "^1.0.4", + "@radix-ui/react-dropdown-menu": "^2.0.5", + "@radix-ui/react-tooltip": "^1.0.6", + "@radix-ui/react-visually-hidden": "^1.0.3", + "@types/codemirror": "^5.60.8", + "clsx": "^1.2.1", + "codemirror": "^5.65.3", + "codemirror-graphql": "^2.0.11", + "copy-to-clipboard": "^3.2.0", + "framer-motion": "^6.5.1", + "graphql-language-service": "^5.2.0", + "markdown-it": "^12.2.0", + "set-value": "^4.1.0" + }, + "peerDependencies": { + "graphql": "^15.5.0 || ^16.0.0", + "react": "^16.8.0 || ^17 || ^18", + "react-dom": "^16.8.0 || ^17 || ^18" + } + }, + "node_modules/graphiql/node_modules/clsx": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/clsx/-/clsx-1.2.1.tgz", + "integrity": "sha512-EcR6r5a8bj6pu3ycsa/E/cKVGuTgZJZdsyUYHOksG/UHIiKfjxzRxYJpyVBwYaQeOvghal9fcc4PidlgzugAQg==", + "engines": { + "node": ">=6" + } + }, + "node_modules/graphiql/node_modules/framer-motion": { + "version": "6.5.1", + "resolved": "https://registry.npmjs.org/framer-motion/-/framer-motion-6.5.1.tgz", + "integrity": "sha512-o1BGqqposwi7cgDrtg0dNONhkmPsUFDaLcKXigzuTFC5x58mE8iyTazxSudFzmT6MEyJKfjjU8ItoMe3W+3fiw==", + "dependencies": { + "@motionone/dom": "10.12.0", + "framesync": "6.0.1", + "hey-listen": "^1.0.8", + "popmotion": "11.0.3", + "style-value-types": "5.0.0", + "tslib": "^2.1.0" + }, + "optionalDependencies": { + "@emotion/is-prop-valid": "^0.8.2" + }, + "peerDependencies": { + "react": ">=16.8 || ^17.0.0 || ^18.0.0", + "react-dom": ">=16.8 || ^17.0.0 || ^18.0.0" + } + }, "node_modules/graphql": { "version": "16.8.1", "resolved": "https://registry.npmjs.org/graphql/-/graphql-16.8.1.tgz", @@ -14338,9 +14429,9 @@ } }, "node_modules/graphql-language-service": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/graphql-language-service/-/graphql-language-service-5.2.0.tgz", - "integrity": "sha512-o/ZgTS0pBxWm3hSF4+6GwiV1//DxzoLWEbS38+jqpzzy1d/QXBidwQuVYTOksclbtOJZ3KR/tZ8fi/tI6VpVMg==", + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/graphql-language-service/-/graphql-language-service-5.2.1.tgz", + "integrity": "sha512-8ewD6otGO43vg2TiEGjoLz3CweTwfaf4ZnqfNREqZXS2JSJGXtsRBOMMknCxMfFVh4x14ql3jyDrXcyAAtbmkQ==", "dependencies": { "nullthrows": "^1.0.0", "vscode-languageserver-types": "^3.17.1" @@ -14475,10 +14566,6 @@ "tslib": "^2.0.3" } }, - "node_modules/help-panel": { - "resolved": "plugins/help-panel", - "link": true - }, "node_modules/hey-listen": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/hey-listen/-/hey-listen-1.0.8.tgz", @@ -21632,6 +21719,14 @@ "node": ">=6" } }, + "node_modules/punycode.js": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode.js/-/punycode.js-2.3.1.tgz", + "integrity": "sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA==", + "engines": { + "node": ">=6" + } + }, "node_modules/puppeteer-core": { "version": "13.7.0", "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-13.7.0.tgz", @@ -21749,10 +21844,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/query-composer-panel": { - "resolved": "plugins/query-composer-panel", - "link": true - }, "node_modules/querystringify": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.2.0.tgz", @@ -26564,19 +26655,71 @@ } }, "plugins/help-panel": { + "name": "@wpgraphql-ide/help-panel", "dependencies": { - "@wordpress/data": "^9.26.0", - "@wordpress/element": "^5.33.0", - "react": "^18.3.1", - "react-dom": "^18.3.1" + "@wordpress/icons": "^10.0.0" }, "devDependencies": { - "@babel/preset-env": "^7.23.9", - "@babel/preset-react": "^7.23.3", - "@types/node": "^20.11.16", - "@wordpress/scripts": "^27.9.0", - "babel-jest": "^29.7.0", - "clsx": "^2.0.0" + "@wordpress/scripts": "^27.9.0" + } + }, + "plugins/help-panel/node_modules/@wordpress/element": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/@wordpress/element/-/element-6.0.0.tgz", + "integrity": "sha512-YaLki9alJIiGbpozTLhsSQesyVFGlY4uP2XmDzroqnUul7ixEn2s6xUGlaSz9Q3TD2RIl+ml9JqAy/kc8vXLFg==", + "dependencies": { + "@babel/runtime": "^7.16.0", + "@types/react": "^18.2.79", + "@types/react-dom": "^18.2.25", + "@wordpress/escape-html": "^3.0.0", + "change-case": "^4.1.2", + "is-plain-object": "^5.0.0", + "react": "^18.3.0", + "react-dom": "^18.3.0" + }, + "engines": { + "node": ">=18.12.0", + "npm": ">=8.19.2" + } + }, + "plugins/help-panel/node_modules/@wordpress/escape-html": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@wordpress/escape-html/-/escape-html-3.0.0.tgz", + "integrity": "sha512-gNdX2+8IQ/yH+d26w1+tJ7zZqUZ59SQRXkgsH0dGOo0LjaSMkhngSnGTVFmhxWo37Td5WzrMREzd6hM3P6RJJg==", + "dependencies": { + "@babel/runtime": "^7.16.0" + }, + "engines": { + "node": ">=18.12.0", + "npm": ">=8.19.2" + } + }, + "plugins/help-panel/node_modules/@wordpress/icons": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/@wordpress/icons/-/icons-10.0.0.tgz", + "integrity": "sha512-BL1LtPgfFZdMLd2EUmckX8EXo10LDGDlQZx4CyyL0Vnx/6HcR/H3Z5EN6yeJl57fbjPg7noyOZVCdvG1EiiZnA==", + "dependencies": { + "@babel/runtime": "^7.16.0", + "@wordpress/element": "^6.0.0", + "@wordpress/primitives": "^4.0.0" + }, + "engines": { + "node": ">=18.12.0", + "npm": ">=8.19.2" + } + }, + "plugins/help-panel/node_modules/@wordpress/primitives": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@wordpress/primitives/-/primitives-4.0.0.tgz", + "integrity": "sha512-NMzDEFxfRwh1IAbf4fJHz6UmvIyfHmId6/1UjueCgpON0LR0y5ydjB6Pd4AngkMcO2qOjD9XNP6MKAOzdjw54g==", + "dependencies": { + "@babel/runtime": "^7.16.0", + "@wordpress/element": "^6.0.0", + "clsx": "^2.1.1" + }, + "engines": { + "node": ">=18.12.0", + "npm": ">=8.19.2" } }, "plugins/help-panel/node_modules/react": { @@ -26633,6 +26776,7 @@ } }, "plugins/query-composer-panel": { + "name": "@wpgraphql-ide/query-composer-panel", "dependencies": { "@wordpress/data": "^9.26.0", "@wordpress/element": "^5.33.0", @@ -26640,12 +26784,7 @@ "react-dom": "^18.3.1" }, "devDependencies": { - "@babel/preset-env": "^7.23.9", - "@babel/preset-react": "^7.23.3", - "@types/node": "^20.11.16", - "@wordpress/scripts": "^27.9.0", - "babel-jest": "^29.7.0", - "clsx": "^2.0.0" + "@wordpress/scripts": "^27.9.0" } }, "plugins/query-composer-panel/node_modules/react": { diff --git a/package.json b/package.json index 7817506..341e852 100644 --- a/package.json +++ b/package.json @@ -8,40 +8,38 @@ }, "files": [ "build", - "styles", - "wpgraphql-ide.php", "package.json", + "plugins/*/*.php", + "plugins/*/build", + "plugins/*/README.md", "README.md", - "readme.txt" - ], - "workspaces": [ - "plugins/*" + "readme.txt", + "styles", + "wpgraphql-ide.php" ], "scripts": { - "check-engines": "wp-scripts check-engines", - "build": "npm run build:main && npm run build:plugins && npm run build:zip", + "build": "npm run build:main && npm run build:zip", "build:main": "wp-scripts build", - "build:plugins": "concurrently --kill-others-on-fail 'npm run build --workspace plugins/query-composer-panel' 'npm run build --workspace plugins/help-panel'", "build:zip": "wp-scripts plugin-zip", - "start": "concurrently --kill-others-on-fail -n 'Main,Plugins' -c 'blue,green' \"wp-scripts start\" \"npm run start:plugins\"", - "start:plugins": "concurrently --kill-others-on-fail 'npm:start --workspace plugins/query-composer-panel' 'npm:start --workspace plugins/help-panel'", + "start": "concurrently --kill-others-on-fail -n 'Main,Plugins' -c 'blue,green' \"wp-scripts start\" \"node bin/start-plugins.js\"", + "test:unit": "jest --config tests/unit/jest.config.js", "pretest:e2e": "npm run build && npm run wp-env start", "pretest:e2e:ui": "npm run build && npm run wp-env start", "test:e2e": "wp-scripts test-playwright --config tests/e2e/playwright.config.js", "test:e2e:ui": "wp-scripts test-playwright --config tests/e2e/playwright.config.js --ui", - "test:unit": "jest --config tests/unit/jest.config.js", - "format": "wp-scripts format", - "format:src": "wp-scripts format ./src", "lint:js": "wp-scripts lint-js ./src", "lint:js:fix": "wp-scripts lint-js --fix ./src", "lint:js:src": "wp-scripts lint-js ./src", - "wp-env": "wp-env", + "format": "wp-scripts format", + "format:src": "wp-scripts format ./src", + "check-engines": "wp-scripts check-engines", + "clean": "rimraf node_modules plugins/*/node_modules plugins/*/build build", "changeset": "changeset", "version": "changeset version && node bin/versionPlugin.js", "prerelease": "npm run build", "release": "changeset publish", "prepare": "husky install", - "clean": "rimraf node_modules plugins/*/node_modules" + "wp-env": "wp-env" }, "devDependencies": { "@babel/preset-env": "^7.23.9", @@ -66,12 +64,15 @@ }, "dependencies": { "@changesets/cli": "^2.27.1", - "@graphiql/plugin-explorer": "^1.0.3", + "@graphiql/react": "^0.22.2", + "@graphiql/toolkit": "^0.9.1", "@wordpress/components": "^27.0.0", "@wordpress/data": "^9.22.0", "@wordpress/element": "^5.23.0", "@wordpress/hooks": "^3.49.0", "@wordpress/icons": "^9.43.0", + "@wpgraphql-ide/help-panel": "file:plugins/help-panel", + "@wpgraphql-ide/query-composer-panel": "file:plugins/query-composer-panel", "copy-to-clipboard": "^3.3.3", "graphiql": "^3.0.10", "graphql": "^16.8.1", diff --git a/plugins/help-panel/.npmrc b/plugins/help-panel/.npmrc new file mode 100644 index 0000000..c1ca392 --- /dev/null +++ b/plugins/help-panel/.npmrc @@ -0,0 +1 @@ +package-lock = false diff --git a/plugins/help-panel/help-panel.php b/plugins/help-panel/help-panel.php index 0981e42..c3327cf 100644 --- a/plugins/help-panel/help-panel.php +++ b/plugins/help-panel/help-panel.php @@ -1,18 +1,30 @@ { +// Define entry points for the main app and plugins +const mainAppEntry = { + 'wpgraphql-ide': path.resolve(process.cwd(), 'src', 'wpgraphql-ide.js'), + 'wpgraphql-ide-render': path.resolve(process.cwd(), 'src', 'wpgraphql-ide-render.js'), + 'graphql': path.resolve(process.cwd(), 'src', 'graphql.js'), +}; + +// Reduce plugins to an entry object and an output object +const { pluginsEntry, pluginsOutput } = plugins.reduce((result, plugin) => { const pluginName = path.basename(plugin); - entries[pluginName] = path.resolve(plugin, 'src', `${pluginName}.js`); - return entries; -}, {}); + result.pluginsEntry[pluginName] = path.resolve(plugin, 'src', `${pluginName}.js`); + result.pluginsOutput[pluginName] = path.resolve(plugin, 'build'); + return result; +}, { pluginsEntry: {}, pluginsOutput: {} }); -module.exports = { +// Generate Webpack configurations for each plugin +const pluginConfigs = Object.entries(pluginsEntry).map(([name, entry]) => ({ ...defaults, entry: { - ...pluginsEntry, - 'wpgraphql-ide': path.resolve( process.cwd(), 'src', 'wpgraphql-ide.js' ), - 'wpgraphql-ide-render': path.resolve( process.cwd(), 'src', 'wpgraphql-ide-render.js' ), - 'graphql': path.resolve( process.cwd(), 'src', 'graphql.js' ), + [name]: entry, }, externals: { react: 'React', @@ -25,7 +35,26 @@ module.exports = { graphql: 'graphql', }, output: { - path: path.resolve(__dirname, 'build'), - filename: '[name]/[name].js', + path: pluginsOutput[name], + filename: `${name}.js`, }, -}; +})); + +// Export an array of Webpack configurations, one for the main app and one for each plugin +module.exports = [ + { + ...defaults, + entry: mainAppEntry, + externals: { + react: 'React', + 'react-dom': 'ReactDOM', + graphql: 'graphql', + }, + output: { + path: path.resolve(__dirname, 'build'), + filename: '[name].js', + }, + }, + // Configurations for each plugin + ...pluginConfigs, +]; \ No newline at end of file diff --git a/wpgraphql-ide.php b/wpgraphql-ide.php index aa6ebef..8effc5e 100644 --- a/wpgraphql-ide.php +++ b/wpgraphql-ide.php @@ -28,8 +28,8 @@ /** * Register core IDE plugins. */ -require_once WPGRAPHQL_IDE_PLUGIN_DIR_PATH . '/plugins/query-composer-panel/query-composer-panel.php'; -require_once WPGRAPHQL_IDE_PLUGIN_DIR_PATH . '/plugins/help-panel/help-panel.php'; +require_once WPGRAPHQL_IDE_PLUGIN_DIR_PATH . 'plugins/query-composer-panel/query-composer-panel.php'; +require_once WPGRAPHQL_IDE_PLUGIN_DIR_PATH . 'plugins/help-panel/help-panel.php'; /** * Generates the SVG logo for GraphQL. @@ -260,15 +260,15 @@ function enqueue_react_app_with_styles(): void { } } - $asset_file = include WPGRAPHQL_IDE_PLUGIN_DIR_PATH . 'build/wpgraphql-ide/wpgraphql-ide.asset.php'; - $render_asset_file = include WPGRAPHQL_IDE_PLUGIN_DIR_PATH . 'build/wpgraphql-ide-render/wpgraphql-ide-render.asset.php'; - $graphql_asset_file = include WPGRAPHQL_IDE_PLUGIN_DIR_PATH . 'build/graphql/graphql.asset.php'; + $asset_file = include WPGRAPHQL_IDE_PLUGIN_DIR_PATH . 'build/wpgraphql-ide.asset.php'; + $render_asset_file = include WPGRAPHQL_IDE_PLUGIN_DIR_PATH . 'build/wpgraphql-ide-render.asset.php'; + $graphql_asset_file = include WPGRAPHQL_IDE_PLUGIN_DIR_PATH . 'build/graphql.asset.php'; $app_context = get_app_context(); wp_register_script( 'graphql', - plugins_url( 'build/graphql/graphql.js', __FILE__ ), + plugins_url( 'build/graphql.js', __FILE__ ), $graphql_asset_file['dependencies'], $graphql_asset_file['version'], false @@ -276,7 +276,7 @@ function enqueue_react_app_with_styles(): void { wp_enqueue_script( 'wpgraphql-ide', - plugins_url( 'build/wpgraphql-ide/wpgraphql-ide.js', __FILE__ ), + plugins_url( 'build/wpgraphql-ide.js', __FILE__ ), array_merge( $asset_file['dependencies'], [ 'graphql' ] ), $asset_file['version'], false @@ -303,7 +303,7 @@ function enqueue_react_app_with_styles(): void { wp_enqueue_script( 'wpgraphql-ide-render', - plugins_url( 'build/wpgraphql-ide-render/wpgraphql-ide-render.js', __FILE__ ), + plugins_url( 'build/wpgraphql-ide-render.js', __FILE__ ), array_merge( $asset_file['dependencies'], [ 'wpgraphql-ide', 'graphql' ] ), $render_asset_file['version'], false