From 0f39a4bd744afad568098cf3b87ad1ca6358755e Mon Sep 17 00:00:00 2001 From: adrians5j Date: Tue, 30 Apr 2024 23:48:29 +0200 Subject: [PATCH 01/32] wip: create essential plugins scaffold --- .../cli-plugin-scaffold-plugin/.babelrc.js | 1 + packages/cli-plugin-scaffold-plugin/LICENSE | 21 +++ packages/cli-plugin-scaffold-plugin/README.md | 25 +++ .../cli-plugin-scaffold-plugin/package.json | 61 +++++++ .../cli-plugin-scaffold-plugin/src/index.ts | 159 ++++++++++++++++++ .../templates/admin/package.json | 4 + .../templates/admin/src/index.tsx | 5 + .../templates/admin/tsconfig.json | 4 + .../templates/api/package.json | 4 + .../templates/api/src/index.tsx | 3 + .../templates/api/tsconfig.json | 4 + .../tsconfig.build.json | 15 ++ .../cli-plugin-scaffold-plugin/tsconfig.json | 19 +++ .../webiny.config.js | 18 ++ 14 files changed, 343 insertions(+) create mode 100644 packages/cli-plugin-scaffold-plugin/.babelrc.js create mode 100644 packages/cli-plugin-scaffold-plugin/LICENSE create mode 100644 packages/cli-plugin-scaffold-plugin/README.md create mode 100644 packages/cli-plugin-scaffold-plugin/package.json create mode 100644 packages/cli-plugin-scaffold-plugin/src/index.ts create mode 100644 packages/cli-plugin-scaffold-plugin/templates/admin/package.json create mode 100644 packages/cli-plugin-scaffold-plugin/templates/admin/src/index.tsx create mode 100644 packages/cli-plugin-scaffold-plugin/templates/admin/tsconfig.json create mode 100644 packages/cli-plugin-scaffold-plugin/templates/api/package.json create mode 100644 packages/cli-plugin-scaffold-plugin/templates/api/src/index.tsx create mode 100644 packages/cli-plugin-scaffold-plugin/templates/api/tsconfig.json create mode 100644 packages/cli-plugin-scaffold-plugin/tsconfig.build.json create mode 100644 packages/cli-plugin-scaffold-plugin/tsconfig.json create mode 100644 packages/cli-plugin-scaffold-plugin/webiny.config.js diff --git a/packages/cli-plugin-scaffold-plugin/.babelrc.js b/packages/cli-plugin-scaffold-plugin/.babelrc.js new file mode 100644 index 00000000000..9da7674cb52 --- /dev/null +++ b/packages/cli-plugin-scaffold-plugin/.babelrc.js @@ -0,0 +1 @@ +module.exports = require("@webiny/project-utils").createBabelConfigForNode({ path: __dirname }); diff --git a/packages/cli-plugin-scaffold-plugin/LICENSE b/packages/cli-plugin-scaffold-plugin/LICENSE new file mode 100644 index 00000000000..f772d04d4db --- /dev/null +++ b/packages/cli-plugin-scaffold-plugin/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) Webiny + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/cli-plugin-scaffold-plugin/README.md b/packages/cli-plugin-scaffold-plugin/README.md new file mode 100644 index 00000000000..6eca2222e46 --- /dev/null +++ b/packages/cli-plugin-scaffold-plugin/README.md @@ -0,0 +1,25 @@ +# @webiny/cli-plugin-scaffold-plugin + +[![](https://img.shields.io/npm/dw/@webiny/cli-plugin-scaffold-plugin.svg)](https://www.npmjs.com/package/@webiny/cli-plugin-scaffold-plugin) +[![](https://img.shields.io/npm/v/@webiny/cli-plugin-scaffold-plugin.svg)](https://www.npmjs.com/package/@webiny/cli-plugin-scaffold-plugin) +[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier) +[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com) + +A plugin for @webiny/cli-plugin-scaffold that generates a simple React component. + +## Install + +``` +yarn add @webiny/cli-plugin-scaffold-plugin +``` + +Add the plugin to your project by editing `webiny.project.js`: + +```js +module.exports = { + projectName: "my-project", + cli: { + plugins: [require("@webiny/cli-plugin-scaffold-plugin").default(),] + } +}; +``` diff --git a/packages/cli-plugin-scaffold-plugin/package.json b/packages/cli-plugin-scaffold-plugin/package.json new file mode 100644 index 00000000000..f1826daa05d --- /dev/null +++ b/packages/cli-plugin-scaffold-plugin/package.json @@ -0,0 +1,61 @@ +{ + "name": "@webiny/cli-plugin-scaffold-plugin", + "version": "0.0.0", + "description": "Scaffolds essential files for creating a new plugin.", + "main": "index.js", + "types": "index.d.ts", + "repository": { + "type": "git", + "url": "git+https://github.com/webiny/webiny-js.git", + "directory": "packages/cli-plugin-scaffold-plugin" + }, + "author": { + "name": "Webiny", + "url": "https://www.webiny.com" + }, + "license": "MIT", + "bugs": { + "url": "https://github.com/webiny/webiny-js/issues" + }, + "homepage": "https://github.com/webiny/webiny-js#readme", + "dependencies": { + "@webiny/cli": "0.0.0", + "@webiny/cli-plugin-scaffold": "0.0.0", + "@webiny/error": "0.0.0", + "case": "^1.6.3", + "chalk": "^4.1.0", + "execa": "^5.0.0", + "indent-string": "^4.0.0", + "load-json-file": "^6.2.0", + "ncp": "^2.0.0", + "pluralize": "^8.0.0", + "replace-in-path": "^1.1.0", + "validate-npm-package-name": "^3.0.0", + "write-json-file": "^4.3.0" + }, + "devDependencies": { + "@babel/cli": "^7.23.9", + "@babel/core": "^7.24.0", + "@babel/preset-env": "^7.24.0", + "@types/inquirer": "^7.3.1", + "@types/ncp": "^2.0.4", + "@types/pluralize": "^0.0.29", + "@types/validate-npm-package-name": "^3.0.3", + "@webiny/project-utils": "0.0.0", + "rimraf": "^5.0.5", + "typescript": "4.7.4" + }, + "scripts": { + "build": "yarn webiny run build", + "watch": "yarn webiny run watch" + }, + "publishConfig": { + "access": "public", + "directory": "dist" + }, + "adio": { + "ignoreDirs": [ + "template" + ] + } +} diff --git a/packages/cli-plugin-scaffold-plugin/src/index.ts b/packages/cli-plugin-scaffold-plugin/src/index.ts new file mode 100644 index 00000000000..954620f8f88 --- /dev/null +++ b/packages/cli-plugin-scaffold-plugin/src/index.ts @@ -0,0 +1,159 @@ +import { + CliCommandScaffoldTemplate, + TsConfigJson, + PackageJson +} from "@webiny/cli-plugin-scaffold/types"; +import fs from "fs"; +import path from "path"; +import util from "util"; +import ncpBase from "ncp"; +import readJson from "load-json-file"; +import writeJson from "write-json-file"; +import execa from "execa"; +import Case from "case"; +import { replaceInPath } from "replace-in-path"; +import chalk from "chalk"; +import indentString from "indent-string"; +import WebinyError from "@webiny/error"; +import validateNpmPackageName from "validate-npm-package-name"; +/** + * TODO: rewrite cli into typescript + */ +// @ts-expect-error +import { getProject } from "@webiny/cli/utils"; +import { updateScaffoldsIndexFile } from "@webiny/cli-plugin-scaffold/utils"; + +const ncp = util.promisify(ncpBase.ncp); + +interface Input { + pluginName: string; + location: string; + pluginType: string; +} + +export default (): CliCommandScaffoldTemplate => ({ + name: "cli-plugin-scaffold-template-plugin", + type: "cli-plugin-scaffold-template", + scaffold: { + name: "New Plugin", + description: "Scaffolds essential files for creating a new plugin.", + questions: () => { + return [ + { + name: "pluginType", + message: "What type of a plugin you want to create?", + type: "list", + choices: [ + { name: "Admin plugin", value: "admin" }, + { name: "API plugin", value: "api" } + ] + }, + { + name: "pluginName", + message: "Enter the plugin name:", + validate: pluginName => { + if (!pluginName) { + return "Missing plugin name."; + } + + const isValidNpmPackageName = validateNpmPackageName(pluginName); + if (!isValidNpmPackageName) { + return `Package name must look something like "myCustomPlugin".`; + } + + return true; + } + }, + { + name: "location", + message: `Enter the plugin location:`, + default: (answers: Input) => { + return `plugins/${Case.kebab(answers.pluginName)}`; + }, + validate: location => { + if (!location) { + return "Please enter the package location."; + } + + if (!location.startsWith("plugins/")) { + return 'Package location must start with "plugins/".'; + } + + const locationPath = path.resolve(location); + if (fs.existsSync(locationPath)) { + return `The target location already exists "${location}".`; + } + + return true; + } + } + ]; + }, + generate: async ({ input, ora }) => { + ora.start(`Creating plugin...`); + + try { + const { pluginName, location, pluginType } = input; + + const sourcePath = path.join(__dirname, "templates", pluginType); + + if (fs.existsSync(location)) { + throw new WebinyError(`The target location already exists "${location}"`); + } + + const project = getProject(); + + // + const baseTsConfigFullPath = path.resolve(project.root, "tsconfig.json"); + const baseTsConfigRelativePath = path.relative(location, baseTsConfigFullPath); + + fs.mkdirSync(location, { recursive: true }); + + // Copy template files + await ncp(sourcePath, location); + + const codeReplacements = [ + { find: "PACKAGE_NAME", replaceWith: pluginName }, + { + find: "BASE_TSCONFIG_PATH", + replaceWith: baseTsConfigRelativePath + } + ]; + + replaceInPath(path.join(location, "**/*.*"), codeReplacements); + + const apiScaffoldsIndexTsPath = path.join( + "apps", + "api", + "graphql", + "src", + "plugins", + "scaffolds", + "index.ts" + ); + + await updateScaffoldsIndexFile({ + scaffoldsIndexPath: apiScaffoldsIndexTsPath, + importName: pluginName, + importPath: pluginName + }); + + // Add package to workspaces + const rootPackageJsonPath = path.join(project.root, "package.json"); + const rootPackageJson = await readJson(rootPackageJsonPath); + if (!rootPackageJson.workspaces.packages.includes(location)) { + rootPackageJson.workspaces.packages.push(location); + await writeJson(rootPackageJsonPath, rootPackageJson); + } + + // Once everything is done, run `yarn` so the new packages are automatically installed. + await execa("yarn"); + + ora.succeed("New plugin created."); + } catch (err) { + ora.fail("Could not create plugin. Please check the logs below."); + console.log(err); + } + } + } +}); diff --git a/packages/cli-plugin-scaffold-plugin/templates/admin/package.json b/packages/cli-plugin-scaffold-plugin/templates/admin/package.json new file mode 100644 index 00000000000..a05c512306d --- /dev/null +++ b/packages/cli-plugin-scaffold-plugin/templates/admin/package.json @@ -0,0 +1,4 @@ +{ + "name": "PACKAGE_NAME", + "main": "src/index.ts" +} \ No newline at end of file diff --git a/packages/cli-plugin-scaffold-plugin/templates/admin/src/index.tsx b/packages/cli-plugin-scaffold-plugin/templates/admin/src/index.tsx new file mode 100644 index 00000000000..4a8f4a35ff8 --- /dev/null +++ b/packages/cli-plugin-scaffold-plugin/templates/admin/src/index.tsx @@ -0,0 +1,5 @@ +import React from "react"; + +export default () => { + return <>; +}; diff --git a/packages/cli-plugin-scaffold-plugin/templates/admin/tsconfig.json b/packages/cli-plugin-scaffold-plugin/templates/admin/tsconfig.json new file mode 100644 index 00000000000..752a892f3ef --- /dev/null +++ b/packages/cli-plugin-scaffold-plugin/templates/admin/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "BASE_TSCONFIG_PATH", + "include": ["src"] +} \ No newline at end of file diff --git a/packages/cli-plugin-scaffold-plugin/templates/api/package.json b/packages/cli-plugin-scaffold-plugin/templates/api/package.json new file mode 100644 index 00000000000..a05c512306d --- /dev/null +++ b/packages/cli-plugin-scaffold-plugin/templates/api/package.json @@ -0,0 +1,4 @@ +{ + "name": "PACKAGE_NAME", + "main": "src/index.ts" +} \ No newline at end of file diff --git a/packages/cli-plugin-scaffold-plugin/templates/api/src/index.tsx b/packages/cli-plugin-scaffold-plugin/templates/api/src/index.tsx new file mode 100644 index 00000000000..bd87ef83e7e --- /dev/null +++ b/packages/cli-plugin-scaffold-plugin/templates/api/src/index.tsx @@ -0,0 +1,3 @@ +export default () => { + return []; +}; diff --git a/packages/cli-plugin-scaffold-plugin/templates/api/tsconfig.json b/packages/cli-plugin-scaffold-plugin/templates/api/tsconfig.json new file mode 100644 index 00000000000..752a892f3ef --- /dev/null +++ b/packages/cli-plugin-scaffold-plugin/templates/api/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "BASE_TSCONFIG_PATH", + "include": ["src"] +} \ No newline at end of file diff --git a/packages/cli-plugin-scaffold-plugin/tsconfig.build.json b/packages/cli-plugin-scaffold-plugin/tsconfig.build.json new file mode 100644 index 00000000000..b4b3446f615 --- /dev/null +++ b/packages/cli-plugin-scaffold-plugin/tsconfig.build.json @@ -0,0 +1,15 @@ +{ + "extends": "../../tsconfig.build.json", + "include": ["src"], + "references": [ + { "path": "../cli-plugin-scaffold/tsconfig.build.json" }, + { "path": "../error/tsconfig.build.json" } + ], + "compilerOptions": { + "rootDir": "./src", + "outDir": "./dist", + "declarationDir": "./dist", + "paths": { "~/*": ["./src/*"], "~tests/*": ["./__tests__/*"] }, + "baseUrl": "." + } +} diff --git a/packages/cli-plugin-scaffold-plugin/tsconfig.json b/packages/cli-plugin-scaffold-plugin/tsconfig.json new file mode 100644 index 00000000000..442dd9125b9 --- /dev/null +++ b/packages/cli-plugin-scaffold-plugin/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "../../tsconfig.json", + "include": ["src", "__tests__"], + "references": [{ "path": "../cli-plugin-scaffold" }, { "path": "../error" }], + "compilerOptions": { + "rootDirs": ["./src", "./__tests__"], + "outDir": "./dist", + "declarationDir": "./dist", + "paths": { + "~/*": ["./src/*"], + "~tests/*": ["./__tests__/*"], + "@webiny/cli-plugin-scaffold/*": ["../cli-plugin-scaffold/src/*"], + "@webiny/cli-plugin-scaffold": ["../cli-plugin-scaffold/src"], + "@webiny/error/*": ["../error/src/*"], + "@webiny/error": ["../error/src"] + }, + "baseUrl": "." + } +} diff --git a/packages/cli-plugin-scaffold-plugin/webiny.config.js b/packages/cli-plugin-scaffold-plugin/webiny.config.js new file mode 100644 index 00000000000..8fdd233fdef --- /dev/null +++ b/packages/cli-plugin-scaffold-plugin/webiny.config.js @@ -0,0 +1,18 @@ +const util = require("util"); +const path = require("path"); +const ncpBase = require("ncp"); +const ncp = util.promisify(ncpBase.ncp); + +const { createWatchPackage, createBuildPackage } = require("@webiny/project-utils"); + +module.exports = { + commands: { + build: async (options, context) => { + await createBuildPackage({ cwd: __dirname })(options, context); + const from = path.join(__dirname, "template"); + const to = path.join(__dirname, "dist/template"); + await ncp(from, to); + }, + watch: createWatchPackage({ cwd: __dirname }) + } +}; From 9c732d68e615085421f746bc556e0ebe2e1d5cc7 Mon Sep 17 00:00:00 2001 From: adrians5j Date: Sat, 4 May 2024 16:10:00 +0200 Subject: [PATCH 02/32] wip: create essential plugins scaffold --- .../templates/admin/src/index.tsx | 5 -- .../templates/api/src/index.tsx | 3 - .../cli-plugin-scaffold-plugins/.babelrc.js | 1 + packages/cli-plugin-scaffold-plugins/LICENSE | 21 ++++++ .../README.md | 10 +-- .../package.json | 4 +- .../src/generators/admin.ts | 21 ++++++ .../src/generators/api.ts | 29 +++++++++ .../src/generators/index.ts | 8 +++ .../src/index.ts | 65 ++++++++++--------- .../cli-plugin-scaffold-plugins/src/types.ts | 8 +++ .../templates/admin/package.json | 5 ++ .../templates/admin/src/index.tsx | 3 + .../templates/admin/tsconfig.json | 0 .../templates/api/package.json | 5 ++ .../templates/api/src/index.ts | 3 + .../templates/api/tsconfig.json | 0 .../tsconfig.build.json | 0 .../tsconfig.json | 0 .../webiny.config.js | 4 +- 20 files changed, 147 insertions(+), 48 deletions(-) delete mode 100644 packages/cli-plugin-scaffold-plugin/templates/admin/src/index.tsx delete mode 100644 packages/cli-plugin-scaffold-plugin/templates/api/src/index.tsx create mode 100644 packages/cli-plugin-scaffold-plugins/.babelrc.js create mode 100644 packages/cli-plugin-scaffold-plugins/LICENSE rename packages/{cli-plugin-scaffold-plugin => cli-plugin-scaffold-plugins}/README.md (66%) rename packages/{cli-plugin-scaffold-plugin => cli-plugin-scaffold-plugins}/package.json (93%) create mode 100644 packages/cli-plugin-scaffold-plugins/src/generators/admin.ts create mode 100644 packages/cli-plugin-scaffold-plugins/src/generators/api.ts create mode 100644 packages/cli-plugin-scaffold-plugins/src/generators/index.ts rename packages/{cli-plugin-scaffold-plugin => cli-plugin-scaffold-plugins}/src/index.ts (74%) create mode 100644 packages/cli-plugin-scaffold-plugins/src/types.ts create mode 100644 packages/cli-plugin-scaffold-plugins/templates/admin/package.json create mode 100644 packages/cli-plugin-scaffold-plugins/templates/admin/src/index.tsx rename packages/{cli-plugin-scaffold-plugin => cli-plugin-scaffold-plugins}/templates/admin/tsconfig.json (100%) create mode 100644 packages/cli-plugin-scaffold-plugins/templates/api/package.json create mode 100644 packages/cli-plugin-scaffold-plugins/templates/api/src/index.ts rename packages/{cli-plugin-scaffold-plugin => cli-plugin-scaffold-plugins}/templates/api/tsconfig.json (100%) rename packages/{cli-plugin-scaffold-plugin => cli-plugin-scaffold-plugins}/tsconfig.build.json (100%) rename packages/{cli-plugin-scaffold-plugin => cli-plugin-scaffold-plugins}/tsconfig.json (100%) rename packages/{cli-plugin-scaffold-plugin => cli-plugin-scaffold-plugins}/webiny.config.js (79%) diff --git a/packages/cli-plugin-scaffold-plugin/templates/admin/src/index.tsx b/packages/cli-plugin-scaffold-plugin/templates/admin/src/index.tsx deleted file mode 100644 index 4a8f4a35ff8..00000000000 --- a/packages/cli-plugin-scaffold-plugin/templates/admin/src/index.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import React from "react"; - -export default () => { - return <>; -}; diff --git a/packages/cli-plugin-scaffold-plugin/templates/api/src/index.tsx b/packages/cli-plugin-scaffold-plugin/templates/api/src/index.tsx deleted file mode 100644 index bd87ef83e7e..00000000000 --- a/packages/cli-plugin-scaffold-plugin/templates/api/src/index.tsx +++ /dev/null @@ -1,3 +0,0 @@ -export default () => { - return []; -}; diff --git a/packages/cli-plugin-scaffold-plugins/.babelrc.js b/packages/cli-plugin-scaffold-plugins/.babelrc.js new file mode 100644 index 00000000000..9da7674cb52 --- /dev/null +++ b/packages/cli-plugin-scaffold-plugins/.babelrc.js @@ -0,0 +1 @@ +module.exports = require("@webiny/project-utils").createBabelConfigForNode({ path: __dirname }); diff --git a/packages/cli-plugin-scaffold-plugins/LICENSE b/packages/cli-plugin-scaffold-plugins/LICENSE new file mode 100644 index 00000000000..f772d04d4db --- /dev/null +++ b/packages/cli-plugin-scaffold-plugins/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) Webiny + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/cli-plugin-scaffold-plugin/README.md b/packages/cli-plugin-scaffold-plugins/README.md similarity index 66% rename from packages/cli-plugin-scaffold-plugin/README.md rename to packages/cli-plugin-scaffold-plugins/README.md index 6eca2222e46..cb234e1434e 100644 --- a/packages/cli-plugin-scaffold-plugin/README.md +++ b/packages/cli-plugin-scaffold-plugins/README.md @@ -1,7 +1,7 @@ -# @webiny/cli-plugin-scaffold-plugin +# @webiny/cli-plugin-scaffold-plugins -[![](https://img.shields.io/npm/dw/@webiny/cli-plugin-scaffold-plugin.svg)](https://www.npmjs.com/package/@webiny/cli-plugin-scaffold-plugin) -[![](https://img.shields.io/npm/v/@webiny/cli-plugin-scaffold-plugin.svg)](https://www.npmjs.com/package/@webiny/cli-plugin-scaffold-plugin) +[![](https://img.shields.io/npm/dw/@webiny/cli-plugin-scaffold-plugins.svg)](https://www.npmjs.com/package/@webiny/cli-plugin-scaffold-plugins) +[![](https://img.shields.io/npm/v/@webiny/cli-plugin-scaffold-plugins.svg)](https://www.npmjs.com/package/@webiny/cli-plugin-scaffold-plugins) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com) @@ -10,7 +10,7 @@ A plugin for @webiny/cli-plugin-scaffold that generates a simple React component ## Install ``` -yarn add @webiny/cli-plugin-scaffold-plugin +yarn add @webiny/cli-plugin-scaffold-plugins ``` Add the plugin to your project by editing `webiny.project.js`: @@ -19,7 +19,7 @@ Add the plugin to your project by editing `webiny.project.js`: module.exports = { projectName: "my-project", cli: { - plugins: [require("@webiny/cli-plugin-scaffold-plugin").default(),] + plugins: [require("@webiny/cli-plugin-scaffold-plugins").default(),] } }; ``` diff --git a/packages/cli-plugin-scaffold-plugin/package.json b/packages/cli-plugin-scaffold-plugins/package.json similarity index 93% rename from packages/cli-plugin-scaffold-plugin/package.json rename to packages/cli-plugin-scaffold-plugins/package.json index f1826daa05d..5317d464f00 100644 --- a/packages/cli-plugin-scaffold-plugin/package.json +++ b/packages/cli-plugin-scaffold-plugins/package.json @@ -1,5 +1,5 @@ { - "name": "@webiny/cli-plugin-scaffold-plugin", + "name": "@webiny/cli-plugin-scaffold-plugins", "version": "0.0.0", "description": "Scaffolds essential files for creating a new plugin.", "main": "index.js", @@ -7,7 +7,7 @@ "repository": { "type": "git", "url": "git+https://github.com/webiny/webiny-js.git", - "directory": "packages/cli-plugin-scaffold-plugin" + "directory": "packages/cli-plugin-scaffold-plugins" }, "author": { "name": "Webiny", diff --git a/packages/cli-plugin-scaffold-plugins/src/generators/admin.ts b/packages/cli-plugin-scaffold-plugins/src/generators/admin.ts new file mode 100644 index 00000000000..f5b3891c26a --- /dev/null +++ b/packages/cli-plugin-scaffold-plugins/src/generators/admin.ts @@ -0,0 +1,21 @@ +import path from "path"; +import { updateScaffoldsIndexFile } from "@webiny/cli-plugin-scaffold/utils"; +import { PluginGenerator } from "~/types"; + +export const adminGenerator: PluginGenerator = async ({ input }) => { + const apiScaffoldsIndexTsPath = path.join( + "apps", + "api", + "graphql", + "src", + "plugins", + "scaffolds", + "index.ts" + ); + + await updateScaffoldsIndexFile({ + scaffoldsIndexPath: apiScaffoldsIndexTsPath, + importName: input.pluginName, + importPath: input.pluginName + }); +}; diff --git a/packages/cli-plugin-scaffold-plugins/src/generators/api.ts b/packages/cli-plugin-scaffold-plugins/src/generators/api.ts new file mode 100644 index 00000000000..fa4f15c83f6 --- /dev/null +++ b/packages/cli-plugin-scaffold-plugins/src/generators/api.ts @@ -0,0 +1,29 @@ +import path from "path"; +import { updateScaffoldsIndexFile } from "@webiny/cli-plugin-scaffold/utils"; +import { PluginGenerator } from "~/types"; + +export const apiGenerator: PluginGenerator = async ({ input }) => { + const apiScaffoldsIndexTsPath = path.join( + "apps", + "api", + "graphql", + "src", + "plugins", + "scaffolds", + "index.ts" + ); + + const scaffoldsIndexPath = apiScaffoldsIndexTsPath; + + const pluginsFactory = input.pluginName + "PluginsFactory"; + const importName = "{ createPlugins as " + pluginsFactory + " }"; + const importPath = input.packageName; + const pluginsArrayElement = pluginsFactory + '()' + + await updateScaffoldsIndexFile({ + scaffoldsIndexPath, + importName, + importPath, + pluginsArrayElement + }); +}; diff --git a/packages/cli-plugin-scaffold-plugins/src/generators/index.ts b/packages/cli-plugin-scaffold-plugins/src/generators/index.ts new file mode 100644 index 00000000000..66743d5a83e --- /dev/null +++ b/packages/cli-plugin-scaffold-plugins/src/generators/index.ts @@ -0,0 +1,8 @@ +import { apiGenerator } from "./api"; +import { adminGenerator } from "./admin"; +import { PluginGenerator } from "~/types"; + +export const generators: Record = { + api: apiGenerator, + admin: adminGenerator +}; diff --git a/packages/cli-plugin-scaffold-plugin/src/index.ts b/packages/cli-plugin-scaffold-plugins/src/index.ts similarity index 74% rename from packages/cli-plugin-scaffold-plugin/src/index.ts rename to packages/cli-plugin-scaffold-plugins/src/index.ts index 954620f8f88..7d7426f31cb 100644 --- a/packages/cli-plugin-scaffold-plugin/src/index.ts +++ b/packages/cli-plugin-scaffold-plugins/src/index.ts @@ -1,8 +1,4 @@ -import { - CliCommandScaffoldTemplate, - TsConfigJson, - PackageJson -} from "@webiny/cli-plugin-scaffold/types"; +import { CliCommandScaffoldTemplate, PackageJson } from "@webiny/cli-plugin-scaffold/types"; import fs from "fs"; import path from "path"; import util from "util"; @@ -12,8 +8,6 @@ import writeJson from "write-json-file"; import execa from "execa"; import Case from "case"; import { replaceInPath } from "replace-in-path"; -import chalk from "chalk"; -import indentString from "indent-string"; import WebinyError from "@webiny/error"; import validateNpmPackageName from "validate-npm-package-name"; /** @@ -21,12 +15,13 @@ import validateNpmPackageName from "validate-npm-package-name"; */ // @ts-expect-error import { getProject } from "@webiny/cli/utils"; -import { updateScaffoldsIndexFile } from "@webiny/cli-plugin-scaffold/utils"; +import { generators } from "./generators"; const ncp = util.promisify(ncpBase.ncp); interface Input { pluginName: string; + packageName: string; location: string; pluginType: string; } @@ -51,14 +46,34 @@ export default (): CliCommandScaffoldTemplate => ({ { name: "pluginName", message: "Enter the plugin name:", + default: "myCustomPlugin", validate: pluginName => { if (!pluginName) { return "Missing plugin name."; } - const isValidNpmPackageName = validateNpmPackageName(pluginName); - if (!isValidNpmPackageName) { - return `Package name must look something like "myCustomPlugin".`; + const isValidName = pluginName === Case.camel(pluginName); + if (!isValidName) { + return `Please use camel case when providing the name of the plugin (for example "myCustomPlugin").`; + } + + return true; + } + }, + { + name: "packageName", + message: "Enter the package name:", + default: (answers: Input) => { + return Case.kebab(answers.pluginName); + }, + validate: pkgName => { + if (!pkgName) { + return "Missing package name."; + } + + const isValidName = validateNpmPackageName(pkgName); + if (!isValidName) { + return `Package name must look something like "my-custom-plugin".`; } return true; @@ -68,7 +83,7 @@ export default (): CliCommandScaffoldTemplate => ({ name: "location", message: `Enter the plugin location:`, default: (answers: Input) => { - return `plugins/${Case.kebab(answers.pluginName)}`; + return `plugins/${answers.pluginName}`; }, validate: location => { if (!location) { @@ -93,7 +108,7 @@ export default (): CliCommandScaffoldTemplate => ({ ora.start(`Creating plugin...`); try { - const { pluginName, location, pluginType } = input; + const { pluginType, pluginName, packageName, location } = input; const sourcePath = path.join(__dirname, "templates", pluginType); @@ -103,7 +118,6 @@ export default (): CliCommandScaffoldTemplate => ({ const project = getProject(); - // const baseTsConfigFullPath = path.resolve(project.root, "tsconfig.json"); const baseTsConfigRelativePath = path.relative(location, baseTsConfigFullPath); @@ -113,7 +127,7 @@ export default (): CliCommandScaffoldTemplate => ({ await ncp(sourcePath, location); const codeReplacements = [ - { find: "PACKAGE_NAME", replaceWith: pluginName }, + { find: "PACKAGE_NAME", replaceWith: packageName }, { find: "BASE_TSCONFIG_PATH", replaceWith: baseTsConfigRelativePath @@ -122,22 +136,6 @@ export default (): CliCommandScaffoldTemplate => ({ replaceInPath(path.join(location, "**/*.*"), codeReplacements); - const apiScaffoldsIndexTsPath = path.join( - "apps", - "api", - "graphql", - "src", - "plugins", - "scaffolds", - "index.ts" - ); - - await updateScaffoldsIndexFile({ - scaffoldsIndexPath: apiScaffoldsIndexTsPath, - importName: pluginName, - importPath: pluginName - }); - // Add package to workspaces const rootPackageJsonPath = path.join(project.root, "package.json"); const rootPackageJson = await readJson(rootPackageJsonPath); @@ -146,12 +144,17 @@ export default (): CliCommandScaffoldTemplate => ({ await writeJson(rootPackageJsonPath, rootPackageJson); } + if (typeof generators[pluginType] === "function") { + await generators[pluginType]({ input }); + } + // Once everything is done, run `yarn` so the new packages are automatically installed. await execa("yarn"); ora.succeed("New plugin created."); } catch (err) { ora.fail("Could not create plugin. Please check the logs below."); + console.log(); console.log(err); } } diff --git a/packages/cli-plugin-scaffold-plugins/src/types.ts b/packages/cli-plugin-scaffold-plugins/src/types.ts new file mode 100644 index 00000000000..5f9fe871b03 --- /dev/null +++ b/packages/cli-plugin-scaffold-plugins/src/types.ts @@ -0,0 +1,8 @@ +interface PluginGeneratorParams { + input: { + pluginName: string; + packageName: string; + }; +} + +export type PluginGenerator = (params: PluginGeneratorParams) => Promise; diff --git a/packages/cli-plugin-scaffold-plugins/templates/admin/package.json b/packages/cli-plugin-scaffold-plugins/templates/admin/package.json new file mode 100644 index 00000000000..449720b0269 --- /dev/null +++ b/packages/cli-plugin-scaffold-plugins/templates/admin/package.json @@ -0,0 +1,5 @@ +{ + "name": "PACKAGE_NAME", + "main": "src/index.ts", + "version": "1.0.0" +} \ No newline at end of file diff --git a/packages/cli-plugin-scaffold-plugins/templates/admin/src/index.tsx b/packages/cli-plugin-scaffold-plugins/templates/admin/src/index.tsx new file mode 100644 index 00000000000..dfc9d199f64 --- /dev/null +++ b/packages/cli-plugin-scaffold-plugins/templates/admin/src/index.tsx @@ -0,0 +1,3 @@ +import React from "react"; + +export const createPlugins = () => <>{/*Your plugins here.*/}; diff --git a/packages/cli-plugin-scaffold-plugin/templates/admin/tsconfig.json b/packages/cli-plugin-scaffold-plugins/templates/admin/tsconfig.json similarity index 100% rename from packages/cli-plugin-scaffold-plugin/templates/admin/tsconfig.json rename to packages/cli-plugin-scaffold-plugins/templates/admin/tsconfig.json diff --git a/packages/cli-plugin-scaffold-plugins/templates/api/package.json b/packages/cli-plugin-scaffold-plugins/templates/api/package.json new file mode 100644 index 00000000000..449720b0269 --- /dev/null +++ b/packages/cli-plugin-scaffold-plugins/templates/api/package.json @@ -0,0 +1,5 @@ +{ + "name": "PACKAGE_NAME", + "main": "src/index.ts", + "version": "1.0.0" +} \ No newline at end of file diff --git a/packages/cli-plugin-scaffold-plugins/templates/api/src/index.ts b/packages/cli-plugin-scaffold-plugins/templates/api/src/index.ts new file mode 100644 index 00000000000..f7ac3fa8533 --- /dev/null +++ b/packages/cli-plugin-scaffold-plugins/templates/api/src/index.ts @@ -0,0 +1,3 @@ +export const createPlugins = () => [ + // Your plugins here. +]; \ No newline at end of file diff --git a/packages/cli-plugin-scaffold-plugin/templates/api/tsconfig.json b/packages/cli-plugin-scaffold-plugins/templates/api/tsconfig.json similarity index 100% rename from packages/cli-plugin-scaffold-plugin/templates/api/tsconfig.json rename to packages/cli-plugin-scaffold-plugins/templates/api/tsconfig.json diff --git a/packages/cli-plugin-scaffold-plugin/tsconfig.build.json b/packages/cli-plugin-scaffold-plugins/tsconfig.build.json similarity index 100% rename from packages/cli-plugin-scaffold-plugin/tsconfig.build.json rename to packages/cli-plugin-scaffold-plugins/tsconfig.build.json diff --git a/packages/cli-plugin-scaffold-plugin/tsconfig.json b/packages/cli-plugin-scaffold-plugins/tsconfig.json similarity index 100% rename from packages/cli-plugin-scaffold-plugin/tsconfig.json rename to packages/cli-plugin-scaffold-plugins/tsconfig.json diff --git a/packages/cli-plugin-scaffold-plugin/webiny.config.js b/packages/cli-plugin-scaffold-plugins/webiny.config.js similarity index 79% rename from packages/cli-plugin-scaffold-plugin/webiny.config.js rename to packages/cli-plugin-scaffold-plugins/webiny.config.js index 8fdd233fdef..240ce95d511 100644 --- a/packages/cli-plugin-scaffold-plugin/webiny.config.js +++ b/packages/cli-plugin-scaffold-plugins/webiny.config.js @@ -9,8 +9,8 @@ module.exports = { commands: { build: async (options, context) => { await createBuildPackage({ cwd: __dirname })(options, context); - const from = path.join(__dirname, "template"); - const to = path.join(__dirname, "dist/template"); + const from = path.join(__dirname, "templates"); + const to = path.join(__dirname, "dist/templates"); await ncp(from, to); }, watch: createWatchPackage({ cwd: __dirname }) From 71958c878d05985cdec02cd60cdb83d6066da694 Mon Sep 17 00:00:00 2001 From: adrians5j Date: Sat, 4 May 2024 16:11:57 +0200 Subject: [PATCH 03/32] wip: create essential plugins scaffold --- .../src/utils/updateScaffoldsIndexFile.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/cli-plugin-scaffold/src/utils/updateScaffoldsIndexFile.ts b/packages/cli-plugin-scaffold/src/utils/updateScaffoldsIndexFile.ts index be0e4994e1f..9d6fe544bf6 100644 --- a/packages/cli-plugin-scaffold/src/utils/updateScaffoldsIndexFile.ts +++ b/packages/cli-plugin-scaffold/src/utils/updateScaffoldsIndexFile.ts @@ -4,9 +4,10 @@ interface Params { scaffoldsIndexPath: string; importName: string; importPath: string; + pluginsArrayElement?: string; } export default async (params: Params): Promise => { - const { scaffoldsIndexPath, importName, importPath } = params; + const { scaffoldsIndexPath, importName, importPath, pluginsArrayElement } = params; const project = new Project(); project.addSourceFileAtPath(scaffoldsIndexPath); @@ -34,7 +35,7 @@ export default async (params: Params): Promise => { Node.isArrayLiteralExpression(node) ) as ArrayLiteralExpression; - pluginsArray.addElement(importName); + pluginsArray.addElement(pluginsArrayElement || importName); await source.save(); }; From 3ac716abe7e813b23100c1e42507dc23631e303e Mon Sep 17 00:00:00 2001 From: adrians5j Date: Sat, 4 May 2024 16:12:11 +0200 Subject: [PATCH 04/32] wip: create essential plugins scaffold --- .../cli-plugin-scaffold-plugin/templates/admin/package.json | 4 ---- .../cli-plugin-scaffold-plugin/templates/api/package.json | 4 ---- 2 files changed, 8 deletions(-) delete mode 100644 packages/cli-plugin-scaffold-plugin/templates/admin/package.json delete mode 100644 packages/cli-plugin-scaffold-plugin/templates/api/package.json diff --git a/packages/cli-plugin-scaffold-plugin/templates/admin/package.json b/packages/cli-plugin-scaffold-plugin/templates/admin/package.json deleted file mode 100644 index a05c512306d..00000000000 --- a/packages/cli-plugin-scaffold-plugin/templates/admin/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "PACKAGE_NAME", - "main": "src/index.ts" -} \ No newline at end of file diff --git a/packages/cli-plugin-scaffold-plugin/templates/api/package.json b/packages/cli-plugin-scaffold-plugin/templates/api/package.json deleted file mode 100644 index a05c512306d..00000000000 --- a/packages/cli-plugin-scaffold-plugin/templates/api/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "PACKAGE_NAME", - "main": "src/index.ts" -} \ No newline at end of file From 4f61e64f6d15674db5a5c8f11c41f1528de2a166 Mon Sep 17 00:00:00 2001 From: adrians5j Date: Sat, 4 May 2024 16:12:24 +0200 Subject: [PATCH 05/32] wip: create api-sls-cms package --- .../.babelrc.js | 0 .../LICENSE | 0 packages/api-serverless-cms/README.md | 15 +++++++ packages/api-serverless-cms/package.json | 31 ++++++++++++++ packages/api-serverless-cms/src/index.ts | 40 +++++++++++++++++++ .../api-serverless-cms/tsconfig.build.json | 15 +++++++ packages/api-serverless-cms/tsconfig.json | 19 +++++++++ packages/api-serverless-cms/webiny.config.js | 8 ++++ 8 files changed, 128 insertions(+) rename packages/{cli-plugin-scaffold-plugin => api-serverless-cms}/.babelrc.js (100%) rename packages/{cli-plugin-scaffold-plugin => api-serverless-cms}/LICENSE (100%) create mode 100644 packages/api-serverless-cms/README.md create mode 100644 packages/api-serverless-cms/package.json create mode 100644 packages/api-serverless-cms/src/index.ts create mode 100644 packages/api-serverless-cms/tsconfig.build.json create mode 100644 packages/api-serverless-cms/tsconfig.json create mode 100644 packages/api-serverless-cms/webiny.config.js diff --git a/packages/cli-plugin-scaffold-plugin/.babelrc.js b/packages/api-serverless-cms/.babelrc.js similarity index 100% rename from packages/cli-plugin-scaffold-plugin/.babelrc.js rename to packages/api-serverless-cms/.babelrc.js diff --git a/packages/cli-plugin-scaffold-plugin/LICENSE b/packages/api-serverless-cms/LICENSE similarity index 100% rename from packages/cli-plugin-scaffold-plugin/LICENSE rename to packages/api-serverless-cms/LICENSE diff --git a/packages/api-serverless-cms/README.md b/packages/api-serverless-cms/README.md new file mode 100644 index 00000000000..fc99886f597 --- /dev/null +++ b/packages/api-serverless-cms/README.md @@ -0,0 +1,15 @@ +# @webiny/api-serverless-cms +[![](https://img.shields.io/npm/dw/@webiny/api-serverless-cms.svg)](https://www.npmjs.com/package/@webiny/api-serverless-cms) +[![](https://img.shields.io/npm/v/@webiny/api-serverless-cms.svg)](https://www.npmjs.com/package/@webiny/api-serverless-cms) +[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier) +[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com) + +## Install +``` +npm install --save @webiny/api-serverless-cms +``` + +Or if you prefer yarn: +``` +yarn add @webiny/api-serverless-cms +``` diff --git a/packages/api-serverless-cms/package.json b/packages/api-serverless-cms/package.json new file mode 100644 index 00000000000..a20c2135957 --- /dev/null +++ b/packages/api-serverless-cms/package.json @@ -0,0 +1,31 @@ +{ + "name": "@webiny/api-serverless-cms", + "version": "0.0.0", + "main": "index.js", + "repository": { + "type": "git", + "url": "https://github.com/webiny/webiny-js.git" + }, + "description": "Core package for all of our API packages.", + "license": "MIT", + "devDependencies": { + "@babel/cli": "^7.23.9", + "@babel/core": "^7.24.0", + "@babel/preset-env": "^7.24.0", + "@babel/preset-typescript": "^7.23.3", + "@webiny/cli": "0.0.0", + "@webiny/project-utils": "0.0.0", + "rimraf": "^5.0.5", + "ttypescript": "^1.5.13", + "typescript": "4.7.4" + }, + "publishConfig": { + "access": "public", + "directory": "dist" + }, + "scripts": { + "build": "yarn webiny run build", + "watch": "yarn webiny run watch" + }, + "gitHead": "8476da73b653c89cc1474d968baf55c1b0ae0e5f" +} diff --git a/packages/api-serverless-cms/src/index.ts b/packages/api-serverless-cms/src/index.ts new file mode 100644 index 00000000000..1fde469c0e4 --- /dev/null +++ b/packages/api-serverless-cms/src/index.ts @@ -0,0 +1,40 @@ +import { ClientContext } from "@webiny/handler-client/types"; +import { TenancyContext } from "@webiny/api-tenancy/types"; +import { SecurityContext } from "@webiny/api-security/types"; +import { I18NContext } from "@webiny/api-i18n/types"; +import { I18NContentContext } from "@webiny/api-i18n-content/types"; +import { PbContext } from "@webiny/api-page-builder/graphql/types"; +import { PrerenderingServiceClientContext } from "@webiny/api-prerendering-service/client/types"; +import { FileManagerContext } from "@webiny/api-file-manager/types"; +import { FormBuilderContext } from "@webiny/api-form-builder/types"; +import { CmsContext } from "@webiny/api-headless-cms/types"; +import { AcoContext } from "@webiny/api-aco/types"; +import { PbAcoContext } from "@webiny/api-page-builder-aco/types"; + +import { createContextPlugin as baseCreateContextPlugin, ContextPluginCallable } from "@webiny/api"; + +// When working with the `context` object (for example while defining a new GraphQL resolver function), +// you can import this interface and assign it to it. This will give you full autocomplete functionality +// and type safety. The easiest way to import it would be via the following import statement: +// import { Context } from "~/types"; +// Feel free to extend it with additional context interfaces, if needed. Also, please do not change the +// name of the interface, as existing scaffolding utilities may rely on it during the scaffolding process. +export interface Context + extends ClientContext, + TenancyContext, + SecurityContext, + I18NContext, + I18NContentContext, + PbContext, + PrerenderingServiceClientContext, + FileManagerContext, + FormBuilderContext, + AcoContext, + PbAcoContext, + CmsContext {} + +export const createContextPlugin = ( + callable: ContextPluginCallable +) => { + return baseCreateContextPlugin(callable); +}; diff --git a/packages/api-serverless-cms/tsconfig.build.json b/packages/api-serverless-cms/tsconfig.build.json new file mode 100644 index 00000000000..bcc9a624b5f --- /dev/null +++ b/packages/api-serverless-cms/tsconfig.build.json @@ -0,0 +1,15 @@ +{ + "extends": "../../tsconfig.build.json", + "include": ["src"], + "references": [ + { "path": "../aws-sdk/tsconfig.build.json" }, + { "path": "../plugins/tsconfig.build.json" } + ], + "compilerOptions": { + "rootDir": "./src", + "outDir": "./dist", + "declarationDir": "./dist", + "paths": { "~/*": ["./src/*"], "~tests/*": ["./__tests__/*"] }, + "baseUrl": "." + } +} diff --git a/packages/api-serverless-cms/tsconfig.json b/packages/api-serverless-cms/tsconfig.json new file mode 100644 index 00000000000..47c4318ae5a --- /dev/null +++ b/packages/api-serverless-cms/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "../../tsconfig.json", + "include": ["src", "__tests__"], + "references": [{ "path": "../aws-sdk" }, { "path": "../plugins" }], + "compilerOptions": { + "rootDirs": ["./src", "./__tests__"], + "outDir": "./dist", + "declarationDir": "./dist", + "paths": { + "~/*": ["./src/*"], + "~tests/*": ["./__tests__/*"], + "@webiny/aws-sdk/*": ["../aws-sdk/src/*"], + "@webiny/aws-sdk": ["../aws-sdk/src"], + "@webiny/plugins/*": ["../plugins/src/*"], + "@webiny/plugins": ["../plugins/src"] + }, + "baseUrl": "." + } +} diff --git a/packages/api-serverless-cms/webiny.config.js b/packages/api-serverless-cms/webiny.config.js new file mode 100644 index 00000000000..6dff86766c9 --- /dev/null +++ b/packages/api-serverless-cms/webiny.config.js @@ -0,0 +1,8 @@ +const { createWatchPackage, createBuildPackage } = require("@webiny/project-utils"); + +module.exports = { + commands: { + build: createBuildPackage({ cwd: __dirname }), + watch: createWatchPackage({ cwd: __dirname }) + } +}; From 441742fdfbdb69a336fd1f8b43f658b1f18c8a0a Mon Sep 17 00:00:00 2001 From: adrians5j Date: Sat, 4 May 2024 16:13:01 +0200 Subject: [PATCH 06/32] wip: create api-sls-cms package --- webiny.project.ts | 5 ++--- yarn.lock | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 3 deletions(-) diff --git a/webiny.project.ts b/webiny.project.ts index e4f4f1e02e5..86128323883 100644 --- a/webiny.project.ts +++ b/webiny.project.ts @@ -17,9 +17,8 @@ export default { import("@webiny/cli-plugin-deploy-pulumi"), import("@webiny/cwp-template-aws/cli"), import("@webiny/cli-plugin-scaffold"), - import("@webiny/cli-plugin-scaffold-graphql-service"), - import("@webiny/cli-plugin-scaffold-admin-app-module"), - import("@webiny/cli-plugin-scaffold-ci") + import("@webiny/cli-plugin-scaffold-plugins"), + import("@webiny/cli-plugin-scaffold-ci"), ]); return modules diff --git a/yarn.lock b/yarn.lock index 7789aa2ae13..95247679e9f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -14258,6 +14258,22 @@ __metadata: languageName: unknown linkType: soft +"@webiny/api-serverless-cms@workspace:packages/api-serverless-cms": + version: 0.0.0-use.local + resolution: "@webiny/api-serverless-cms@workspace:packages/api-serverless-cms" + dependencies: + "@babel/cli": ^7.23.9 + "@babel/core": ^7.24.0 + "@babel/preset-env": ^7.24.0 + "@babel/preset-typescript": ^7.23.3 + "@webiny/cli": 0.0.0 + "@webiny/project-utils": 0.0.0 + rimraf: ^5.0.5 + ttypescript: ^1.5.13 + typescript: 4.7.4 + languageName: unknown + linkType: soft + "@webiny/api-tenancy-so-ddb@0.0.0, @webiny/api-tenancy-so-ddb@workspace:packages/api-tenancy-so-ddb": version: 0.0.0-use.local resolution: "@webiny/api-tenancy-so-ddb@workspace:packages/api-tenancy-so-ddb" @@ -16171,6 +16187,36 @@ __metadata: languageName: unknown linkType: soft +"@webiny/cli-plugin-scaffold-plugins@workspace:packages/cli-plugin-scaffold-plugins": + version: 0.0.0-use.local + resolution: "@webiny/cli-plugin-scaffold-plugins@workspace:packages/cli-plugin-scaffold-plugins" + dependencies: + "@babel/cli": ^7.23.9 + "@babel/core": ^7.24.0 + "@babel/preset-env": ^7.24.0 + "@types/inquirer": ^7.3.1 + "@types/ncp": ^2.0.4 + "@types/pluralize": ^0.0.29 + "@types/validate-npm-package-name": ^3.0.3 + "@webiny/cli": 0.0.0 + "@webiny/cli-plugin-scaffold": 0.0.0 + "@webiny/error": 0.0.0 + "@webiny/project-utils": 0.0.0 + case: ^1.6.3 + chalk: ^4.1.0 + execa: ^5.0.0 + indent-string: ^4.0.0 + load-json-file: ^6.2.0 + ncp: ^2.0.0 + pluralize: ^8.0.0 + replace-in-path: ^1.1.0 + rimraf: ^5.0.5 + typescript: 4.7.4 + validate-npm-package-name: ^3.0.0 + write-json-file: ^4.3.0 + languageName: unknown + linkType: soft + "@webiny/cli-plugin-scaffold-react-app@workspace:packages/cli-plugin-scaffold-react-app": version: 0.0.0-use.local resolution: "@webiny/cli-plugin-scaffold-react-app@workspace:packages/cli-plugin-scaffold-react-app" From 91a29bacb51d7cd9620fbb5b70ff6da9733c61f2 Mon Sep 17 00:00:00 2001 From: adrians5j Date: Sun, 5 May 2024 22:39:43 +0200 Subject: [PATCH 07/32] wip: create essential plugins scaffold --- apps/admin/src/App.tsx | 2 + apps/admin/src/plugins/Scaffolds.tsx | 5 ++ .../src/generators/admin.ts | 19 +---- .../src/generators/api.ts | 27 +----- .../generators/utils/addPluginToApiApp.tsx | 61 ++++++++++++++ .../utils/addReactPluginToReactApp.tsx | 82 +++++++++++++++++++ .../cli-plugin-scaffold-plugins/src/index.ts | 6 +- .../templates/admin/package.json | 2 +- 8 files changed, 158 insertions(+), 46 deletions(-) create mode 100644 apps/admin/src/plugins/Scaffolds.tsx create mode 100644 packages/cli-plugin-scaffold-plugins/src/generators/utils/addPluginToApiApp.tsx create mode 100644 packages/cli-plugin-scaffold-plugins/src/generators/utils/addReactPluginToReactApp.tsx diff --git a/apps/admin/src/App.tsx b/apps/admin/src/App.tsx index 2773f643e51..7366e99020e 100644 --- a/apps/admin/src/App.tsx +++ b/apps/admin/src/App.tsx @@ -1,12 +1,14 @@ import React from "react"; import { Admin } from "@webiny/app-serverless-cms"; import { Cognito } from "@webiny/app-admin-users-cognito"; +import { Scaffolds } from "./plugins/Scaffolds"; import "./App.scss"; export const App = () => { return ( + ); }; diff --git a/apps/admin/src/plugins/Scaffolds.tsx b/apps/admin/src/plugins/Scaffolds.tsx new file mode 100644 index 00000000000..d2dc7a2ffa4 --- /dev/null +++ b/apps/admin/src/plugins/Scaffolds.tsx @@ -0,0 +1,5 @@ +import React from "react"; + +export const Scaffolds = () => { + return <>; +}; diff --git a/packages/cli-plugin-scaffold-plugins/src/generators/admin.ts b/packages/cli-plugin-scaffold-plugins/src/generators/admin.ts index f5b3891c26a..d26e9ccd6d3 100644 --- a/packages/cli-plugin-scaffold-plugins/src/generators/admin.ts +++ b/packages/cli-plugin-scaffold-plugins/src/generators/admin.ts @@ -1,21 +1,6 @@ -import path from "path"; -import { updateScaffoldsIndexFile } from "@webiny/cli-plugin-scaffold/utils"; +import { addReactPluginToReactApp } from "./utils/addReactPluginToReactApp"; import { PluginGenerator } from "~/types"; export const adminGenerator: PluginGenerator = async ({ input }) => { - const apiScaffoldsIndexTsPath = path.join( - "apps", - "api", - "graphql", - "src", - "plugins", - "scaffolds", - "index.ts" - ); - - await updateScaffoldsIndexFile({ - scaffoldsIndexPath: apiScaffoldsIndexTsPath, - importName: input.pluginName, - importPath: input.pluginName - }); + await addReactPluginToReactApp(input); }; diff --git a/packages/cli-plugin-scaffold-plugins/src/generators/api.ts b/packages/cli-plugin-scaffold-plugins/src/generators/api.ts index fa4f15c83f6..bfd8a55f7cc 100644 --- a/packages/cli-plugin-scaffold-plugins/src/generators/api.ts +++ b/packages/cli-plugin-scaffold-plugins/src/generators/api.ts @@ -1,29 +1,6 @@ -import path from "path"; -import { updateScaffoldsIndexFile } from "@webiny/cli-plugin-scaffold/utils"; +import { addPluginToApiApp } from "./utils/addPluginToApiApp"; import { PluginGenerator } from "~/types"; export const apiGenerator: PluginGenerator = async ({ input }) => { - const apiScaffoldsIndexTsPath = path.join( - "apps", - "api", - "graphql", - "src", - "plugins", - "scaffolds", - "index.ts" - ); - - const scaffoldsIndexPath = apiScaffoldsIndexTsPath; - - const pluginsFactory = input.pluginName + "PluginsFactory"; - const importName = "{ createPlugins as " + pluginsFactory + " }"; - const importPath = input.packageName; - const pluginsArrayElement = pluginsFactory + '()' - - await updateScaffoldsIndexFile({ - scaffoldsIndexPath, - importName, - importPath, - pluginsArrayElement - }); + await addPluginToApiApp(input); }; diff --git a/packages/cli-plugin-scaffold-plugins/src/generators/utils/addPluginToApiApp.tsx b/packages/cli-plugin-scaffold-plugins/src/generators/utils/addPluginToApiApp.tsx new file mode 100644 index 00000000000..f3218a3eb7e --- /dev/null +++ b/packages/cli-plugin-scaffold-plugins/src/generators/utils/addPluginToApiApp.tsx @@ -0,0 +1,61 @@ +import { Project, ArrayLiteralExpression, Node } from "ts-morph"; +import path from "path"; +import { formatCode } from "@webiny/cli-plugin-scaffold/utils"; + +interface Params { + pluginName: string; + packageName: string; +} + +export const addPluginToApiApp = async (params: Params): Promise => { + const { pluginName, packageName } = params; + + const scaffoldsFilePath = path.join( + "apps", + "api", + "graphql", + "src", + "plugins", + "scaffolds", + "index.ts" + ); + + const pluginsFactory = pluginName + "PluginsFactory"; + const importName = "{ createPlugins as " + pluginsFactory + " }"; + const importPath = packageName; + + const project = new Project(); + project.addSourceFileAtPath(scaffoldsFilePath); + + const source = project.getSourceFileOrThrow(scaffoldsFilePath); + + const existingImportDeclaration = source.getImportDeclaration(importPath); + if (existingImportDeclaration) { + throw new Error( + `Could not import "${importPath}" in "${scaffoldsFilePath}" as it already exists.` + ); + } + + let index = 1; + + const importDeclarations = source.getImportDeclarations(); + if (importDeclarations.length) { + const last = importDeclarations[importDeclarations.length - 1]; + index = last.getChildIndex() + 1; + } + + source.insertImportDeclaration(index, { + defaultImport: importName, + moduleSpecifier: importPath + }); + + const pluginsArray = source.getFirstDescendant(node => + Node.isArrayLiteralExpression(node) + ) as ArrayLiteralExpression; + + pluginsArray.addElement(pluginsFactory); + + await source.save(); + + await formatCode(scaffoldsFilePath, {}); +}; diff --git a/packages/cli-plugin-scaffold-plugins/src/generators/utils/addReactPluginToReactApp.tsx b/packages/cli-plugin-scaffold-plugins/src/generators/utils/addReactPluginToReactApp.tsx new file mode 100644 index 00000000000..db17b51badf --- /dev/null +++ b/packages/cli-plugin-scaffold-plugins/src/generators/utils/addReactPluginToReactApp.tsx @@ -0,0 +1,82 @@ +import { Project, Node, JsxFragment } from "ts-morph"; +import path from "path"; +import {formatCode} from "@webiny/cli-plugin-scaffold/utils"; + +interface Params { + pluginName: string; + packageName: string; +} + +export const addReactPluginToReactApp = async (params: Params): Promise => { + const { pluginName, packageName } = params; + + const scaffoldsFilePath = path.join("apps", "admin", "src", "plugins", "Scaffolds.tsx"); + + const pluginsFactory = pluginName + "PluginsFactory"; + const importName = "{ createPlugins as " + pluginsFactory + " }"; + const importPath = packageName; + + const project = new Project(); + project.addSourceFileAtPath(scaffoldsFilePath); + + const source = project.getSourceFileOrThrow(scaffoldsFilePath); + + const existingImportDeclaration = source.getImportDeclaration(importPath); + if (existingImportDeclaration) { + throw new Error( + `Could not import "${importPath}" in "${scaffoldsFilePath}" as it already exists.` + ); + } + + let index = 1; + + const importDeclarations = source.getImportDeclarations(); + if (importDeclarations.length) { + const last = importDeclarations[importDeclarations.length - 1]; + index = last.getChildIndex() + 1; + } + + source.insertImportDeclaration(index, { + defaultImport: importName, + moduleSpecifier: importPath + }); + + const scaffoldsIdentifier = source.getFirstDescendant(node => { + if (!Node.isIdentifier(node)) { + return false; + } + + return node.getText() === "Scaffolds"; + }); + + if (!scaffoldsIdentifier) { + throw new Error( + `Could not find the "Scaffolds" React component in "${scaffoldsFilePath}". Did you maybe change the name of the component?` + ); + } + + const scaffoldsArrowFn = scaffoldsIdentifier.getNextSibling(node => Node.isArrowFunction(node)); + if (!scaffoldsArrowFn) { + throw new Error( + `Could not find the "Scaffolds" React component in "${scaffoldsFilePath}". Did you maybe change its definition? It should be an arrow function.` + ); + } + + const scaffoldsArrowFnFragment = scaffoldsArrowFn.getFirstDescendant(node => { + return Node.isJsxFragment(node); + }) as JsxFragment; + + const scaffoldsArrowFnFragmentChildrenText = scaffoldsArrowFnFragment + .getFullText() + .replace("<>", "") + .replace("", "") + .trim(); + + scaffoldsArrowFnFragment.replaceWithText( + `<>{${pluginName}PluginsFactory}${scaffoldsArrowFnFragmentChildrenText}` + ); + + await source.save(); + + await formatCode(scaffoldsFilePath, {}); +}; \ No newline at end of file diff --git a/packages/cli-plugin-scaffold-plugins/src/index.ts b/packages/cli-plugin-scaffold-plugins/src/index.ts index 7d7426f31cb..f923af7c62c 100644 --- a/packages/cli-plugin-scaffold-plugins/src/index.ts +++ b/packages/cli-plugin-scaffold-plugins/src/index.ts @@ -105,10 +105,10 @@ export default (): CliCommandScaffoldTemplate => ({ ]; }, generate: async ({ input, ora }) => { - ora.start(`Creating plugin...`); + const { pluginType, pluginName, packageName, location } = input; try { - const { pluginType, pluginName, packageName, location } = input; + ora.start(`Creating ${pluginName} plugin...`); const sourcePath = path.join(__dirname, "templates", pluginType); @@ -151,7 +151,7 @@ export default (): CliCommandScaffoldTemplate => ({ // Once everything is done, run `yarn` so the new packages are automatically installed. await execa("yarn"); - ora.succeed("New plugin created."); + ora.succeed(`New plugin created in ${location}.`); } catch (err) { ora.fail("Could not create plugin. Please check the logs below."); console.log(); diff --git a/packages/cli-plugin-scaffold-plugins/templates/admin/package.json b/packages/cli-plugin-scaffold-plugins/templates/admin/package.json index 449720b0269..5edc1ea1bf4 100644 --- a/packages/cli-plugin-scaffold-plugins/templates/admin/package.json +++ b/packages/cli-plugin-scaffold-plugins/templates/admin/package.json @@ -1,5 +1,5 @@ { "name": "PACKAGE_NAME", - "main": "src/index.ts", + "main": "src/index.tsx", "version": "1.0.0" } \ No newline at end of file From e807266834bed0dc4229e133e9176b4fc43b2e62 Mon Sep 17 00:00:00 2001 From: adrians5j Date: Sun, 5 May 2024 22:42:49 +0200 Subject: [PATCH 08/32] wip: create essential plugins scaffold --- apps/admin/src/App.auth0.tsx | 2 ++ apps/admin/src/App.editor.tsx | 2 ++ apps/admin/src/App.fm.tsx | 2 ++ apps/admin/src/App.okta.tsx | 2 ++ .../cwp-template-aws/template/common/apps/admin/src/App.tsx | 3 +++ .../template/common/apps/admin/src/plugins/Scaffolds.tsx | 5 +++++ 6 files changed, 16 insertions(+) create mode 100644 packages/cwp-template-aws/template/common/apps/admin/src/plugins/Scaffolds.tsx diff --git a/apps/admin/src/App.auth0.tsx b/apps/admin/src/App.auth0.tsx index 94470e11142..db22dccf0d7 100644 --- a/apps/admin/src/App.auth0.tsx +++ b/apps/admin/src/App.auth0.tsx @@ -1,6 +1,7 @@ import React from "react"; import { Admin } from "@webiny/app-serverless-cms"; import { Auth0 } from "@webiny/app-admin-auth0"; +import { Scaffolds } from "./plugins/Scaffolds"; import "./App.scss"; export const App = () => { @@ -13,6 +14,7 @@ export const App = () => { }} rootAppClientId={String(process.env.REACT_APP_AUTH0_CLIENT_ID)} /> + ); }; diff --git a/apps/admin/src/App.editor.tsx b/apps/admin/src/App.editor.tsx index d5ad5a4007b..9533ee4b7e4 100644 --- a/apps/admin/src/App.editor.tsx +++ b/apps/admin/src/App.editor.tsx @@ -1,6 +1,7 @@ import React from "react"; import { Admin } from "@webiny/app-serverless-cms"; import { Cognito } from "@webiny/app-admin-users-cognito"; +import { Scaffolds } from "./plugins/Scaffolds"; import { Editor } from "@webiny/app-page-builder-editor"; import "./App.scss"; @@ -9,6 +10,7 @@ export const App = () => { + ); }; diff --git a/apps/admin/src/App.fm.tsx b/apps/admin/src/App.fm.tsx index b9b2522a83e..4cacecd0d24 100644 --- a/apps/admin/src/App.fm.tsx +++ b/apps/admin/src/App.fm.tsx @@ -2,6 +2,7 @@ import React, { useCallback } from "react"; import { Admin, createComponentPlugin } from "@webiny/app-serverless-cms"; import { FileManagerFileItem, FileManagerRenderer, OverlayLayout } from "@webiny/app-admin"; import { Cognito } from "@webiny/app-admin-users-cognito"; +import { Scaffolds } from "./plugins/Scaffolds"; import "./App.scss"; const CustomFileManager = createComponentPlugin(FileManagerRenderer, () => { @@ -36,6 +37,7 @@ export const App = () => { + ); }; diff --git a/apps/admin/src/App.okta.tsx b/apps/admin/src/App.okta.tsx index 2ec41173259..c05a392338c 100644 --- a/apps/admin/src/App.okta.tsx +++ b/apps/admin/src/App.okta.tsx @@ -1,6 +1,7 @@ import React from "react"; import { Admin } from "@webiny/app-serverless-cms"; import { Okta } from "@webiny/app-admin-okta"; +import { Scaffolds } from "./plugins/Scaffolds"; import "./App.scss"; import { oktaFactory, rootAppClientId } from "./okta"; @@ -9,6 +10,7 @@ export const App = () => { return ( + ); }; diff --git a/packages/cwp-template-aws/template/common/apps/admin/src/App.tsx b/packages/cwp-template-aws/template/common/apps/admin/src/App.tsx index 2773f643e51..ad7354bad04 100644 --- a/packages/cwp-template-aws/template/common/apps/admin/src/App.tsx +++ b/packages/cwp-template-aws/template/common/apps/admin/src/App.tsx @@ -1,12 +1,15 @@ import React from "react"; import { Admin } from "@webiny/app-serverless-cms"; import { Cognito } from "@webiny/app-admin-users-cognito"; +import { Scaffolds } from "./plugins/Scaffolds"; + import "./App.scss"; export const App = () => { return ( + ); }; diff --git a/packages/cwp-template-aws/template/common/apps/admin/src/plugins/Scaffolds.tsx b/packages/cwp-template-aws/template/common/apps/admin/src/plugins/Scaffolds.tsx new file mode 100644 index 00000000000..d2dc7a2ffa4 --- /dev/null +++ b/packages/cwp-template-aws/template/common/apps/admin/src/plugins/Scaffolds.tsx @@ -0,0 +1,5 @@ +import React from "react"; + +export const Scaffolds = () => { + return <>; +}; From 3a532f54b30b491d2038d42a872f540da0b94223 Mon Sep 17 00:00:00 2001 From: adrians5j Date: Sun, 5 May 2024 22:47:41 +0200 Subject: [PATCH 09/32] wip: create essential plugins scaffold --- apps/admin/src/App.auth0.tsx | 2 +- apps/admin/src/App.fm.tsx | 2 +- apps/admin/src/App.tsx | 2 +- packages/api-serverless-cms/package.json | 15 +++++++++++++++ packages/cli-plugin-scaffold-plugins/package.json | 4 +--- .../generators/utils/addReactPluginToReactApp.tsx | 4 ++-- .../templates/admin/package.json | 2 +- .../templates/admin/tsconfig.json | 2 +- .../templates/api/package.json | 2 +- .../templates/api/src/index.ts | 2 +- .../templates/api/tsconfig.json | 2 +- .../template/common/apps/admin/src/App.tsx | 2 +- webiny.project.ts | 2 +- 13 files changed, 28 insertions(+), 15 deletions(-) diff --git a/apps/admin/src/App.auth0.tsx b/apps/admin/src/App.auth0.tsx index db22dccf0d7..141794fcb5f 100644 --- a/apps/admin/src/App.auth0.tsx +++ b/apps/admin/src/App.auth0.tsx @@ -14,7 +14,7 @@ export const App = () => { }} rootAppClientId={String(process.env.REACT_APP_AUTH0_CLIENT_ID)} /> - + ); }; diff --git a/apps/admin/src/App.fm.tsx b/apps/admin/src/App.fm.tsx index 4cacecd0d24..b03a213de43 100644 --- a/apps/admin/src/App.fm.tsx +++ b/apps/admin/src/App.fm.tsx @@ -37,7 +37,7 @@ export const App = () => { - + ); }; diff --git a/apps/admin/src/App.tsx b/apps/admin/src/App.tsx index 7366e99020e..0f4f32a9b5e 100644 --- a/apps/admin/src/App.tsx +++ b/apps/admin/src/App.tsx @@ -8,7 +8,7 @@ export const App = () => { return ( - + ); }; diff --git a/packages/api-serverless-cms/package.json b/packages/api-serverless-cms/package.json index a20c2135957..c48b3a9b2c1 100644 --- a/packages/api-serverless-cms/package.json +++ b/packages/api-serverless-cms/package.json @@ -8,6 +8,21 @@ }, "description": "Core package for all of our API packages.", "license": "MIT", + "dependencies": { + "@webiny/handler-client": "0.0.0", + "@webiny/api-tenancy": "0.0.0", + "@webiny/api-security": "0.0.0", + "@webiny/api-i18n": "0.0.0", + "@webiny/api-i18n-content": "0.0.0", + "@webiny/api-page-builder": "0.0.0", + "@webiny/api-prerendering-service": "0.0.0", + "@webiny/api-file-manager": "0.0.0", + "@webiny/api-form-builder": "0.0.0", + "@webiny/api-headless-cms": "0.0.0", + "@webiny/api-aco": "0.0.0", + "@webiny/api-page-builder-aco": "0.0.0", + "@webiny/api": "0.0.0" + }, "devDependencies": { "@babel/cli": "^7.23.9", "@babel/core": "^7.24.0", diff --git a/packages/cli-plugin-scaffold-plugins/package.json b/packages/cli-plugin-scaffold-plugins/package.json index 5317d464f00..b1825b5c0aa 100644 --- a/packages/cli-plugin-scaffold-plugins/package.json +++ b/packages/cli-plugin-scaffold-plugins/package.json @@ -23,13 +23,11 @@ "@webiny/cli-plugin-scaffold": "0.0.0", "@webiny/error": "0.0.0", "case": "^1.6.3", - "chalk": "^4.1.0", "execa": "^5.0.0", - "indent-string": "^4.0.0", "load-json-file": "^6.2.0", "ncp": "^2.0.0", - "pluralize": "^8.0.0", "replace-in-path": "^1.1.0", + "ts-morph": "^11.0.0", "validate-npm-package-name": "^3.0.0", "write-json-file": "^4.3.0" }, diff --git a/packages/cli-plugin-scaffold-plugins/src/generators/utils/addReactPluginToReactApp.tsx b/packages/cli-plugin-scaffold-plugins/src/generators/utils/addReactPluginToReactApp.tsx index db17b51badf..38c1fdb0c59 100644 --- a/packages/cli-plugin-scaffold-plugins/src/generators/utils/addReactPluginToReactApp.tsx +++ b/packages/cli-plugin-scaffold-plugins/src/generators/utils/addReactPluginToReactApp.tsx @@ -1,6 +1,6 @@ import { Project, Node, JsxFragment } from "ts-morph"; import path from "path"; -import {formatCode} from "@webiny/cli-plugin-scaffold/utils"; +import { formatCode } from "@webiny/cli-plugin-scaffold/utils"; interface Params { pluginName: string; @@ -79,4 +79,4 @@ export const addReactPluginToReactApp = async (params: Params): Promise => await source.save(); await formatCode(scaffoldsFilePath, {}); -}; \ No newline at end of file +}; diff --git a/packages/cli-plugin-scaffold-plugins/templates/admin/package.json b/packages/cli-plugin-scaffold-plugins/templates/admin/package.json index 5edc1ea1bf4..6b600cd715b 100644 --- a/packages/cli-plugin-scaffold-plugins/templates/admin/package.json +++ b/packages/cli-plugin-scaffold-plugins/templates/admin/package.json @@ -2,4 +2,4 @@ "name": "PACKAGE_NAME", "main": "src/index.tsx", "version": "1.0.0" -} \ No newline at end of file +} diff --git a/packages/cli-plugin-scaffold-plugins/templates/admin/tsconfig.json b/packages/cli-plugin-scaffold-plugins/templates/admin/tsconfig.json index 752a892f3ef..31464829d4e 100644 --- a/packages/cli-plugin-scaffold-plugins/templates/admin/tsconfig.json +++ b/packages/cli-plugin-scaffold-plugins/templates/admin/tsconfig.json @@ -1,4 +1,4 @@ { "extends": "BASE_TSCONFIG_PATH", "include": ["src"] -} \ No newline at end of file +} diff --git a/packages/cli-plugin-scaffold-plugins/templates/api/package.json b/packages/cli-plugin-scaffold-plugins/templates/api/package.json index 449720b0269..4261ad1dad7 100644 --- a/packages/cli-plugin-scaffold-plugins/templates/api/package.json +++ b/packages/cli-plugin-scaffold-plugins/templates/api/package.json @@ -2,4 +2,4 @@ "name": "PACKAGE_NAME", "main": "src/index.ts", "version": "1.0.0" -} \ No newline at end of file +} diff --git a/packages/cli-plugin-scaffold-plugins/templates/api/src/index.ts b/packages/cli-plugin-scaffold-plugins/templates/api/src/index.ts index f7ac3fa8533..fec57ff6047 100644 --- a/packages/cli-plugin-scaffold-plugins/templates/api/src/index.ts +++ b/packages/cli-plugin-scaffold-plugins/templates/api/src/index.ts @@ -1,3 +1,3 @@ export const createPlugins = () => [ // Your plugins here. -]; \ No newline at end of file +]; diff --git a/packages/cli-plugin-scaffold-plugins/templates/api/tsconfig.json b/packages/cli-plugin-scaffold-plugins/templates/api/tsconfig.json index 752a892f3ef..31464829d4e 100644 --- a/packages/cli-plugin-scaffold-plugins/templates/api/tsconfig.json +++ b/packages/cli-plugin-scaffold-plugins/templates/api/tsconfig.json @@ -1,4 +1,4 @@ { "extends": "BASE_TSCONFIG_PATH", "include": ["src"] -} \ No newline at end of file +} diff --git a/packages/cwp-template-aws/template/common/apps/admin/src/App.tsx b/packages/cwp-template-aws/template/common/apps/admin/src/App.tsx index ad7354bad04..55fc7ce18d7 100644 --- a/packages/cwp-template-aws/template/common/apps/admin/src/App.tsx +++ b/packages/cwp-template-aws/template/common/apps/admin/src/App.tsx @@ -9,7 +9,7 @@ export const App = () => { return ( - + ); }; diff --git a/webiny.project.ts b/webiny.project.ts index 86128323883..3f5fffaccf1 100644 --- a/webiny.project.ts +++ b/webiny.project.ts @@ -18,7 +18,7 @@ export default { import("@webiny/cwp-template-aws/cli"), import("@webiny/cli-plugin-scaffold"), import("@webiny/cli-plugin-scaffold-plugins"), - import("@webiny/cli-plugin-scaffold-ci"), + import("@webiny/cli-plugin-scaffold-ci") ]); return modules From 49a9a399ced1bcdb7f81a4c2e7bb6168f8a2f1cb Mon Sep 17 00:00:00 2001 From: adrians5j Date: Sun, 5 May 2024 22:48:33 +0200 Subject: [PATCH 10/32] wip: create essential plugins scaffold --- .../api-serverless-cms/tsconfig.build.json | 15 +++++- packages/api-serverless-cms/tsconfig.json | 46 +++++++++++++++++-- 2 files changed, 54 insertions(+), 7 deletions(-) diff --git a/packages/api-serverless-cms/tsconfig.build.json b/packages/api-serverless-cms/tsconfig.build.json index bcc9a624b5f..c18d5ea1de7 100644 --- a/packages/api-serverless-cms/tsconfig.build.json +++ b/packages/api-serverless-cms/tsconfig.build.json @@ -2,8 +2,19 @@ "extends": "../../tsconfig.build.json", "include": ["src"], "references": [ - { "path": "../aws-sdk/tsconfig.build.json" }, - { "path": "../plugins/tsconfig.build.json" } + { "path": "../handler-client/tsconfig.build.json" }, + { "path": "../api-tenancy/tsconfig.build.json" }, + { "path": "../api-security/tsconfig.build.json" }, + { "path": "../api-i18n/tsconfig.build.json" }, + { "path": "../api-i18n-content/tsconfig.build.json" }, + { "path": "../api-page-builder/tsconfig.build.json" }, + { "path": "../api-prerendering-service/tsconfig.build.json" }, + { "path": "../api-file-manager/tsconfig.build.json" }, + { "path": "../api-form-builder/tsconfig.build.json" }, + { "path": "../api-headless-cms/tsconfig.build.json" }, + { "path": "../api-aco/tsconfig.build.json" }, + { "path": "../api-page-builder-aco/tsconfig.build.json" }, + { "path": "../api/tsconfig.build.json" } ], "compilerOptions": { "rootDir": "./src", diff --git a/packages/api-serverless-cms/tsconfig.json b/packages/api-serverless-cms/tsconfig.json index 47c4318ae5a..119bdaab1bb 100644 --- a/packages/api-serverless-cms/tsconfig.json +++ b/packages/api-serverless-cms/tsconfig.json @@ -1,7 +1,21 @@ { "extends": "../../tsconfig.json", "include": ["src", "__tests__"], - "references": [{ "path": "../aws-sdk" }, { "path": "../plugins" }], + "references": [ + { "path": "../handler-client" }, + { "path": "../api-tenancy" }, + { "path": "../api-security" }, + { "path": "../api-i18n" }, + { "path": "../api-i18n-content" }, + { "path": "../api-page-builder" }, + { "path": "../api-prerendering-service" }, + { "path": "../api-file-manager" }, + { "path": "../api-form-builder" }, + { "path": "../api-headless-cms" }, + { "path": "../api-aco" }, + { "path": "../api-page-builder-aco" }, + { "path": "../api" } + ], "compilerOptions": { "rootDirs": ["./src", "./__tests__"], "outDir": "./dist", @@ -9,10 +23,32 @@ "paths": { "~/*": ["./src/*"], "~tests/*": ["./__tests__/*"], - "@webiny/aws-sdk/*": ["../aws-sdk/src/*"], - "@webiny/aws-sdk": ["../aws-sdk/src"], - "@webiny/plugins/*": ["../plugins/src/*"], - "@webiny/plugins": ["../plugins/src"] + "@webiny/handler-client/*": ["../handler-client/src/*"], + "@webiny/handler-client": ["../handler-client/src"], + "@webiny/api-tenancy/*": ["../api-tenancy/src/*"], + "@webiny/api-tenancy": ["../api-tenancy/src"], + "@webiny/api-security/*": ["../api-security/src/*"], + "@webiny/api-security": ["../api-security/src"], + "@webiny/api-i18n/*": ["../api-i18n/src/*"], + "@webiny/api-i18n": ["../api-i18n/src"], + "@webiny/api-i18n-content/*": ["../api-i18n-content/src/*"], + "@webiny/api-i18n-content": ["../api-i18n-content/src"], + "@webiny/api-page-builder/*": ["../api-page-builder/src/*"], + "@webiny/api-page-builder": ["../api-page-builder/src"], + "@webiny/api-prerendering-service/*": ["../api-prerendering-service/src/*"], + "@webiny/api-prerendering-service": ["../api-prerendering-service/src"], + "@webiny/api-file-manager/*": ["../api-file-manager/src/*"], + "@webiny/api-file-manager": ["../api-file-manager/src"], + "@webiny/api-form-builder/*": ["../api-form-builder/src/*"], + "@webiny/api-form-builder": ["../api-form-builder/src"], + "@webiny/api-headless-cms/*": ["../api-headless-cms/src/*"], + "@webiny/api-headless-cms": ["../api-headless-cms/src"], + "@webiny/api-aco/*": ["../api-aco/src/*"], + "@webiny/api-aco": ["../api-aco/src"], + "@webiny/api-page-builder-aco/*": ["../api-page-builder-aco/src/*"], + "@webiny/api-page-builder-aco": ["../api-page-builder-aco/src"], + "@webiny/api/*": ["../api/src/*"], + "@webiny/api": ["../api/src"] }, "baseUrl": "." } From 8716306c89a72601b11fc28ed4b6f86e0c7fd7dc Mon Sep 17 00:00:00 2001 From: adrians5j Date: Sun, 5 May 2024 23:00:44 +0200 Subject: [PATCH 11/32] wip: create essential plugins scaffold --- apps/admin/src/App.auth0.tsx | 4 ++-- apps/admin/src/App.editor.tsx | 4 ++-- apps/admin/src/App.fm.tsx | 4 ++-- apps/admin/src/App.okta.tsx | 4 ++-- apps/admin/src/App.tsx | 4 ++-- .../src/plugins/{Scaffolds.tsx => scaffolds/AdminPlugins.tsx} | 2 +- .../cwp-template-aws/template/common/apps/admin/src/App.tsx | 4 ++-- .../src/plugins/{Scaffolds.tsx => scaffolds/AdminPlugins.tsx} | 2 +- 8 files changed, 14 insertions(+), 14 deletions(-) rename apps/admin/src/plugins/{Scaffolds.tsx => scaffolds/AdminPlugins.tsx} (57%) rename packages/cwp-template-aws/template/common/apps/admin/src/plugins/{Scaffolds.tsx => scaffolds/AdminPlugins.tsx} (57%) diff --git a/apps/admin/src/App.auth0.tsx b/apps/admin/src/App.auth0.tsx index 141794fcb5f..a6a73806dfe 100644 --- a/apps/admin/src/App.auth0.tsx +++ b/apps/admin/src/App.auth0.tsx @@ -1,7 +1,7 @@ import React from "react"; import { Admin } from "@webiny/app-serverless-cms"; import { Auth0 } from "@webiny/app-admin-auth0"; -import { Scaffolds } from "./plugins/Scaffolds"; +import { AdminPlugins } from "./plugins/scaffolds/AdminPlugins"; import "./App.scss"; export const App = () => { @@ -14,7 +14,7 @@ export const App = () => { }} rootAppClientId={String(process.env.REACT_APP_AUTH0_CLIENT_ID)} /> - + ); }; diff --git a/apps/admin/src/App.editor.tsx b/apps/admin/src/App.editor.tsx index 9533ee4b7e4..421bf24776f 100644 --- a/apps/admin/src/App.editor.tsx +++ b/apps/admin/src/App.editor.tsx @@ -1,7 +1,7 @@ import React from "react"; import { Admin } from "@webiny/app-serverless-cms"; import { Cognito } from "@webiny/app-admin-users-cognito"; -import { Scaffolds } from "./plugins/Scaffolds"; +import { AdminPlugins } from "./plugins/scaffolds/AdminPlugins"; import { Editor } from "@webiny/app-page-builder-editor"; import "./App.scss"; @@ -10,7 +10,7 @@ export const App = () => { - + ); }; diff --git a/apps/admin/src/App.fm.tsx b/apps/admin/src/App.fm.tsx index b03a213de43..04fc83d14ee 100644 --- a/apps/admin/src/App.fm.tsx +++ b/apps/admin/src/App.fm.tsx @@ -2,7 +2,7 @@ import React, { useCallback } from "react"; import { Admin, createComponentPlugin } from "@webiny/app-serverless-cms"; import { FileManagerFileItem, FileManagerRenderer, OverlayLayout } from "@webiny/app-admin"; import { Cognito } from "@webiny/app-admin-users-cognito"; -import { Scaffolds } from "./plugins/Scaffolds"; +import { AdminPlugins } from "./plugins/scaffolds/AdminPlugins"; import "./App.scss"; const CustomFileManager = createComponentPlugin(FileManagerRenderer, () => { @@ -37,7 +37,7 @@ export const App = () => { - + ); }; diff --git a/apps/admin/src/App.okta.tsx b/apps/admin/src/App.okta.tsx index c05a392338c..994b1ac2534 100644 --- a/apps/admin/src/App.okta.tsx +++ b/apps/admin/src/App.okta.tsx @@ -1,7 +1,7 @@ import React from "react"; import { Admin } from "@webiny/app-serverless-cms"; import { Okta } from "@webiny/app-admin-okta"; -import { Scaffolds } from "./plugins/Scaffolds"; +import { AdminPlugins } from "./plugins/scaffolds/AdminPlugins"; import "./App.scss"; import { oktaFactory, rootAppClientId } from "./okta"; @@ -10,7 +10,7 @@ export const App = () => { return ( - + ); }; diff --git a/apps/admin/src/App.tsx b/apps/admin/src/App.tsx index 0f4f32a9b5e..2276bce157c 100644 --- a/apps/admin/src/App.tsx +++ b/apps/admin/src/App.tsx @@ -1,14 +1,14 @@ import React from "react"; import { Admin } from "@webiny/app-serverless-cms"; import { Cognito } from "@webiny/app-admin-users-cognito"; -import { Scaffolds } from "./plugins/Scaffolds"; +import { AdminPlugins } from "./plugins/scaffolds/AdminPlugins"; import "./App.scss"; export const App = () => { return ( - + ); }; diff --git a/apps/admin/src/plugins/Scaffolds.tsx b/apps/admin/src/plugins/scaffolds/AdminPlugins.tsx similarity index 57% rename from apps/admin/src/plugins/Scaffolds.tsx rename to apps/admin/src/plugins/scaffolds/AdminPlugins.tsx index d2dc7a2ffa4..5425d573d9f 100644 --- a/apps/admin/src/plugins/Scaffolds.tsx +++ b/apps/admin/src/plugins/scaffolds/AdminPlugins.tsx @@ -1,5 +1,5 @@ import React from "react"; -export const Scaffolds = () => { +export const AdminPlugins = () => { return <>; }; diff --git a/packages/cwp-template-aws/template/common/apps/admin/src/App.tsx b/packages/cwp-template-aws/template/common/apps/admin/src/App.tsx index 55fc7ce18d7..b6c26b95cf0 100644 --- a/packages/cwp-template-aws/template/common/apps/admin/src/App.tsx +++ b/packages/cwp-template-aws/template/common/apps/admin/src/App.tsx @@ -1,7 +1,7 @@ import React from "react"; import { Admin } from "@webiny/app-serverless-cms"; import { Cognito } from "@webiny/app-admin-users-cognito"; -import { Scaffolds } from "./plugins/Scaffolds"; +import { AdminPlugins } from "./plugins/scaffolds/AdminPlugins"; import "./App.scss"; @@ -9,7 +9,7 @@ export const App = () => { return ( - + ); }; diff --git a/packages/cwp-template-aws/template/common/apps/admin/src/plugins/Scaffolds.tsx b/packages/cwp-template-aws/template/common/apps/admin/src/plugins/scaffolds/AdminPlugins.tsx similarity index 57% rename from packages/cwp-template-aws/template/common/apps/admin/src/plugins/Scaffolds.tsx rename to packages/cwp-template-aws/template/common/apps/admin/src/plugins/scaffolds/AdminPlugins.tsx index d2dc7a2ffa4..5425d573d9f 100644 --- a/packages/cwp-template-aws/template/common/apps/admin/src/plugins/Scaffolds.tsx +++ b/packages/cwp-template-aws/template/common/apps/admin/src/plugins/scaffolds/AdminPlugins.tsx @@ -1,5 +1,5 @@ import React from "react"; -export const Scaffolds = () => { +export const AdminPlugins = () => { return <>; }; From 9bcacb15ce6bccd2a0e872b6bca665d5cbd5e2ad Mon Sep 17 00:00:00 2001 From: adrians5j Date: Mon, 6 May 2024 08:51:50 +0200 Subject: [PATCH 12/32] wip: create essential plugins scaffold --- packages/api-serverless-cms/package.json | 18 +++++++++--------- yarn.lock | 17 ++++++++++++++--- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/packages/api-serverless-cms/package.json b/packages/api-serverless-cms/package.json index c48b3a9b2c1..2189340f803 100644 --- a/packages/api-serverless-cms/package.json +++ b/packages/api-serverless-cms/package.json @@ -9,19 +9,19 @@ "description": "Core package for all of our API packages.", "license": "MIT", "dependencies": { - "@webiny/handler-client": "0.0.0", - "@webiny/api-tenancy": "0.0.0", - "@webiny/api-security": "0.0.0", - "@webiny/api-i18n": "0.0.0", - "@webiny/api-i18n-content": "0.0.0", - "@webiny/api-page-builder": "0.0.0", - "@webiny/api-prerendering-service": "0.0.0", + "@webiny/api": "0.0.0", + "@webiny/api-aco": "0.0.0", "@webiny/api-file-manager": "0.0.0", "@webiny/api-form-builder": "0.0.0", "@webiny/api-headless-cms": "0.0.0", - "@webiny/api-aco": "0.0.0", + "@webiny/api-i18n": "0.0.0", + "@webiny/api-i18n-content": "0.0.0", + "@webiny/api-page-builder": "0.0.0", "@webiny/api-page-builder-aco": "0.0.0", - "@webiny/api": "0.0.0" + "@webiny/api-prerendering-service": "0.0.0", + "@webiny/api-security": "0.0.0", + "@webiny/api-tenancy": "0.0.0", + "@webiny/handler-client": "0.0.0" }, "devDependencies": { "@babel/cli": "^7.23.9", diff --git a/yarn.lock b/yarn.lock index 95247679e9f..374263fee40 100644 --- a/yarn.lock +++ b/yarn.lock @@ -14266,7 +14266,20 @@ __metadata: "@babel/core": ^7.24.0 "@babel/preset-env": ^7.24.0 "@babel/preset-typescript": ^7.23.3 + "@webiny/api": 0.0.0 + "@webiny/api-aco": 0.0.0 + "@webiny/api-file-manager": 0.0.0 + "@webiny/api-form-builder": 0.0.0 + "@webiny/api-headless-cms": 0.0.0 + "@webiny/api-i18n": 0.0.0 + "@webiny/api-i18n-content": 0.0.0 + "@webiny/api-page-builder": 0.0.0 + "@webiny/api-page-builder-aco": 0.0.0 + "@webiny/api-prerendering-service": 0.0.0 + "@webiny/api-security": 0.0.0 + "@webiny/api-tenancy": 0.0.0 "@webiny/cli": 0.0.0 + "@webiny/handler-client": 0.0.0 "@webiny/project-utils": 0.0.0 rimraf: ^5.0.5 ttypescript: ^1.5.13 @@ -16203,14 +16216,12 @@ __metadata: "@webiny/error": 0.0.0 "@webiny/project-utils": 0.0.0 case: ^1.6.3 - chalk: ^4.1.0 execa: ^5.0.0 - indent-string: ^4.0.0 load-json-file: ^6.2.0 ncp: ^2.0.0 - pluralize: ^8.0.0 replace-in-path: ^1.1.0 rimraf: ^5.0.5 + ts-morph: ^11.0.0 typescript: 4.7.4 validate-npm-package-name: ^3.0.0 write-json-file: ^4.3.0 From ca301dff53feebe29df4571d2a25c643105d7a83 Mon Sep 17 00:00:00 2001 From: adrians5j Date: Mon, 6 May 2024 08:57:50 +0200 Subject: [PATCH 13/32] wip: create essential plugins scaffold --- packages/cwp-template-aws/template/common/webiny.project.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/cwp-template-aws/template/common/webiny.project.ts b/packages/cwp-template-aws/template/common/webiny.project.ts index 8de03c7a9f9..a0e24befd5a 100644 --- a/packages/cwp-template-aws/template/common/webiny.project.ts +++ b/packages/cwp-template-aws/template/common/webiny.project.ts @@ -6,8 +6,10 @@ import cliAwsTemplate from "@webiny/cwp-template-aws/cli"; import cliScaffold from "@webiny/cli-plugin-scaffold"; import cliScaffoldExtendGraphQlApi from "@webiny/cli-plugin-scaffold-graphql-service"; import cliScaffoldAdminModule from "@webiny/cli-plugin-scaffold-admin-app-module"; +import cliScaffoldPlugins from "@webiny/cli-plugin-scaffold-plugins"; import cliScaffoldCiCd from "@webiny/cli-plugin-scaffold-ci"; + export default { template: "[TEMPLATE_VERSION]", name: "[PROJECT_NAME]", @@ -21,6 +23,7 @@ export default { cliScaffold(), cliScaffoldExtendGraphQlApi(), cliScaffoldAdminModule(), + cliScaffoldPlugins, cliScaffoldCiCd() ] }, From c8317cdaabcff6ae3f47027d67e46fdb9faa2758 Mon Sep 17 00:00:00 2001 From: adrians5j Date: Mon, 6 May 2024 09:04:43 +0200 Subject: [PATCH 14/32] wip: create essential plugins scaffold --- packages/api-serverless-cms/package.json | 1 + packages/api-serverless-cms/src/index.ts | 17 +++--- .../api-serverless-cms/tsconfig.build.json | 19 ++++--- packages/api-serverless-cms/tsconfig.json | 57 ++++++++++--------- 4 files changed, 51 insertions(+), 43 deletions(-) diff --git a/packages/api-serverless-cms/package.json b/packages/api-serverless-cms/package.json index 2189340f803..974e1e8c9c5 100644 --- a/packages/api-serverless-cms/package.json +++ b/packages/api-serverless-cms/package.json @@ -13,6 +13,7 @@ "@webiny/api-aco": "0.0.0", "@webiny/api-file-manager": "0.0.0", "@webiny/api-form-builder": "0.0.0", + "@webiny/handler-graphql": "0.0.0", "@webiny/api-headless-cms": "0.0.0", "@webiny/api-i18n": "0.0.0", "@webiny/api-i18n-content": "0.0.0", diff --git a/packages/api-serverless-cms/src/index.ts b/packages/api-serverless-cms/src/index.ts index 1fde469c0e4..5e87938046f 100644 --- a/packages/api-serverless-cms/src/index.ts +++ b/packages/api-serverless-cms/src/index.ts @@ -10,15 +10,12 @@ import { FormBuilderContext } from "@webiny/api-form-builder/types"; import { CmsContext } from "@webiny/api-headless-cms/types"; import { AcoContext } from "@webiny/api-aco/types"; import { PbAcoContext } from "@webiny/api-page-builder-aco/types"; - import { createContextPlugin as baseCreateContextPlugin, ContextPluginCallable } from "@webiny/api"; +import { + createGraphQLSchemaPlugin as baseCreateGraphQLSchemaPlugin, + GraphQLSchemaPluginConfig +} from "@webiny/handler-graphql"; -// When working with the `context` object (for example while defining a new GraphQL resolver function), -// you can import this interface and assign it to it. This will give you full autocomplete functionality -// and type safety. The easiest way to import it would be via the following import statement: -// import { Context } from "~/types"; -// Feel free to extend it with additional context interfaces, if needed. Also, please do not change the -// name of the interface, as existing scaffolding utilities may rely on it during the scaffolding process. export interface Context extends ClientContext, TenancyContext, @@ -38,3 +35,9 @@ export const createContextPlugin = ( ) => { return baseCreateContextPlugin(callable); }; + +export const createGraphQLSchemaPlugin = ( + config: GraphQLSchemaPluginConfig +) => { + return baseCreateGraphQLSchemaPlugin(config); +}; diff --git a/packages/api-serverless-cms/tsconfig.build.json b/packages/api-serverless-cms/tsconfig.build.json index c18d5ea1de7..1f153853c01 100644 --- a/packages/api-serverless-cms/tsconfig.build.json +++ b/packages/api-serverless-cms/tsconfig.build.json @@ -2,19 +2,20 @@ "extends": "../../tsconfig.build.json", "include": ["src"], "references": [ - { "path": "../handler-client/tsconfig.build.json" }, - { "path": "../api-tenancy/tsconfig.build.json" }, - { "path": "../api-security/tsconfig.build.json" }, - { "path": "../api-i18n/tsconfig.build.json" }, - { "path": "../api-i18n-content/tsconfig.build.json" }, - { "path": "../api-page-builder/tsconfig.build.json" }, - { "path": "../api-prerendering-service/tsconfig.build.json" }, + { "path": "../api/tsconfig.build.json" }, + { "path": "../api-aco/tsconfig.build.json" }, { "path": "../api-file-manager/tsconfig.build.json" }, { "path": "../api-form-builder/tsconfig.build.json" }, + { "path": "../handler-graphql/tsconfig.build.json" }, { "path": "../api-headless-cms/tsconfig.build.json" }, - { "path": "../api-aco/tsconfig.build.json" }, + { "path": "../api-i18n/tsconfig.build.json" }, + { "path": "../api-i18n-content/tsconfig.build.json" }, + { "path": "../api-page-builder/tsconfig.build.json" }, { "path": "../api-page-builder-aco/tsconfig.build.json" }, - { "path": "../api/tsconfig.build.json" } + { "path": "../api-prerendering-service/tsconfig.build.json" }, + { "path": "../api-security/tsconfig.build.json" }, + { "path": "../api-tenancy/tsconfig.build.json" }, + { "path": "../handler-client/tsconfig.build.json" } ], "compilerOptions": { "rootDir": "./src", diff --git a/packages/api-serverless-cms/tsconfig.json b/packages/api-serverless-cms/tsconfig.json index 119bdaab1bb..07dcf392adf 100644 --- a/packages/api-serverless-cms/tsconfig.json +++ b/packages/api-serverless-cms/tsconfig.json @@ -2,19 +2,20 @@ "extends": "../../tsconfig.json", "include": ["src", "__tests__"], "references": [ - { "path": "../handler-client" }, - { "path": "../api-tenancy" }, - { "path": "../api-security" }, - { "path": "../api-i18n" }, - { "path": "../api-i18n-content" }, - { "path": "../api-page-builder" }, - { "path": "../api-prerendering-service" }, + { "path": "../api" }, + { "path": "../api-aco" }, { "path": "../api-file-manager" }, { "path": "../api-form-builder" }, + { "path": "../handler-graphql" }, { "path": "../api-headless-cms" }, - { "path": "../api-aco" }, + { "path": "../api-i18n" }, + { "path": "../api-i18n-content" }, + { "path": "../api-page-builder" }, { "path": "../api-page-builder-aco" }, - { "path": "../api" } + { "path": "../api-prerendering-service" }, + { "path": "../api-security" }, + { "path": "../api-tenancy" }, + { "path": "../handler-client" } ], "compilerOptions": { "rootDirs": ["./src", "./__tests__"], @@ -23,32 +24,34 @@ "paths": { "~/*": ["./src/*"], "~tests/*": ["./__tests__/*"], - "@webiny/handler-client/*": ["../handler-client/src/*"], - "@webiny/handler-client": ["../handler-client/src"], - "@webiny/api-tenancy/*": ["../api-tenancy/src/*"], - "@webiny/api-tenancy": ["../api-tenancy/src"], - "@webiny/api-security/*": ["../api-security/src/*"], - "@webiny/api-security": ["../api-security/src"], - "@webiny/api-i18n/*": ["../api-i18n/src/*"], - "@webiny/api-i18n": ["../api-i18n/src"], - "@webiny/api-i18n-content/*": ["../api-i18n-content/src/*"], - "@webiny/api-i18n-content": ["../api-i18n-content/src"], - "@webiny/api-page-builder/*": ["../api-page-builder/src/*"], - "@webiny/api-page-builder": ["../api-page-builder/src"], - "@webiny/api-prerendering-service/*": ["../api-prerendering-service/src/*"], - "@webiny/api-prerendering-service": ["../api-prerendering-service/src"], + "@webiny/api/*": ["../api/src/*"], + "@webiny/api": ["../api/src"], + "@webiny/api-aco/*": ["../api-aco/src/*"], + "@webiny/api-aco": ["../api-aco/src"], "@webiny/api-file-manager/*": ["../api-file-manager/src/*"], "@webiny/api-file-manager": ["../api-file-manager/src"], "@webiny/api-form-builder/*": ["../api-form-builder/src/*"], "@webiny/api-form-builder": ["../api-form-builder/src"], + "@webiny/handler-graphql/*": ["../handler-graphql/src/*"], + "@webiny/handler-graphql": ["../handler-graphql/src"], "@webiny/api-headless-cms/*": ["../api-headless-cms/src/*"], "@webiny/api-headless-cms": ["../api-headless-cms/src"], - "@webiny/api-aco/*": ["../api-aco/src/*"], - "@webiny/api-aco": ["../api-aco/src"], + "@webiny/api-i18n/*": ["../api-i18n/src/*"], + "@webiny/api-i18n": ["../api-i18n/src"], + "@webiny/api-i18n-content/*": ["../api-i18n-content/src/*"], + "@webiny/api-i18n-content": ["../api-i18n-content/src"], + "@webiny/api-page-builder/*": ["../api-page-builder/src/*"], + "@webiny/api-page-builder": ["../api-page-builder/src"], "@webiny/api-page-builder-aco/*": ["../api-page-builder-aco/src/*"], "@webiny/api-page-builder-aco": ["../api-page-builder-aco/src"], - "@webiny/api/*": ["../api/src/*"], - "@webiny/api": ["../api/src"] + "@webiny/api-prerendering-service/*": ["../api-prerendering-service/src/*"], + "@webiny/api-prerendering-service": ["../api-prerendering-service/src"], + "@webiny/api-security/*": ["../api-security/src/*"], + "@webiny/api-security": ["../api-security/src"], + "@webiny/api-tenancy/*": ["../api-tenancy/src/*"], + "@webiny/api-tenancy": ["../api-tenancy/src"], + "@webiny/handler-client/*": ["../handler-client/src/*"], + "@webiny/handler-client": ["../handler-client/src"] }, "baseUrl": "." } From 199486a6d31f5127742e475d30770f26a0b9f019 Mon Sep 17 00:00:00 2001 From: adrians5j Date: Mon, 6 May 2024 09:06:46 +0200 Subject: [PATCH 15/32] wip: create essential plugins scaffold --- packages/cli-plugin-scaffold-plugins/README.md | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/packages/cli-plugin-scaffold-plugins/README.md b/packages/cli-plugin-scaffold-plugins/README.md index cb234e1434e..a9ea297c2bd 100644 --- a/packages/cli-plugin-scaffold-plugins/README.md +++ b/packages/cli-plugin-scaffold-plugins/README.md @@ -1,25 +1,15 @@ # @webiny/cli-plugin-scaffold-plugins - [![](https://img.shields.io/npm/dw/@webiny/cli-plugin-scaffold-plugins.svg)](https://www.npmjs.com/package/@webiny/cli-plugin-scaffold-plugins) [![](https://img.shields.io/npm/v/@webiny/cli-plugin-scaffold-plugins.svg)](https://www.npmjs.com/package/@webiny/cli-plugin-scaffold-plugins) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com) -A plugin for @webiny/cli-plugin-scaffold that generates a simple React component. - ## Install - ``` -yarn add @webiny/cli-plugin-scaffold-plugins +npm install --save @webiny/cli-plugin-scaffold-plugins ``` -Add the plugin to your project by editing `webiny.project.js`: - -```js -module.exports = { - projectName: "my-project", - cli: { - plugins: [require("@webiny/cli-plugin-scaffold-plugins").default(),] - } -}; +Or if you prefer yarn: +``` +yarn add @webiny/cli-plugin-scaffold-plugins ``` From 5e92fae37ea09a0116b0cdc4b99d359f7ba276d5 Mon Sep 17 00:00:00 2001 From: adrians5j Date: Mon, 6 May 2024 09:10:12 +0200 Subject: [PATCH 16/32] wip: create essential plugins scaffold --- packages/cli-plugin-scaffold-plugins/src/generators/admin.ts | 4 ++-- .../{addReactPluginToReactApp.tsx => addPluginToReactApp.tsx} | 2 +- webiny.project.ts | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) rename packages/cli-plugin-scaffold-plugins/src/generators/utils/{addReactPluginToReactApp.tsx => addPluginToReactApp.tsx} (96%) diff --git a/packages/cli-plugin-scaffold-plugins/src/generators/admin.ts b/packages/cli-plugin-scaffold-plugins/src/generators/admin.ts index d26e9ccd6d3..940d00c05c5 100644 --- a/packages/cli-plugin-scaffold-plugins/src/generators/admin.ts +++ b/packages/cli-plugin-scaffold-plugins/src/generators/admin.ts @@ -1,6 +1,6 @@ -import { addReactPluginToReactApp } from "./utils/addReactPluginToReactApp"; +import { addPluginToReactApp } from "./utils/addPluginToReactApp"; import { PluginGenerator } from "~/types"; export const adminGenerator: PluginGenerator = async ({ input }) => { - await addReactPluginToReactApp(input); + await addPluginToReactApp(input); }; diff --git a/packages/cli-plugin-scaffold-plugins/src/generators/utils/addReactPluginToReactApp.tsx b/packages/cli-plugin-scaffold-plugins/src/generators/utils/addPluginToReactApp.tsx similarity index 96% rename from packages/cli-plugin-scaffold-plugins/src/generators/utils/addReactPluginToReactApp.tsx rename to packages/cli-plugin-scaffold-plugins/src/generators/utils/addPluginToReactApp.tsx index 38c1fdb0c59..0302aaaeb7b 100644 --- a/packages/cli-plugin-scaffold-plugins/src/generators/utils/addReactPluginToReactApp.tsx +++ b/packages/cli-plugin-scaffold-plugins/src/generators/utils/addPluginToReactApp.tsx @@ -7,7 +7,7 @@ interface Params { packageName: string; } -export const addReactPluginToReactApp = async (params: Params): Promise => { +export const addPluginToReactApp = async (params: Params): Promise => { const { pluginName, packageName } = params; const scaffoldsFilePath = path.join("apps", "admin", "src", "plugins", "Scaffolds.tsx"); diff --git a/webiny.project.ts b/webiny.project.ts index 3f5fffaccf1..6b8e1b2ec21 100644 --- a/webiny.project.ts +++ b/webiny.project.ts @@ -17,6 +17,8 @@ export default { import("@webiny/cli-plugin-deploy-pulumi"), import("@webiny/cwp-template-aws/cli"), import("@webiny/cli-plugin-scaffold"), + import("@webiny/cli-plugin-scaffold-graphql-service"), + import("@webiny/cli-plugin-scaffold-admin-app-module"), import("@webiny/cli-plugin-scaffold-plugins"), import("@webiny/cli-plugin-scaffold-ci") ]); From d447aa72239a70e23a643db3234ef16cb67ab9d3 Mon Sep 17 00:00:00 2001 From: adrians5j Date: Mon, 6 May 2024 12:27:40 +0200 Subject: [PATCH 17/32] wip: create essential plugins scaffold --- apps/admin/src/App.auth0.tsx | 4 +- apps/admin/src/App.editor.tsx | 4 +- apps/admin/src/App.fm.tsx | 4 +- apps/admin/src/App.okta.tsx | 4 +- apps/admin/src/App.tsx | 4 +- apps/admin/src/Extensions.tsx | 6 + .../src/plugins/scaffolds/AdminPlugins.tsx | 5 - apps/api/graphql/src/extensions.ts | 2 + apps/api/graphql/src/index.ts | 10 +- package.json | 449 +++++++++--------- packages/api-serverless-cms/package.json | 4 +- .../generators/utils/addPluginToApiApp.tsx | 10 +- .../generators/utils/addPluginToReactApp.tsx | 2 +- yarn.lock | 7 + 14 files changed, 261 insertions(+), 254 deletions(-) create mode 100644 apps/admin/src/Extensions.tsx delete mode 100644 apps/admin/src/plugins/scaffolds/AdminPlugins.tsx create mode 100644 apps/api/graphql/src/extensions.ts diff --git a/apps/admin/src/App.auth0.tsx b/apps/admin/src/App.auth0.tsx index a6a73806dfe..15b9bded727 100644 --- a/apps/admin/src/App.auth0.tsx +++ b/apps/admin/src/App.auth0.tsx @@ -1,7 +1,7 @@ import React from "react"; import { Admin } from "@webiny/app-serverless-cms"; import { Auth0 } from "@webiny/app-admin-auth0"; -import { AdminPlugins } from "./plugins/scaffolds/AdminPlugins"; +import { Extensions } from "./Extensions"; import "./App.scss"; export const App = () => { @@ -14,7 +14,7 @@ export const App = () => { }} rootAppClientId={String(process.env.REACT_APP_AUTH0_CLIENT_ID)} /> - + ); }; diff --git a/apps/admin/src/App.editor.tsx b/apps/admin/src/App.editor.tsx index 421bf24776f..81e29c37ce2 100644 --- a/apps/admin/src/App.editor.tsx +++ b/apps/admin/src/App.editor.tsx @@ -1,7 +1,7 @@ import React from "react"; import { Admin } from "@webiny/app-serverless-cms"; import { Cognito } from "@webiny/app-admin-users-cognito"; -import { AdminPlugins } from "./plugins/scaffolds/AdminPlugins"; +import { Extensions } from "./Extensions"; import { Editor } from "@webiny/app-page-builder-editor"; import "./App.scss"; @@ -10,7 +10,7 @@ export const App = () => { - + ); }; diff --git a/apps/admin/src/App.fm.tsx b/apps/admin/src/App.fm.tsx index 04fc83d14ee..c3a53d9c10e 100644 --- a/apps/admin/src/App.fm.tsx +++ b/apps/admin/src/App.fm.tsx @@ -2,7 +2,7 @@ import React, { useCallback } from "react"; import { Admin, createComponentPlugin } from "@webiny/app-serverless-cms"; import { FileManagerFileItem, FileManagerRenderer, OverlayLayout } from "@webiny/app-admin"; import { Cognito } from "@webiny/app-admin-users-cognito"; -import { AdminPlugins } from "./plugins/scaffolds/AdminPlugins"; +import { Extensions } from "./Extensions"; import "./App.scss"; const CustomFileManager = createComponentPlugin(FileManagerRenderer, () => { @@ -37,7 +37,7 @@ export const App = () => { - + ); }; diff --git a/apps/admin/src/App.okta.tsx b/apps/admin/src/App.okta.tsx index 994b1ac2534..7ffc0f568f6 100644 --- a/apps/admin/src/App.okta.tsx +++ b/apps/admin/src/App.okta.tsx @@ -1,7 +1,7 @@ import React from "react"; import { Admin } from "@webiny/app-serverless-cms"; import { Okta } from "@webiny/app-admin-okta"; -import { AdminPlugins } from "./plugins/scaffolds/AdminPlugins"; +import { Extensions } from "./Extensions"; import "./App.scss"; import { oktaFactory, rootAppClientId } from "./okta"; @@ -10,7 +10,7 @@ export const App = () => { return ( - + ); }; diff --git a/apps/admin/src/App.tsx b/apps/admin/src/App.tsx index 2276bce157c..ac6cee40cd1 100644 --- a/apps/admin/src/App.tsx +++ b/apps/admin/src/App.tsx @@ -1,14 +1,14 @@ import React from "react"; import { Admin } from "@webiny/app-serverless-cms"; import { Cognito } from "@webiny/app-admin-users-cognito"; -import { AdminPlugins } from "./plugins/scaffolds/AdminPlugins"; +import { Extensions } from "./Extensions"; import "./App.scss"; export const App = () => { return ( - + ); }; diff --git a/apps/admin/src/Extensions.tsx b/apps/admin/src/Extensions.tsx new file mode 100644 index 00000000000..00cd662531a --- /dev/null +++ b/apps/admin/src/Extensions.tsx @@ -0,0 +1,6 @@ +// This file is automatically updated via scaffolding utilities. +import React from "react"; + +export const Extensions = () => { + return <>; +}; diff --git a/apps/admin/src/plugins/scaffolds/AdminPlugins.tsx b/apps/admin/src/plugins/scaffolds/AdminPlugins.tsx deleted file mode 100644 index 5425d573d9f..00000000000 --- a/apps/admin/src/plugins/scaffolds/AdminPlugins.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import React from "react"; - -export const AdminPlugins = () => { - return <>; -}; diff --git a/apps/api/graphql/src/extensions.ts b/apps/api/graphql/src/extensions.ts new file mode 100644 index 00000000000..4b6c9fbff0d --- /dev/null +++ b/apps/api/graphql/src/extensions.ts @@ -0,0 +1,2 @@ +// This file is automatically updated via scaffolding utilities. +export const extensions = () => []; diff --git a/apps/api/graphql/src/index.ts b/apps/api/graphql/src/index.ts index 6cfe84d46f3..be937e2ccf9 100644 --- a/apps/api/graphql/src/index.ts +++ b/apps/api/graphql/src/index.ts @@ -38,12 +38,13 @@ import { createAco } from "@webiny/api-aco"; import { createAcoPageBuilderContext } from "@webiny/api-page-builder-aco"; import { createAuditLogs } from "@webiny/api-audit-logs"; import { createBackgroundTasks } from "@webiny/api-background-tasks-ddb"; -import scaffoldsPlugins from "./plugins/scaffolds"; import { createBenchmarkEnablePlugin } from "~/plugins/benchmarkEnable"; import { createCountDynamoDbTask } from "~/plugins/countDynamoDbTask"; import { createContinuingTask } from "~/plugins/continuingTask"; import { createWebsockets } from "@webiny/api-websockets"; import { createLockingMechanism } from "@webiny/api-locking-mechanism"; +import scaffoldsPlugins from "./plugins/scaffolds"; +import { extensions } from "./extensions"; const debug = process.env.DEBUG === "true"; const documentClient = getDocumentClient(); @@ -107,7 +108,6 @@ export const handler = createHandler({ createAcoPageBuilderContext(), createAcoHcmsContext(), createHcmsTasks(), - scaffoldsPlugins(), createFileModelModifier(({ modifier }) => { modifier.addField({ id: "customField1", @@ -134,7 +134,11 @@ export const handler = createHandler({ }), createAuditLogs(), createCountDynamoDbTask(), - createContinuingTask() + createContinuingTask(), + + // Leave this at the end. + scaffoldsPlugins(), + extensions() ], debug }); diff --git a/package.json b/package.json index dc5e983a9c3..aeeb4df24fc 100644 --- a/package.json +++ b/package.json @@ -1,226 +1,227 @@ { - "private": true, - "workspaces": { - "packages": [ - "packages/*", - "migrations", - "cypress-tests", - "apps/admin", - "apps/custom", - "apps/website", - "apps/website/prerendering/*", - "apps/theme", - "apps/core/dynamoToElastic", - "apps/api/apw/*", - "apps/api/fileManager/*", - "apps/api/graphql", - "apps/api/migration", - "apps/api/pageBuilder/updateSettings", - "apps/api/pageBuilder/import/*", - "apps/api/pageBuilder/export/*", - "scripts/buildPackages", - "scripts/prepublishOnly" - ] - }, - "author": "Webiny Ltd.", - "repository": { - "type": "git", - "url": "https://github.com/webiny/webiny-js.git" - }, - "devDependencies": { - "@babel/cli": "^7.23.9", - "@babel/core": "^7.24.0", - "@babel/eslint-parser": "^7.23.9", - "@commitlint/cli": "^11.0.0", - "@commitlint/config-conventional": "^11.0.0", - "@octokit/rest": "^20.0.2", - "@types/fs-extra": "^8.0.1", - "@types/jest": "^29.5.11", - "@types/node": "^18.0.0", - "@types/prettier": "^2.7.3", - "@types/react": "17.0.39", - "@types/react-dom": "17.0.11", - "@typescript-eslint/eslint-plugin": "^5.5.0", - "@typescript-eslint/parser": "^5.5.0", - "adio": "^1.0.1", - "babel-jest": "29.7.0", - "babel-plugin-dynamic-import-node": "2.3.3", - "babel-plugin-macros": "3.1.0", - "babel-plugin-module-resolver": "^5.0.0", - "chalk": "^4.1.0", - "cross-env": "^5.2.0", - "deepmerge": "^4.3.1", - "env-ci": "2.0.1", - "eslint": "^8.56.0", - "eslint-config-standard": "^16.0.3", - "eslint-import-resolver-babel-module": "^5.3.1", - "eslint-plugin-import": "^2.25.3", - "eslint-plugin-jest": "^25.3.0", - "eslint-plugin-lodash": "^7.4.0", - "eslint-plugin-node": "^11.1.0", - "eslint-plugin-promise": "^5.2.0", - "eslint-plugin-react": "^7.27.1", - "eslint-plugin-standard": "^5.0.0", - "execa": "^5.1.1", - "folder-hash": "^4.0.0", - "fs-extra": "^7.0.0", - "get-stream": "^3.0.0", - "get-yarn-workspaces": "^1.0.2", - "git-cz": "^1.7.1", - "github-actions-wac": "^1.4.1", - "glob": "^7.1.3", - "graphql": "^15.7.2", - "husky": "^4.2.5", - "inquirer": "^7.0.0", - "inquirer-autocomplete-prompt": "^1.0.1", - "inquirer-checkbox-plus-prompt": "^1.0.1", - "inquirer-maxlength-input-prompt": "^1.0.0", - "jest": "^29.7.0", - "jest-environment-jsdom": "^29.7.0", - "jest-extended": "4.0.2", - "lerna": "8.1.2", - "lint-staged": "^15.2.2", - "listr": "^0.14.3", - "load-json-file": "^6.2.0", - "lodash": "4.17.21", - "longest": "^2.0.1", - "minimatch": "^5.1.0", - "nanoid": "^3.3.7", - "node-fetch": "^2.6.1", - "pm2": "^5.3.1", - "prettier": "^2.8.3", - "rimraf": "^5.0.5", - "semver": "^7.5.4", - "ts-expect": "^1.3.0", - "ts-jest": "^29.1.2", - "typescript": "4.7.4", - "typescript-transform-paths": "^3.4.6", - "verdaccio": "^5.29.1", - "write-json-file": "^4.2.0", - "yargs": "^17.0.1" - }, - "optionalDependencies": { - "fsevents": "^2.0.7" - }, - "scripts": { - "awp": "yarn add-webiny-package", - "add-webiny-package": "node scripts/addWebinyPackage.js", - "ci-workflows:build": "yarn ghawac build", - "ci-workflows:watch": "yarn ghawac watch", - "check-ts-configs": "node scripts/checkTsConfigs.js", - "check-package-dependencies": "node scripts/checkPackageNodeModules.js", - "deploy": "yarn webiny deploy", - "open": "yarn webiny open", - "eslint": "eslint \"**/*.{js,jsx,ts,tsx}\" --max-warnings=0", - "eslint:fix": "yarn eslint --fix", - "build": "node scripts/buildPackages", - "build:quick": "node scripts/buildPackages --build-overrides='{\"tsConfig\":{\"compilerOptions\":{\"skipLibCheck\":true}}}'", - "build:apps": "yarn webiny ws run build --scope='@webiny/app*'", - "build:api": "yarn webiny ws run build --scope='@webiny/api*' --scope='@webiny/handler*'", - "watch": "yarn webiny watch", - "watch:apps": "yarn webiny ws run watch --scope='@webiny/app*'", - "watch:api": "yarn webiny ws run watch --scope='@webiny/api*'", - "clear-dist": "yarn rimraf packages/*/dist", - "delete-empty-package-folders": "node scripts/deleteEmptyPackageFolders.js", - "cypress:open": "cd cypress-tests && yarn cypress open", - "cy:open": "yarn cypress:open", - "cypress:run": "cd cypress-tests && yarn cypress run", - "cy:run": "yarn cypress:run", - "cypress:ts": "cd cypress-tests && yarn tsc --noEmit", - "cy:ts": "yarn cypress:ts", - "webiny-versions": "node ./scripts/webinyVersions.js", - "trigger-release": "node ./scripts/release/triggerRelease.js", - "dispatch-github-event": "node ./scripts/dispatchGitHubEvent.js", - "lint-staged": "lint-staged", - "postinstall": "yarn node ./scripts/linkWorkspaces.js", - "prepublishOnly": "node scripts/prepublishOnly", - "prettier": "prettier \"**/**/*.{js,jsx,ts,tsx,json}\" --config .prettierrc.js", - "prettier:check": "yarn prettier --check", - "prettier:fix": "yarn prettier --write", - "lint:fix": "yarn eslint:fix && yarn prettier:fix", - "release": "node ./scripts/release/index.js", - "setup-project": "node scripts/setupProject", - "setup-env-files": "node scripts/setupEnvFiles", - "setup-cypress": "node scripts/setupCypress", - "test": "jest --runInBand --logHeapUsage --config jest.config.js", - "test:unit": "cross-env TEST_TYPE=unit yarn test", - "test:integration": "cross-env TEST_TYPE=integration yarn test", - "test:e2e": "cross-env TEST_TYPE=e2e yarn test", - "validate-packages": "node scripts/validatePackages.js", - "verdaccio:start": "yarn verdaccio -c ./.verdaccio.yaml", - "verdaccio:start:detached": "yarn pm2 start \"yarn verdaccio:start\"", - "webiny": "./node_modules/.bin/webiny", - "wby": "./node_modules/.bin/wby", - "webiny-ui-build-storybook": "cd packages/ui && cross-env OUT=../../netlify-static yarn build-storybook" - }, - "husky": { - "hooks": { - "pre-commit": "yarn && git add yarn.lock && yarn lint-staged && yarn adio && yarn check-ts-configs", - "commit-msg": "commitlint -E HUSKY_GIT_PARAMS" - } - }, - "lint-staged": { - "**/*.{js,ts,tsx}": [ - "prettier --write", - "eslint --max-warnings=0 --no-ignore" - ] - }, - "yargs": { - "populate--": true - }, - "commitlint": { - "extends": [ - "@commitlint/config-conventional" - ], - "rules": { - "type-enum": [ - 2, - "always", - [ - "feat", - "fix", - "docs", - "style", - "refactor", - "test", - "build", - "ci", - "chore", - "revert", - "merge", - "wip" - ] - ] - } - }, - "lerna": { - "version": "0.0.0", - "packages": [ - "packages/*" - ] - }, - "resolutions": { - "@emotion/react": "11.10.8", - "@octokit/rest": "^20.0.2", - "@types/react": "17.0.39", - "@types/jsdom": "link:./typings/void", - "@types/webpack": "^5.28.0", - "browserify-sign": "^4.2.2", - "@babel/traverse": "^7.24.0", - "jsdom": "24.0.0", - "react": "17.0.2", - "follow-redirects": "^1.15.6", - "crypto-js": "^4.2.0", - "ip": "^2.0.1", - "postcss": "^8.4.35", - "react-dom": "17.0.2", - "semver": "7.5.4", - "typescript": "4.7.4", - "codex-tooltip": "1.0.2", - "@types/eslint": "8.2.1", - "xml2js": "0.6.2", - "yargs": "^17.3.1", - "lerna@8.1.2": "patch:lerna@npm%3A8.1.2#./.yarn/patches/lerna-npm-8.1.2-be48ad2329.patch" - }, - "packageManager": "yarn@3.6.4" + "private": true, + "workspaces": { + "packages": [ + "packages/*", + "migrations", + "cypress-tests", + "apps/admin", + "apps/custom", + "apps/website", + "apps/website/prerendering/*", + "apps/theme", + "apps/core/dynamoToElastic", + "apps/api/apw/*", + "apps/api/fileManager/*", + "apps/api/graphql", + "apps/api/migration", + "apps/api/pageBuilder/updateSettings", + "apps/api/pageBuilder/import/*", + "apps/api/pageBuilder/export/*", + "scripts/buildPackages", + "scripts/prepublishOnly", + "plugins/myCustomPlugin" + ] + }, + "author": "Webiny Ltd.", + "repository": { + "type": "git", + "url": "https://github.com/webiny/webiny-js.git" + }, + "devDependencies": { + "@babel/cli": "^7.23.9", + "@babel/core": "^7.24.0", + "@babel/eslint-parser": "^7.23.9", + "@commitlint/cli": "^11.0.0", + "@commitlint/config-conventional": "^11.0.0", + "@octokit/rest": "^20.0.2", + "@types/fs-extra": "^8.0.1", + "@types/jest": "^29.5.11", + "@types/node": "^18.0.0", + "@types/prettier": "^2.7.3", + "@types/react": "17.0.39", + "@types/react-dom": "17.0.11", + "@typescript-eslint/eslint-plugin": "^5.5.0", + "@typescript-eslint/parser": "^5.5.0", + "adio": "^1.0.1", + "babel-jest": "29.7.0", + "babel-plugin-dynamic-import-node": "2.3.3", + "babel-plugin-macros": "3.1.0", + "babel-plugin-module-resolver": "^5.0.0", + "chalk": "^4.1.0", + "cross-env": "^5.2.0", + "deepmerge": "^4.3.1", + "env-ci": "2.0.1", + "eslint": "^8.56.0", + "eslint-config-standard": "^16.0.3", + "eslint-import-resolver-babel-module": "^5.3.1", + "eslint-plugin-import": "^2.25.3", + "eslint-plugin-jest": "^25.3.0", + "eslint-plugin-lodash": "^7.4.0", + "eslint-plugin-node": "^11.1.0", + "eslint-plugin-promise": "^5.2.0", + "eslint-plugin-react": "^7.27.1", + "eslint-plugin-standard": "^5.0.0", + "execa": "^5.1.1", + "folder-hash": "^4.0.0", + "fs-extra": "^7.0.0", + "get-stream": "^3.0.0", + "get-yarn-workspaces": "^1.0.2", + "git-cz": "^1.7.1", + "github-actions-wac": "^1.4.1", + "glob": "^7.1.3", + "graphql": "^15.7.2", + "husky": "^4.2.5", + "inquirer": "^7.0.0", + "inquirer-autocomplete-prompt": "^1.0.1", + "inquirer-checkbox-plus-prompt": "^1.0.1", + "inquirer-maxlength-input-prompt": "^1.0.0", + "jest": "^29.7.0", + "jest-environment-jsdom": "^29.7.0", + "jest-extended": "4.0.2", + "lerna": "8.1.2", + "lint-staged": "^15.2.2", + "listr": "^0.14.3", + "load-json-file": "^6.2.0", + "lodash": "4.17.21", + "longest": "^2.0.1", + "minimatch": "^5.1.0", + "nanoid": "^3.3.7", + "node-fetch": "^2.6.1", + "pm2": "^5.3.1", + "prettier": "^2.8.3", + "rimraf": "^5.0.5", + "semver": "^7.5.4", + "ts-expect": "^1.3.0", + "ts-jest": "^29.1.2", + "typescript": "4.7.4", + "typescript-transform-paths": "^3.4.6", + "verdaccio": "^5.29.1", + "write-json-file": "^4.2.0", + "yargs": "^17.0.1" + }, + "optionalDependencies": { + "fsevents": "^2.0.7" + }, + "scripts": { + "awp": "yarn add-webiny-package", + "add-webiny-package": "node scripts/addWebinyPackage.js", + "ci-workflows:build": "yarn ghawac build", + "ci-workflows:watch": "yarn ghawac watch", + "check-ts-configs": "node scripts/checkTsConfigs.js", + "check-package-dependencies": "node scripts/checkPackageNodeModules.js", + "deploy": "yarn webiny deploy", + "open": "yarn webiny open", + "eslint": "eslint \"**/*.{js,jsx,ts,tsx}\" --max-warnings=0", + "eslint:fix": "yarn eslint --fix", + "build": "node scripts/buildPackages", + "build:quick": "node scripts/buildPackages --build-overrides='{\"tsConfig\":{\"compilerOptions\":{\"skipLibCheck\":true}}}'", + "build:apps": "yarn webiny ws run build --scope='@webiny/app*'", + "build:api": "yarn webiny ws run build --scope='@webiny/api*' --scope='@webiny/handler*'", + "watch": "yarn webiny watch", + "watch:apps": "yarn webiny ws run watch --scope='@webiny/app*'", + "watch:api": "yarn webiny ws run watch --scope='@webiny/api*'", + "clear-dist": "yarn rimraf packages/*/dist", + "delete-empty-package-folders": "node scripts/deleteEmptyPackageFolders.js", + "cypress:open": "cd cypress-tests && yarn cypress open", + "cy:open": "yarn cypress:open", + "cypress:run": "cd cypress-tests && yarn cypress run", + "cy:run": "yarn cypress:run", + "cypress:ts": "cd cypress-tests && yarn tsc --noEmit", + "cy:ts": "yarn cypress:ts", + "webiny-versions": "node ./scripts/webinyVersions.js", + "trigger-release": "node ./scripts/release/triggerRelease.js", + "dispatch-github-event": "node ./scripts/dispatchGitHubEvent.js", + "lint-staged": "lint-staged", + "postinstall": "yarn node ./scripts/linkWorkspaces.js", + "prepublishOnly": "node scripts/prepublishOnly", + "prettier": "prettier \"**/**/*.{js,jsx,ts,tsx,json}\" --config .prettierrc.js", + "prettier:check": "yarn prettier --check", + "prettier:fix": "yarn prettier --write", + "lint:fix": "yarn eslint:fix && yarn prettier:fix", + "release": "node ./scripts/release/index.js", + "setup-project": "node scripts/setupProject", + "setup-env-files": "node scripts/setupEnvFiles", + "setup-cypress": "node scripts/setupCypress", + "test": "jest --runInBand --logHeapUsage --config jest.config.js", + "test:unit": "cross-env TEST_TYPE=unit yarn test", + "test:integration": "cross-env TEST_TYPE=integration yarn test", + "test:e2e": "cross-env TEST_TYPE=e2e yarn test", + "validate-packages": "node scripts/validatePackages.js", + "verdaccio:start": "yarn verdaccio -c ./.verdaccio.yaml", + "verdaccio:start:detached": "yarn pm2 start \"yarn verdaccio:start\"", + "webiny": "./node_modules/.bin/webiny", + "wby": "./node_modules/.bin/wby", + "webiny-ui-build-storybook": "cd packages/ui && cross-env OUT=../../netlify-static yarn build-storybook" + }, + "husky": { + "hooks": { + "pre-commit": "yarn && git add yarn.lock && yarn lint-staged && yarn adio && yarn check-ts-configs", + "commit-msg": "commitlint -E HUSKY_GIT_PARAMS" + } + }, + "lint-staged": { + "**/*.{js,ts,tsx}": [ + "prettier --write", + "eslint --max-warnings=0 --no-ignore" + ] + }, + "yargs": { + "populate--": true + }, + "commitlint": { + "extends": [ + "@commitlint/config-conventional" + ], + "rules": { + "type-enum": [ + 2, + "always", + [ + "feat", + "fix", + "docs", + "style", + "refactor", + "test", + "build", + "ci", + "chore", + "revert", + "merge", + "wip" + ] + ] + } + }, + "lerna": { + "version": "0.0.0", + "packages": [ + "packages/*" + ] + }, + "resolutions": { + "@emotion/react": "11.10.8", + "@octokit/rest": "^20.0.2", + "@types/react": "17.0.39", + "@types/jsdom": "link:./typings/void", + "@types/webpack": "^5.28.0", + "browserify-sign": "^4.2.2", + "@babel/traverse": "^7.24.0", + "jsdom": "24.0.0", + "react": "17.0.2", + "follow-redirects": "^1.15.6", + "crypto-js": "^4.2.0", + "ip": "^2.0.1", + "postcss": "^8.4.35", + "react-dom": "17.0.2", + "semver": "7.5.4", + "typescript": "4.7.4", + "codex-tooltip": "1.0.2", + "@types/eslint": "8.2.1", + "xml2js": "0.6.2", + "yargs": "^17.3.1", + "lerna@8.1.2": "patch:lerna@npm%3A8.1.2#./.yarn/patches/lerna-npm-8.1.2-be48ad2329.patch" + }, + "packageManager": "yarn@3.6.4" } diff --git a/packages/api-serverless-cms/package.json b/packages/api-serverless-cms/package.json index 974e1e8c9c5..4efd16ef13f 100644 --- a/packages/api-serverless-cms/package.json +++ b/packages/api-serverless-cms/package.json @@ -13,7 +13,6 @@ "@webiny/api-aco": "0.0.0", "@webiny/api-file-manager": "0.0.0", "@webiny/api-form-builder": "0.0.0", - "@webiny/handler-graphql": "0.0.0", "@webiny/api-headless-cms": "0.0.0", "@webiny/api-i18n": "0.0.0", "@webiny/api-i18n-content": "0.0.0", @@ -22,7 +21,8 @@ "@webiny/api-prerendering-service": "0.0.0", "@webiny/api-security": "0.0.0", "@webiny/api-tenancy": "0.0.0", - "@webiny/handler-client": "0.0.0" + "@webiny/handler-client": "0.0.0", + "@webiny/handler-graphql": "0.0.0" }, "devDependencies": { "@babel/cli": "^7.23.9", diff --git a/packages/cli-plugin-scaffold-plugins/src/generators/utils/addPluginToApiApp.tsx b/packages/cli-plugin-scaffold-plugins/src/generators/utils/addPluginToApiApp.tsx index f3218a3eb7e..a1d7c46be88 100644 --- a/packages/cli-plugin-scaffold-plugins/src/generators/utils/addPluginToApiApp.tsx +++ b/packages/cli-plugin-scaffold-plugins/src/generators/utils/addPluginToApiApp.tsx @@ -10,15 +10,7 @@ interface Params { export const addPluginToApiApp = async (params: Params): Promise => { const { pluginName, packageName } = params; - const scaffoldsFilePath = path.join( - "apps", - "api", - "graphql", - "src", - "plugins", - "scaffolds", - "index.ts" - ); + const scaffoldsFilePath = path.join("apps", "api", "graphql", "src", "extensions.ts"); const pluginsFactory = pluginName + "PluginsFactory"; const importName = "{ createPlugins as " + pluginsFactory + " }"; diff --git a/packages/cli-plugin-scaffold-plugins/src/generators/utils/addPluginToReactApp.tsx b/packages/cli-plugin-scaffold-plugins/src/generators/utils/addPluginToReactApp.tsx index 0302aaaeb7b..0f1b5957011 100644 --- a/packages/cli-plugin-scaffold-plugins/src/generators/utils/addPluginToReactApp.tsx +++ b/packages/cli-plugin-scaffold-plugins/src/generators/utils/addPluginToReactApp.tsx @@ -10,7 +10,7 @@ interface Params { export const addPluginToReactApp = async (params: Params): Promise => { const { pluginName, packageName } = params; - const scaffoldsFilePath = path.join("apps", "admin", "src", "plugins", "Scaffolds.tsx"); + const scaffoldsFilePath = path.join("apps", "admin", "src", "Extensions.tsx"); const pluginsFactory = pluginName + "PluginsFactory"; const importName = "{ createPlugins as " + pluginsFactory + " }"; diff --git a/yarn.lock b/yarn.lock index 374263fee40..3adbb4847cc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -14280,6 +14280,7 @@ __metadata: "@webiny/api-tenancy": 0.0.0 "@webiny/cli": 0.0.0 "@webiny/handler-client": 0.0.0 + "@webiny/handler-graphql": 0.0.0 "@webiny/project-utils": 0.0.0 rimraf: ^5.0.5 ttypescript: ^1.5.13 @@ -30505,6 +30506,12 @@ __metadata: languageName: node linkType: hard +"my-custom-plugin@workspace:plugins/myCustomPlugin": + version: 0.0.0-use.local + resolution: "my-custom-plugin@workspace:plugins/myCustomPlugin" + languageName: unknown + linkType: soft + "nanoclone@npm:^0.2.1": version: 0.2.1 resolution: "nanoclone@npm:0.2.1" From a34be3aad07998b1a60fef4e4ff3a418987d4f72 Mon Sep 17 00:00:00 2001 From: adrians5j Date: Mon, 6 May 2024 13:22:02 +0200 Subject: [PATCH 18/32] wip: create essential plugins scaffold --- apps/api/graphql/src/extensions.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/api/graphql/src/extensions.ts b/apps/api/graphql/src/extensions.ts index 4b6c9fbff0d..658b605320b 100644 --- a/apps/api/graphql/src/extensions.ts +++ b/apps/api/graphql/src/extensions.ts @@ -1,2 +1,4 @@ // This file is automatically updated via scaffolding utilities. -export const extensions = () => []; +export const extensions = () => { + return []; +}; From 90ae35a233944893aa9273a18e87a0ade306bb29 Mon Sep 17 00:00:00 2001 From: adrians5j Date: Mon, 6 May 2024 13:22:18 +0200 Subject: [PATCH 19/32] wip: create essential plugins scaffold --- .../templates/admin/src/index.tsx | 4 +++- .../templates/api/src/index.ts | 8 +++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/cli-plugin-scaffold-plugins/templates/admin/src/index.tsx b/packages/cli-plugin-scaffold-plugins/templates/admin/src/index.tsx index dfc9d199f64..89aec64af47 100644 --- a/packages/cli-plugin-scaffold-plugins/templates/admin/src/index.tsx +++ b/packages/cli-plugin-scaffold-plugins/templates/admin/src/index.tsx @@ -1,3 +1,5 @@ import React from "react"; -export const createPlugins = () => <>{/*Your plugins here.*/}; +export const createPlugins = () => { + return <>{/*Your plugins here.*/}; +}; diff --git a/packages/cli-plugin-scaffold-plugins/templates/api/src/index.ts b/packages/cli-plugin-scaffold-plugins/templates/api/src/index.ts index fec57ff6047..9b5ed911533 100644 --- a/packages/cli-plugin-scaffold-plugins/templates/api/src/index.ts +++ b/packages/cli-plugin-scaffold-plugins/templates/api/src/index.ts @@ -1,3 +1,5 @@ -export const createPlugins = () => [ - // Your plugins here. -]; +export const createPlugins = () => { + return [ + // Your plugins here. + ]; +}; From 0093eb0444eb0065e9b00fd9f8595112d6445273 Mon Sep 17 00:00:00 2001 From: adrians5j Date: Mon, 6 May 2024 13:26:51 +0200 Subject: [PATCH 20/32] wip: create essential plugins scaffold --- .../.babelrc.js | 0 .../LICENSE | 0 .../cli-plugin-scaffold-extensions/README.md | 15 ++++ .../package.json | 4 +- .../src/generators/admin.ts | 0 .../src/generators/api.ts | 0 .../src/generators/index.ts | 0 .../generators/utils/addPluginToApiApp.tsx | 18 ++-- .../generators/utils/addPluginToReactApp.tsx | 82 +++++++++++++++++++ .../src/index.ts | 44 +++++----- .../src/types.ts | 2 +- .../templates/admin/package.json | 0 .../templates/admin/src/index.tsx | 0 .../templates/admin/tsconfig.json | 0 .../templates/api/package.json | 0 .../templates/api/src/index.ts | 0 .../templates/api/tsconfig.json | 0 .../tsconfig.build.json | 0 .../tsconfig.json | 0 .../webiny.config.js | 0 .../cli-plugin-scaffold-plugins/README.md | 15 ---- .../generators/utils/addPluginToReactApp.tsx | 82 ------------------- webiny.project.ts | 2 +- 23 files changed, 133 insertions(+), 131 deletions(-) rename packages/{cli-plugin-scaffold-plugins => cli-plugin-scaffold-extensions}/.babelrc.js (100%) rename packages/{cli-plugin-scaffold-plugins => cli-plugin-scaffold-extensions}/LICENSE (100%) create mode 100644 packages/cli-plugin-scaffold-extensions/README.md rename packages/{cli-plugin-scaffold-plugins => cli-plugin-scaffold-extensions}/package.json (92%) rename packages/{cli-plugin-scaffold-plugins => cli-plugin-scaffold-extensions}/src/generators/admin.ts (100%) rename packages/{cli-plugin-scaffold-plugins => cli-plugin-scaffold-extensions}/src/generators/api.ts (100%) rename packages/{cli-plugin-scaffold-plugins => cli-plugin-scaffold-extensions}/src/generators/index.ts (100%) rename packages/{cli-plugin-scaffold-plugins => cli-plugin-scaffold-extensions}/src/generators/utils/addPluginToApiApp.tsx (67%) create mode 100644 packages/cli-plugin-scaffold-extensions/src/generators/utils/addPluginToReactApp.tsx rename packages/{cli-plugin-scaffold-plugins => cli-plugin-scaffold-extensions}/src/index.ts (78%) rename packages/{cli-plugin-scaffold-plugins => cli-plugin-scaffold-extensions}/src/types.ts (84%) rename packages/{cli-plugin-scaffold-plugins => cli-plugin-scaffold-extensions}/templates/admin/package.json (100%) rename packages/{cli-plugin-scaffold-plugins => cli-plugin-scaffold-extensions}/templates/admin/src/index.tsx (100%) rename packages/{cli-plugin-scaffold-plugins => cli-plugin-scaffold-extensions}/templates/admin/tsconfig.json (100%) rename packages/{cli-plugin-scaffold-plugins => cli-plugin-scaffold-extensions}/templates/api/package.json (100%) rename packages/{cli-plugin-scaffold-plugins => cli-plugin-scaffold-extensions}/templates/api/src/index.ts (100%) rename packages/{cli-plugin-scaffold-plugins => cli-plugin-scaffold-extensions}/templates/api/tsconfig.json (100%) rename packages/{cli-plugin-scaffold-plugins => cli-plugin-scaffold-extensions}/tsconfig.build.json (100%) rename packages/{cli-plugin-scaffold-plugins => cli-plugin-scaffold-extensions}/tsconfig.json (100%) rename packages/{cli-plugin-scaffold-plugins => cli-plugin-scaffold-extensions}/webiny.config.js (100%) delete mode 100644 packages/cli-plugin-scaffold-plugins/README.md delete mode 100644 packages/cli-plugin-scaffold-plugins/src/generators/utils/addPluginToReactApp.tsx diff --git a/packages/cli-plugin-scaffold-plugins/.babelrc.js b/packages/cli-plugin-scaffold-extensions/.babelrc.js similarity index 100% rename from packages/cli-plugin-scaffold-plugins/.babelrc.js rename to packages/cli-plugin-scaffold-extensions/.babelrc.js diff --git a/packages/cli-plugin-scaffold-plugins/LICENSE b/packages/cli-plugin-scaffold-extensions/LICENSE similarity index 100% rename from packages/cli-plugin-scaffold-plugins/LICENSE rename to packages/cli-plugin-scaffold-extensions/LICENSE diff --git a/packages/cli-plugin-scaffold-extensions/README.md b/packages/cli-plugin-scaffold-extensions/README.md new file mode 100644 index 00000000000..df02f6c9ecd --- /dev/null +++ b/packages/cli-plugin-scaffold-extensions/README.md @@ -0,0 +1,15 @@ +# @webiny/cli-plugin-scaffold-extensions +[![](https://img.shields.io/npm/dw/@webiny/cli-plugin-scaffold-extensions.svg)](https://www.npmjs.com/package/@webiny/cli-plugin-scaffold-extensions) +[![](https://img.shields.io/npm/v/@webiny/cli-plugin-scaffold-extensions.svg)](https://www.npmjs.com/package/@webiny/cli-plugin-scaffold-extensions) +[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier) +[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com) + +## Install +``` +npm install --save @webiny/cli-plugin-scaffold-extensions +``` + +Or if you prefer yarn: +``` +yarn add @webiny/cli-plugin-scaffold-extensions +``` diff --git a/packages/cli-plugin-scaffold-plugins/package.json b/packages/cli-plugin-scaffold-extensions/package.json similarity index 92% rename from packages/cli-plugin-scaffold-plugins/package.json rename to packages/cli-plugin-scaffold-extensions/package.json index b1825b5c0aa..01caf1d8874 100644 --- a/packages/cli-plugin-scaffold-plugins/package.json +++ b/packages/cli-plugin-scaffold-extensions/package.json @@ -1,5 +1,5 @@ { - "name": "@webiny/cli-plugin-scaffold-plugins", + "name": "@webiny/cli-plugin-scaffold-extensions", "version": "0.0.0", "description": "Scaffolds essential files for creating a new plugin.", "main": "index.js", @@ -7,7 +7,7 @@ "repository": { "type": "git", "url": "git+https://github.com/webiny/webiny-js.git", - "directory": "packages/cli-plugin-scaffold-plugins" + "directory": "packages/cli-plugin-scaffold-extensions" }, "author": { "name": "Webiny", diff --git a/packages/cli-plugin-scaffold-plugins/src/generators/admin.ts b/packages/cli-plugin-scaffold-extensions/src/generators/admin.ts similarity index 100% rename from packages/cli-plugin-scaffold-plugins/src/generators/admin.ts rename to packages/cli-plugin-scaffold-extensions/src/generators/admin.ts diff --git a/packages/cli-plugin-scaffold-plugins/src/generators/api.ts b/packages/cli-plugin-scaffold-extensions/src/generators/api.ts similarity index 100% rename from packages/cli-plugin-scaffold-plugins/src/generators/api.ts rename to packages/cli-plugin-scaffold-extensions/src/generators/api.ts diff --git a/packages/cli-plugin-scaffold-plugins/src/generators/index.ts b/packages/cli-plugin-scaffold-extensions/src/generators/index.ts similarity index 100% rename from packages/cli-plugin-scaffold-plugins/src/generators/index.ts rename to packages/cli-plugin-scaffold-extensions/src/generators/index.ts diff --git a/packages/cli-plugin-scaffold-plugins/src/generators/utils/addPluginToApiApp.tsx b/packages/cli-plugin-scaffold-extensions/src/generators/utils/addPluginToApiApp.tsx similarity index 67% rename from packages/cli-plugin-scaffold-plugins/src/generators/utils/addPluginToApiApp.tsx rename to packages/cli-plugin-scaffold-extensions/src/generators/utils/addPluginToApiApp.tsx index a1d7c46be88..29650b74c56 100644 --- a/packages/cli-plugin-scaffold-plugins/src/generators/utils/addPluginToApiApp.tsx +++ b/packages/cli-plugin-scaffold-extensions/src/generators/utils/addPluginToApiApp.tsx @@ -3,28 +3,28 @@ import path from "path"; import { formatCode } from "@webiny/cli-plugin-scaffold/utils"; interface Params { - pluginName: string; + extensionName: string; packageName: string; } export const addPluginToApiApp = async (params: Params): Promise => { - const { pluginName, packageName } = params; + const { extensionName, packageName } = params; - const scaffoldsFilePath = path.join("apps", "api", "graphql", "src", "extensions.ts"); + const extensionsFilePath = path.join("apps", "api", "graphql", "src", "extensions.ts"); - const pluginsFactory = pluginName + "PluginsFactory"; + const pluginsFactory = extensionName + "PluginsFactory"; const importName = "{ createPlugins as " + pluginsFactory + " }"; const importPath = packageName; const project = new Project(); - project.addSourceFileAtPath(scaffoldsFilePath); + project.addSourceFileAtPath(extensionsFilePath); - const source = project.getSourceFileOrThrow(scaffoldsFilePath); + const source = project.getSourceFileOrThrow(extensionsFilePath); const existingImportDeclaration = source.getImportDeclaration(importPath); if (existingImportDeclaration) { throw new Error( - `Could not import "${importPath}" in "${scaffoldsFilePath}" as it already exists.` + `Could not import "${importPath}" in "${extensionsFilePath}" as it already exists.` ); } @@ -45,9 +45,9 @@ export const addPluginToApiApp = async (params: Params): Promise => { Node.isArrayLiteralExpression(node) ) as ArrayLiteralExpression; - pluginsArray.addElement(pluginsFactory); + pluginsArray.addElement(`${pluginsFactory}()`); await source.save(); - await formatCode(scaffoldsFilePath, {}); + await formatCode(extensionsFilePath, {}); }; diff --git a/packages/cli-plugin-scaffold-extensions/src/generators/utils/addPluginToReactApp.tsx b/packages/cli-plugin-scaffold-extensions/src/generators/utils/addPluginToReactApp.tsx new file mode 100644 index 00000000000..3afa401664c --- /dev/null +++ b/packages/cli-plugin-scaffold-extensions/src/generators/utils/addPluginToReactApp.tsx @@ -0,0 +1,82 @@ +import { Project, Node, JsxFragment } from "ts-morph"; +import path from "path"; +import { formatCode } from "@webiny/cli-plugin-scaffold/utils"; + +interface Params { + extensionName: string; + packageName: string; +} + +export const addPluginToReactApp = async (params: Params): Promise => { + const { extensionName, packageName } = params; + + const extensionsFilePath = path.join("apps", "admin", "src", "Extensions.tsx"); + + const pluginsFactory = extensionName + "PluginsFactory"; + const importName = "{ createPlugins as " + pluginsFactory + " }"; + const importPath = packageName; + + const project = new Project(); + project.addSourceFileAtPath(extensionsFilePath); + + const source = project.getSourceFileOrThrow(extensionsFilePath); + + const existingImportDeclaration = source.getImportDeclaration(importPath); + if (existingImportDeclaration) { + throw new Error( + `Could not import "${importPath}" in "${extensionsFilePath}" as it already exists.` + ); + } + + let index = 1; + + const importDeclarations = source.getImportDeclarations(); + if (importDeclarations.length) { + const last = importDeclarations[importDeclarations.length - 1]; + index = last.getChildIndex() + 1; + } + + source.insertImportDeclaration(index, { + defaultImport: importName, + moduleSpecifier: importPath + }); + + const extensionsIdentifier = source.getFirstDescendant(node => { + if (!Node.isIdentifier(node)) { + return false; + } + + return node.getText() === "Extensions"; + }); + + if (!extensionsIdentifier) { + throw new Error( + `Could not find the "Extensions" React component in "${extensionsFilePath}". Did you maybe change the name of the component?` + ); + } + + const extensionsArrowFn = extensionsIdentifier.getNextSibling(node => Node.isArrowFunction(node)); + if (!extensionsArrowFn) { + throw new Error( + `Could not find the "Extensions" React component in "${extensionsFilePath}". Did you maybe change its definition? It should be an arrow function.` + ); + } + + const extensionsArrowFnFragment = extensionsArrowFn.getFirstDescendant(node => { + return Node.isJsxFragment(node); + }) as JsxFragment; + + const extensionsArrowFnFragmentChildrenText = extensionsArrowFnFragment + .getFullText() + .replace("<>", "") + .replace("", "") + .trim(); + + extensionsArrowFnFragment.replaceWithText( + `<>{${extensionName}PluginsFactory()}${extensionsArrowFnFragmentChildrenText}` + ); + + await source.save(); + + await formatCode(extensionsFilePath, {}); +}; diff --git a/packages/cli-plugin-scaffold-plugins/src/index.ts b/packages/cli-plugin-scaffold-extensions/src/index.ts similarity index 78% rename from packages/cli-plugin-scaffold-plugins/src/index.ts rename to packages/cli-plugin-scaffold-extensions/src/index.ts index f923af7c62c..26d174c1c7a 100644 --- a/packages/cli-plugin-scaffold-plugins/src/index.ts +++ b/packages/cli-plugin-scaffold-extensions/src/index.ts @@ -14,47 +14,49 @@ import validateNpmPackageName from "validate-npm-package-name"; * TODO: rewrite cli into typescript */ // @ts-expect-error -import { getProject } from "@webiny/cli/utils"; +import { getProject, log } from "@webiny/cli/utils"; import { generators } from "./generators"; const ncp = util.promisify(ncpBase.ncp); interface Input { - pluginName: string; + extensionName: string; packageName: string; location: string; pluginType: string; } +const EXTENSIONS_ROOT_FOLDER = 'extensions'; + export default (): CliCommandScaffoldTemplate => ({ name: "cli-plugin-scaffold-template-plugin", type: "cli-plugin-scaffold-template", scaffold: { - name: "New Plugin", - description: "Scaffolds essential files for creating a new plugin.", + name: "New Extension", + description: "Scaffolds essential files for creating a new extension.", questions: () => { return [ { name: "pluginType", - message: "What type of a plugin you want to create?", + message: "What type of an extension do you want to create?", type: "list", choices: [ - { name: "Admin plugin", value: "admin" }, - { name: "API plugin", value: "api" } + { name: "Admin extension", value: "admin" }, + { name: "API extension", value: "api" } ] }, { - name: "pluginName", - message: "Enter the plugin name:", + name: "extensionName", + message: "Enter the extension name:", default: "myCustomPlugin", - validate: pluginName => { - if (!pluginName) { - return "Missing plugin name."; + validate: extensionName => { + if (!extensionName) { + return "Missing extension name."; } - const isValidName = pluginName === Case.camel(pluginName); + const isValidName = extensionName === Case.camel(extensionName); if (!isValidName) { - return `Please use camel case when providing the name of the plugin (for example "myCustomPlugin").`; + return `Please use camel case when providing the name of the extension (for example "myCustomPlugin").`; } return true; @@ -64,7 +66,7 @@ export default (): CliCommandScaffoldTemplate => ({ name: "packageName", message: "Enter the package name:", default: (answers: Input) => { - return Case.kebab(answers.pluginName); + return Case.kebab(answers.extensionName); }, validate: pkgName => { if (!pkgName) { @@ -83,15 +85,15 @@ export default (): CliCommandScaffoldTemplate => ({ name: "location", message: `Enter the plugin location:`, default: (answers: Input) => { - return `plugins/${answers.pluginName}`; + return `${EXTENSIONS_ROOT_FOLDER}/${answers.extensionName}`; }, validate: location => { if (!location) { return "Please enter the package location."; } - if (!location.startsWith("plugins/")) { - return 'Package location must start with "plugins/".'; + if (!location.startsWith(`${EXTENSIONS_ROOT_FOLDER}/`)) { + return `Package location must start with "${EXTENSIONS_ROOT_FOLDER}/".`; } const locationPath = path.resolve(location); @@ -105,10 +107,10 @@ export default (): CliCommandScaffoldTemplate => ({ ]; }, generate: async ({ input, ora }) => { - const { pluginType, pluginName, packageName, location } = input; + const { pluginType, extensionName, packageName, location } = input; try { - ora.start(`Creating ${pluginName} plugin...`); + ora.start(`Creating ${extensionName} plugin...`); const sourcePath = path.join(__dirname, "templates", pluginType); @@ -151,7 +153,7 @@ export default (): CliCommandScaffoldTemplate => ({ // Once everything is done, run `yarn` so the new packages are automatically installed. await execa("yarn"); - ora.succeed(`New plugin created in ${location}.`); + ora.succeed(`New plugin created in ${log.success.hl(location)}.`); } catch (err) { ora.fail("Could not create plugin. Please check the logs below."); console.log(); diff --git a/packages/cli-plugin-scaffold-plugins/src/types.ts b/packages/cli-plugin-scaffold-extensions/src/types.ts similarity index 84% rename from packages/cli-plugin-scaffold-plugins/src/types.ts rename to packages/cli-plugin-scaffold-extensions/src/types.ts index 5f9fe871b03..50f63fe4c7b 100644 --- a/packages/cli-plugin-scaffold-plugins/src/types.ts +++ b/packages/cli-plugin-scaffold-extensions/src/types.ts @@ -1,6 +1,6 @@ interface PluginGeneratorParams { input: { - pluginName: string; + extensionName: string; packageName: string; }; } diff --git a/packages/cli-plugin-scaffold-plugins/templates/admin/package.json b/packages/cli-plugin-scaffold-extensions/templates/admin/package.json similarity index 100% rename from packages/cli-plugin-scaffold-plugins/templates/admin/package.json rename to packages/cli-plugin-scaffold-extensions/templates/admin/package.json diff --git a/packages/cli-plugin-scaffold-plugins/templates/admin/src/index.tsx b/packages/cli-plugin-scaffold-extensions/templates/admin/src/index.tsx similarity index 100% rename from packages/cli-plugin-scaffold-plugins/templates/admin/src/index.tsx rename to packages/cli-plugin-scaffold-extensions/templates/admin/src/index.tsx diff --git a/packages/cli-plugin-scaffold-plugins/templates/admin/tsconfig.json b/packages/cli-plugin-scaffold-extensions/templates/admin/tsconfig.json similarity index 100% rename from packages/cli-plugin-scaffold-plugins/templates/admin/tsconfig.json rename to packages/cli-plugin-scaffold-extensions/templates/admin/tsconfig.json diff --git a/packages/cli-plugin-scaffold-plugins/templates/api/package.json b/packages/cli-plugin-scaffold-extensions/templates/api/package.json similarity index 100% rename from packages/cli-plugin-scaffold-plugins/templates/api/package.json rename to packages/cli-plugin-scaffold-extensions/templates/api/package.json diff --git a/packages/cli-plugin-scaffold-plugins/templates/api/src/index.ts b/packages/cli-plugin-scaffold-extensions/templates/api/src/index.ts similarity index 100% rename from packages/cli-plugin-scaffold-plugins/templates/api/src/index.ts rename to packages/cli-plugin-scaffold-extensions/templates/api/src/index.ts diff --git a/packages/cli-plugin-scaffold-plugins/templates/api/tsconfig.json b/packages/cli-plugin-scaffold-extensions/templates/api/tsconfig.json similarity index 100% rename from packages/cli-plugin-scaffold-plugins/templates/api/tsconfig.json rename to packages/cli-plugin-scaffold-extensions/templates/api/tsconfig.json diff --git a/packages/cli-plugin-scaffold-plugins/tsconfig.build.json b/packages/cli-plugin-scaffold-extensions/tsconfig.build.json similarity index 100% rename from packages/cli-plugin-scaffold-plugins/tsconfig.build.json rename to packages/cli-plugin-scaffold-extensions/tsconfig.build.json diff --git a/packages/cli-plugin-scaffold-plugins/tsconfig.json b/packages/cli-plugin-scaffold-extensions/tsconfig.json similarity index 100% rename from packages/cli-plugin-scaffold-plugins/tsconfig.json rename to packages/cli-plugin-scaffold-extensions/tsconfig.json diff --git a/packages/cli-plugin-scaffold-plugins/webiny.config.js b/packages/cli-plugin-scaffold-extensions/webiny.config.js similarity index 100% rename from packages/cli-plugin-scaffold-plugins/webiny.config.js rename to packages/cli-plugin-scaffold-extensions/webiny.config.js diff --git a/packages/cli-plugin-scaffold-plugins/README.md b/packages/cli-plugin-scaffold-plugins/README.md deleted file mode 100644 index a9ea297c2bd..00000000000 --- a/packages/cli-plugin-scaffold-plugins/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# @webiny/cli-plugin-scaffold-plugins -[![](https://img.shields.io/npm/dw/@webiny/cli-plugin-scaffold-plugins.svg)](https://www.npmjs.com/package/@webiny/cli-plugin-scaffold-plugins) -[![](https://img.shields.io/npm/v/@webiny/cli-plugin-scaffold-plugins.svg)](https://www.npmjs.com/package/@webiny/cli-plugin-scaffold-plugins) -[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier) -[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com) - -## Install -``` -npm install --save @webiny/cli-plugin-scaffold-plugins -``` - -Or if you prefer yarn: -``` -yarn add @webiny/cli-plugin-scaffold-plugins -``` diff --git a/packages/cli-plugin-scaffold-plugins/src/generators/utils/addPluginToReactApp.tsx b/packages/cli-plugin-scaffold-plugins/src/generators/utils/addPluginToReactApp.tsx deleted file mode 100644 index 0f1b5957011..00000000000 --- a/packages/cli-plugin-scaffold-plugins/src/generators/utils/addPluginToReactApp.tsx +++ /dev/null @@ -1,82 +0,0 @@ -import { Project, Node, JsxFragment } from "ts-morph"; -import path from "path"; -import { formatCode } from "@webiny/cli-plugin-scaffold/utils"; - -interface Params { - pluginName: string; - packageName: string; -} - -export const addPluginToReactApp = async (params: Params): Promise => { - const { pluginName, packageName } = params; - - const scaffoldsFilePath = path.join("apps", "admin", "src", "Extensions.tsx"); - - const pluginsFactory = pluginName + "PluginsFactory"; - const importName = "{ createPlugins as " + pluginsFactory + " }"; - const importPath = packageName; - - const project = new Project(); - project.addSourceFileAtPath(scaffoldsFilePath); - - const source = project.getSourceFileOrThrow(scaffoldsFilePath); - - const existingImportDeclaration = source.getImportDeclaration(importPath); - if (existingImportDeclaration) { - throw new Error( - `Could not import "${importPath}" in "${scaffoldsFilePath}" as it already exists.` - ); - } - - let index = 1; - - const importDeclarations = source.getImportDeclarations(); - if (importDeclarations.length) { - const last = importDeclarations[importDeclarations.length - 1]; - index = last.getChildIndex() + 1; - } - - source.insertImportDeclaration(index, { - defaultImport: importName, - moduleSpecifier: importPath - }); - - const scaffoldsIdentifier = source.getFirstDescendant(node => { - if (!Node.isIdentifier(node)) { - return false; - } - - return node.getText() === "Scaffolds"; - }); - - if (!scaffoldsIdentifier) { - throw new Error( - `Could not find the "Scaffolds" React component in "${scaffoldsFilePath}". Did you maybe change the name of the component?` - ); - } - - const scaffoldsArrowFn = scaffoldsIdentifier.getNextSibling(node => Node.isArrowFunction(node)); - if (!scaffoldsArrowFn) { - throw new Error( - `Could not find the "Scaffolds" React component in "${scaffoldsFilePath}". Did you maybe change its definition? It should be an arrow function.` - ); - } - - const scaffoldsArrowFnFragment = scaffoldsArrowFn.getFirstDescendant(node => { - return Node.isJsxFragment(node); - }) as JsxFragment; - - const scaffoldsArrowFnFragmentChildrenText = scaffoldsArrowFnFragment - .getFullText() - .replace("<>", "") - .replace("", "") - .trim(); - - scaffoldsArrowFnFragment.replaceWithText( - `<>{${pluginName}PluginsFactory}${scaffoldsArrowFnFragmentChildrenText}` - ); - - await source.save(); - - await formatCode(scaffoldsFilePath, {}); -}; diff --git a/webiny.project.ts b/webiny.project.ts index 6b8e1b2ec21..74a64bd04c0 100644 --- a/webiny.project.ts +++ b/webiny.project.ts @@ -19,7 +19,7 @@ export default { import("@webiny/cli-plugin-scaffold"), import("@webiny/cli-plugin-scaffold-graphql-service"), import("@webiny/cli-plugin-scaffold-admin-app-module"), - import("@webiny/cli-plugin-scaffold-plugins"), + import("@webiny/cli-plugin-scaffold-extensions"), import("@webiny/cli-plugin-scaffold-ci") ]); From e8628017634beb6e253109110352a75f13d02947 Mon Sep 17 00:00:00 2001 From: adrians5j Date: Mon, 6 May 2024 13:34:15 +0200 Subject: [PATCH 21/32] wip: create essential plugins scaffold --- .../template/common/apps/admin/src/App.tsx | 4 +- .../common/apps/admin/src/Extensions.tsx | 6 +++ .../src/plugins/scaffolds/AdminPlugins.tsx | 5 -- .../template/common/webiny.project.ts | 4 +- .../ddb-es/apps/api/graphql/src/extensions.ts | 4 ++ .../ddb-es/apps/api/graphql/src/index.ts | 4 +- .../template/ddb-es/dependencies.json | 1 + .../ddb-os/apps/api/graphql/src/extensions.ts | 4 ++ .../ddb-os/apps/api/graphql/src/index.ts | 4 +- .../template/ddb-os/dependencies.json | 1 + .../ddb/apps/api/graphql/src/extensions.ts | 4 ++ .../ddb/apps/api/graphql/src/index.ts | 4 +- .../template/ddb/dependencies.json | 1 + yarn.lock | 52 ++++++++----------- 14 files changed, 57 insertions(+), 41 deletions(-) create mode 100644 packages/cwp-template-aws/template/common/apps/admin/src/Extensions.tsx delete mode 100644 packages/cwp-template-aws/template/common/apps/admin/src/plugins/scaffolds/AdminPlugins.tsx create mode 100644 packages/cwp-template-aws/template/ddb-es/apps/api/graphql/src/extensions.ts create mode 100644 packages/cwp-template-aws/template/ddb-os/apps/api/graphql/src/extensions.ts create mode 100644 packages/cwp-template-aws/template/ddb/apps/api/graphql/src/extensions.ts diff --git a/packages/cwp-template-aws/template/common/apps/admin/src/App.tsx b/packages/cwp-template-aws/template/common/apps/admin/src/App.tsx index b6c26b95cf0..6526bd7faa8 100644 --- a/packages/cwp-template-aws/template/common/apps/admin/src/App.tsx +++ b/packages/cwp-template-aws/template/common/apps/admin/src/App.tsx @@ -1,7 +1,7 @@ import React from "react"; import { Admin } from "@webiny/app-serverless-cms"; import { Cognito } from "@webiny/app-admin-users-cognito"; -import { AdminPlugins } from "./plugins/scaffolds/AdminPlugins"; +import { Extensions } from "./Extensions"; import "./App.scss"; @@ -9,7 +9,7 @@ export const App = () => { return ( - + ); }; diff --git a/packages/cwp-template-aws/template/common/apps/admin/src/Extensions.tsx b/packages/cwp-template-aws/template/common/apps/admin/src/Extensions.tsx new file mode 100644 index 00000000000..00cd662531a --- /dev/null +++ b/packages/cwp-template-aws/template/common/apps/admin/src/Extensions.tsx @@ -0,0 +1,6 @@ +// This file is automatically updated via scaffolding utilities. +import React from "react"; + +export const Extensions = () => { + return <>; +}; diff --git a/packages/cwp-template-aws/template/common/apps/admin/src/plugins/scaffolds/AdminPlugins.tsx b/packages/cwp-template-aws/template/common/apps/admin/src/plugins/scaffolds/AdminPlugins.tsx deleted file mode 100644 index 5425d573d9f..00000000000 --- a/packages/cwp-template-aws/template/common/apps/admin/src/plugins/scaffolds/AdminPlugins.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import React from "react"; - -export const AdminPlugins = () => { - return <>; -}; diff --git a/packages/cwp-template-aws/template/common/webiny.project.ts b/packages/cwp-template-aws/template/common/webiny.project.ts index a0e24befd5a..1fa753b35d9 100644 --- a/packages/cwp-template-aws/template/common/webiny.project.ts +++ b/packages/cwp-template-aws/template/common/webiny.project.ts @@ -6,7 +6,7 @@ import cliAwsTemplate from "@webiny/cwp-template-aws/cli"; import cliScaffold from "@webiny/cli-plugin-scaffold"; import cliScaffoldExtendGraphQlApi from "@webiny/cli-plugin-scaffold-graphql-service"; import cliScaffoldAdminModule from "@webiny/cli-plugin-scaffold-admin-app-module"; -import cliScaffoldPlugins from "@webiny/cli-plugin-scaffold-plugins"; +import cliScaffoldExtensions from "@webiny/cli-plugin-scaffold-extensions"; import cliScaffoldCiCd from "@webiny/cli-plugin-scaffold-ci"; @@ -23,7 +23,7 @@ export default { cliScaffold(), cliScaffoldExtendGraphQlApi(), cliScaffoldAdminModule(), - cliScaffoldPlugins, + cliScaffoldExtensions(), cliScaffoldCiCd() ] }, diff --git a/packages/cwp-template-aws/template/ddb-es/apps/api/graphql/src/extensions.ts b/packages/cwp-template-aws/template/ddb-es/apps/api/graphql/src/extensions.ts new file mode 100644 index 00000000000..658b605320b --- /dev/null +++ b/packages/cwp-template-aws/template/ddb-es/apps/api/graphql/src/extensions.ts @@ -0,0 +1,4 @@ +// This file is automatically updated via scaffolding utilities. +export const extensions = () => { + return []; +}; diff --git a/packages/cwp-template-aws/template/ddb-es/apps/api/graphql/src/index.ts b/packages/cwp-template-aws/template/ddb-es/apps/api/graphql/src/index.ts index 5015bf90806..80190917b8f 100644 --- a/packages/cwp-template-aws/template/ddb-es/apps/api/graphql/src/index.ts +++ b/packages/cwp-template-aws/template/ddb-es/apps/api/graphql/src/index.ts @@ -43,6 +43,7 @@ import { createLockingMechanism } from "@webiny/api-locking-mechanism"; // Imports plugins created via scaffolding utilities. import scaffoldsPlugins from "./plugins/scaffolds"; +import { extensions } from "./extensions"; const debug = process.env.DEBUG === "true"; @@ -118,7 +119,8 @@ export const handler = createHandler({ createAcoHcmsContext(), createHcmsTasks(), createAuditLogs(), - scaffoldsPlugins() + scaffoldsPlugins(), + extensions() ], debug }); diff --git a/packages/cwp-template-aws/template/ddb-es/dependencies.json b/packages/cwp-template-aws/template/ddb-es/dependencies.json index a3861d7d0ff..296ad80cad4 100644 --- a/packages/cwp-template-aws/template/ddb-es/dependencies.json +++ b/packages/cwp-template-aws/template/ddb-es/dependencies.json @@ -8,6 +8,7 @@ "@webiny/cli-plugin-scaffold-admin-app-module": "latest", "@webiny/cli-plugin-scaffold-graphql-service": "latest", "@webiny/cli-plugin-scaffold-ci": "latest", + "@webiny/cli-plugin-scaffold-extensions": "latest", "@webiny/cli-plugin-workspaces": "latest", "@webiny/cli-plugin-deploy-pulumi": "latest", "@webiny/project-utils": "latest", diff --git a/packages/cwp-template-aws/template/ddb-os/apps/api/graphql/src/extensions.ts b/packages/cwp-template-aws/template/ddb-os/apps/api/graphql/src/extensions.ts new file mode 100644 index 00000000000..658b605320b --- /dev/null +++ b/packages/cwp-template-aws/template/ddb-os/apps/api/graphql/src/extensions.ts @@ -0,0 +1,4 @@ +// This file is automatically updated via scaffolding utilities. +export const extensions = () => { + return []; +}; diff --git a/packages/cwp-template-aws/template/ddb-os/apps/api/graphql/src/index.ts b/packages/cwp-template-aws/template/ddb-os/apps/api/graphql/src/index.ts index 97fe678c147..e32794266fc 100644 --- a/packages/cwp-template-aws/template/ddb-os/apps/api/graphql/src/index.ts +++ b/packages/cwp-template-aws/template/ddb-os/apps/api/graphql/src/index.ts @@ -43,6 +43,7 @@ import { createLockingMechanism } from "@webiny/api-locking-mechanism"; // Imports plugins created via scaffolding utilities. import scaffoldsPlugins from "./plugins/scaffolds"; +import { extensions } from "./extensions"; const debug = process.env.DEBUG === "true"; @@ -118,7 +119,8 @@ export const handler = createHandler({ createAcoHcmsContext(), createHcmsTasks(), createAuditLogs(), - scaffoldsPlugins() + scaffoldsPlugins(), + extensions() ], debug }); diff --git a/packages/cwp-template-aws/template/ddb-os/dependencies.json b/packages/cwp-template-aws/template/ddb-os/dependencies.json index 3daf4810a96..fec4ea06f6f 100644 --- a/packages/cwp-template-aws/template/ddb-os/dependencies.json +++ b/packages/cwp-template-aws/template/ddb-os/dependencies.json @@ -8,6 +8,7 @@ "@webiny/cli-plugin-scaffold-admin-app-module": "latest", "@webiny/cli-plugin-scaffold-graphql-service": "latest", "@webiny/cli-plugin-scaffold-ci": "latest", + "@webiny/cli-plugin-scaffold-extensions": "latest", "@webiny/cli-plugin-workspaces": "latest", "@webiny/cli-plugin-deploy-pulumi": "latest", "@webiny/project-utils": "latest", diff --git a/packages/cwp-template-aws/template/ddb/apps/api/graphql/src/extensions.ts b/packages/cwp-template-aws/template/ddb/apps/api/graphql/src/extensions.ts new file mode 100644 index 00000000000..658b605320b --- /dev/null +++ b/packages/cwp-template-aws/template/ddb/apps/api/graphql/src/extensions.ts @@ -0,0 +1,4 @@ +// This file is automatically updated via scaffolding utilities. +export const extensions = () => { + return []; +}; diff --git a/packages/cwp-template-aws/template/ddb/apps/api/graphql/src/index.ts b/packages/cwp-template-aws/template/ddb/apps/api/graphql/src/index.ts index 842c962b53a..682bb2f00d1 100644 --- a/packages/cwp-template-aws/template/ddb/apps/api/graphql/src/index.ts +++ b/packages/cwp-template-aws/template/ddb/apps/api/graphql/src/index.ts @@ -39,6 +39,7 @@ import { createLockingMechanism } from "@webiny/api-locking-mechanism"; // Imports plugins created via scaffolding utilities. import scaffoldsPlugins from "./plugins/scaffolds"; +import { extensions } from "./extensions"; const debug = process.env.DEBUG === "true"; @@ -103,7 +104,8 @@ export const handler = createHandler({ createAuditLogs(), createAcoHcmsContext(), createHcmsTasks(), - scaffoldsPlugins() + scaffoldsPlugins(), + extensions() ], debug }); diff --git a/packages/cwp-template-aws/template/ddb/dependencies.json b/packages/cwp-template-aws/template/ddb/dependencies.json index 9bd87a2db1a..74ae8d5733f 100644 --- a/packages/cwp-template-aws/template/ddb/dependencies.json +++ b/packages/cwp-template-aws/template/ddb/dependencies.json @@ -8,6 +8,7 @@ "@webiny/cli-plugin-scaffold-admin-app-module": "latest", "@webiny/cli-plugin-scaffold-graphql-service": "latest", "@webiny/cli-plugin-scaffold-ci": "latest", + "@webiny/cli-plugin-scaffold-extensions": "latest", "@webiny/cli-plugin-workspaces": "latest", "@webiny/cli-plugin-deploy-pulumi": "latest", "@webiny/project-utils": "latest", diff --git a/yarn.lock b/yarn.lock index 3adbb4847cc..aead5cb7489 100644 --- a/yarn.lock +++ b/yarn.lock @@ -16117,9 +16117,9 @@ __metadata: languageName: unknown linkType: soft -"@webiny/cli-plugin-scaffold-full-stack-app@workspace:packages/cli-plugin-scaffold-full-stack-app": +"@webiny/cli-plugin-scaffold-extensions@workspace:packages/cli-plugin-scaffold-extensions": version: 0.0.0-use.local - resolution: "@webiny/cli-plugin-scaffold-full-stack-app@workspace:packages/cli-plugin-scaffold-full-stack-app" + resolution: "@webiny/cli-plugin-scaffold-extensions@workspace:packages/cli-plugin-scaffold-extensions" dependencies: "@babel/cli": ^7.23.9 "@babel/core": ^7.24.0 @@ -16127,24 +16127,27 @@ __metadata: "@types/inquirer": ^7.3.1 "@types/ncp": ^2.0.4 "@types/pluralize": ^0.0.29 + "@types/validate-npm-package-name": ^3.0.3 "@webiny/cli": 0.0.0 "@webiny/cli-plugin-scaffold": 0.0.0 - "@webiny/cli-plugin-scaffold-graphql-api": 0.0.0 - "@webiny/plugins": 0.0.0 + "@webiny/error": 0.0.0 "@webiny/project-utils": 0.0.0 case: ^1.6.3 - chalk: ^4.1.0 + execa: ^5.0.0 + load-json-file: ^6.2.0 ncp: ^2.0.0 replace-in-path: ^1.1.0 rimraf: ^5.0.5 - terminal-link: ^2.1.1 + ts-morph: ^11.0.0 typescript: 4.7.4 + validate-npm-package-name: ^3.0.0 + write-json-file: ^4.3.0 languageName: unknown linkType: soft -"@webiny/cli-plugin-scaffold-graphql-api@0.0.0, @webiny/cli-plugin-scaffold-graphql-api@workspace:packages/cli-plugin-scaffold-graphql-api": +"@webiny/cli-plugin-scaffold-full-stack-app@workspace:packages/cli-plugin-scaffold-full-stack-app": version: 0.0.0-use.local - resolution: "@webiny/cli-plugin-scaffold-graphql-api@workspace:packages/cli-plugin-scaffold-graphql-api" + resolution: "@webiny/cli-plugin-scaffold-full-stack-app@workspace:packages/cli-plugin-scaffold-full-stack-app" dependencies: "@babel/cli": ^7.23.9 "@babel/core": ^7.24.0 @@ -16153,27 +16156,23 @@ __metadata: "@types/ncp": ^2.0.4 "@types/pluralize": ^0.0.29 "@webiny/cli": 0.0.0 - "@webiny/cli-plugin-deploy-pulumi": 0.0.0 "@webiny/cli-plugin-scaffold": 0.0.0 - "@webiny/error": 0.0.0 + "@webiny/cli-plugin-scaffold-graphql-api": 0.0.0 "@webiny/plugins": 0.0.0 "@webiny/project-utils": 0.0.0 case: ^1.6.3 chalk: ^4.1.0 - execa: ^5.0.0 - load-json-file: ^6.2.0 ncp: ^2.0.0 replace-in-path: ^1.1.0 rimraf: ^5.0.5 terminal-link: ^2.1.1 typescript: 4.7.4 - write-json-file: ^4.3.0 languageName: unknown linkType: soft -"@webiny/cli-plugin-scaffold-graphql-service@workspace:packages/cli-plugin-scaffold-graphql-service": +"@webiny/cli-plugin-scaffold-graphql-api@0.0.0, @webiny/cli-plugin-scaffold-graphql-api@workspace:packages/cli-plugin-scaffold-graphql-api": version: 0.0.0-use.local - resolution: "@webiny/cli-plugin-scaffold-graphql-service@workspace:packages/cli-plugin-scaffold-graphql-service" + resolution: "@webiny/cli-plugin-scaffold-graphql-api@workspace:packages/cli-plugin-scaffold-graphql-api" dependencies: "@babel/cli": ^7.23.9 "@babel/core": ^7.24.0 @@ -16182,28 +16181,27 @@ __metadata: "@types/ncp": ^2.0.4 "@types/pluralize": ^0.0.29 "@webiny/cli": 0.0.0 + "@webiny/cli-plugin-deploy-pulumi": 0.0.0 "@webiny/cli-plugin-scaffold": 0.0.0 + "@webiny/error": 0.0.0 "@webiny/plugins": 0.0.0 "@webiny/project-utils": 0.0.0 case: ^1.6.3 chalk: ^4.1.0 execa: ^5.0.0 - find-up: ^5.0.0 load-json-file: ^6.2.0 ncp: ^2.0.0 - pluralize: ^8.0.0 replace-in-path: ^1.1.0 rimraf: ^5.0.5 terminal-link: ^2.1.1 - ts-morph: ^11.0.0 typescript: 4.7.4 write-json-file: ^4.3.0 languageName: unknown linkType: soft -"@webiny/cli-plugin-scaffold-plugins@workspace:packages/cli-plugin-scaffold-plugins": +"@webiny/cli-plugin-scaffold-graphql-service@workspace:packages/cli-plugin-scaffold-graphql-service": version: 0.0.0-use.local - resolution: "@webiny/cli-plugin-scaffold-plugins@workspace:packages/cli-plugin-scaffold-plugins" + resolution: "@webiny/cli-plugin-scaffold-graphql-service@workspace:packages/cli-plugin-scaffold-graphql-service" dependencies: "@babel/cli": ^7.23.9 "@babel/core": ^7.24.0 @@ -16211,20 +16209,22 @@ __metadata: "@types/inquirer": ^7.3.1 "@types/ncp": ^2.0.4 "@types/pluralize": ^0.0.29 - "@types/validate-npm-package-name": ^3.0.3 "@webiny/cli": 0.0.0 "@webiny/cli-plugin-scaffold": 0.0.0 - "@webiny/error": 0.0.0 + "@webiny/plugins": 0.0.0 "@webiny/project-utils": 0.0.0 case: ^1.6.3 + chalk: ^4.1.0 execa: ^5.0.0 + find-up: ^5.0.0 load-json-file: ^6.2.0 ncp: ^2.0.0 + pluralize: ^8.0.0 replace-in-path: ^1.1.0 rimraf: ^5.0.5 + terminal-link: ^2.1.1 ts-morph: ^11.0.0 typescript: 4.7.4 - validate-npm-package-name: ^3.0.0 write-json-file: ^4.3.0 languageName: unknown linkType: soft @@ -30506,12 +30506,6 @@ __metadata: languageName: node linkType: hard -"my-custom-plugin@workspace:plugins/myCustomPlugin": - version: 0.0.0-use.local - resolution: "my-custom-plugin@workspace:plugins/myCustomPlugin" - languageName: unknown - linkType: soft - "nanoclone@npm:^0.2.1": version: 0.2.1 resolution: "nanoclone@npm:0.2.1" From a43eac9538b731470adb64d5f9b2d3c82ca610d4 Mon Sep 17 00:00:00 2001 From: adrians5j Date: Mon, 6 May 2024 14:01:10 +0200 Subject: [PATCH 22/32] wip: move theme into extensions --- .../template/common/{apps => extensions}/theme/global.scss | 0 .../template/common/{apps => extensions}/theme/index.ts | 0 .../theme/layouts/forms/DefaultFormLayout.tsx | 0 .../theme/layouts/forms/DefaultFormLayout/Cell.tsx | 0 .../theme/layouts/forms/DefaultFormLayout/Field.tsx | 0 .../theme/layouts/forms/DefaultFormLayout/ReCaptchaSection.tsx | 0 .../theme/layouts/forms/DefaultFormLayout/Row.tsx | 0 .../theme/layouts/forms/DefaultFormLayout/SuccessMessage.tsx | 0 .../layouts/forms/DefaultFormLayout/TermsOfServiceSection.tsx | 0 .../theme/layouts/forms/DefaultFormLayout/buttons/Button.tsx | 0 .../theme/layouts/forms/DefaultFormLayout/fields/Checkbox.tsx | 0 .../theme/layouts/forms/DefaultFormLayout/fields/DateTime.tsx | 0 .../theme/layouts/forms/DefaultFormLayout/fields/Hidden.tsx | 0 .../theme/layouts/forms/DefaultFormLayout/fields/Input.tsx | 0 .../theme/layouts/forms/DefaultFormLayout/fields/Radio.tsx | 0 .../theme/layouts/forms/DefaultFormLayout/fields/Select.tsx | 0 .../theme/layouts/forms/DefaultFormLayout/fields/Textarea.tsx | 0 .../forms/DefaultFormLayout/fields/components/Field.tsx | 0 .../DefaultFormLayout/fields/components/FieldErrorMessage.tsx | 0 .../DefaultFormLayout/fields/components/FieldHelperMessage.tsx | 0 .../forms/DefaultFormLayout/fields/components/FieldLabel.tsx | 0 .../common/{apps => extensions}/theme/layouts/pages/Static.tsx | 0 .../{apps => extensions}/theme/layouts/pages/Static/Footer.tsx | 0 .../{apps => extensions}/theme/layouts/pages/Static/Header.tsx | 0 .../theme/layouts/pages/Static/HeaderDesktop.tsx | 0 .../theme/layouts/pages/Static/HeaderMobile.tsx | 0 .../theme/layouts/pages/Static/Navigation.tsx | 0 .../layouts/pages/Static/assets/facebook-square-brands.svg | 0 .../theme/layouts/pages/Static/assets/instagram-brands.svg | 0 .../theme/layouts/pages/Static/assets/linkedin-brands.svg | 0 .../layouts/pages/Static/assets/twitter-square-brands.svg | 0 .../template/common/{apps => extensions}/theme/package.json | 0 .../template/common/{apps => extensions}/theme/theme.ts | 0 .../template/common/{apps => extensions}/theme/tsconfig.json | 0 packages/cwp-template-aws/template/ddb-es/dependencies.json | 3 +-- packages/cwp-template-aws/template/ddb-os/dependencies.json | 3 +-- packages/cwp-template-aws/template/ddb/dependencies.json | 3 +-- 37 files changed, 3 insertions(+), 6 deletions(-) rename packages/cwp-template-aws/template/common/{apps => extensions}/theme/global.scss (100%) rename packages/cwp-template-aws/template/common/{apps => extensions}/theme/index.ts (100%) rename packages/cwp-template-aws/template/common/{apps => extensions}/theme/layouts/forms/DefaultFormLayout.tsx (100%) rename packages/cwp-template-aws/template/common/{apps => extensions}/theme/layouts/forms/DefaultFormLayout/Cell.tsx (100%) rename packages/cwp-template-aws/template/common/{apps => extensions}/theme/layouts/forms/DefaultFormLayout/Field.tsx (100%) rename packages/cwp-template-aws/template/common/{apps => extensions}/theme/layouts/forms/DefaultFormLayout/ReCaptchaSection.tsx (100%) rename packages/cwp-template-aws/template/common/{apps => extensions}/theme/layouts/forms/DefaultFormLayout/Row.tsx (100%) rename packages/cwp-template-aws/template/common/{apps => extensions}/theme/layouts/forms/DefaultFormLayout/SuccessMessage.tsx (100%) rename packages/cwp-template-aws/template/common/{apps => extensions}/theme/layouts/forms/DefaultFormLayout/TermsOfServiceSection.tsx (100%) rename packages/cwp-template-aws/template/common/{apps => extensions}/theme/layouts/forms/DefaultFormLayout/buttons/Button.tsx (100%) rename packages/cwp-template-aws/template/common/{apps => extensions}/theme/layouts/forms/DefaultFormLayout/fields/Checkbox.tsx (100%) rename packages/cwp-template-aws/template/common/{apps => extensions}/theme/layouts/forms/DefaultFormLayout/fields/DateTime.tsx (100%) rename packages/cwp-template-aws/template/common/{apps => extensions}/theme/layouts/forms/DefaultFormLayout/fields/Hidden.tsx (100%) rename packages/cwp-template-aws/template/common/{apps => extensions}/theme/layouts/forms/DefaultFormLayout/fields/Input.tsx (100%) rename packages/cwp-template-aws/template/common/{apps => extensions}/theme/layouts/forms/DefaultFormLayout/fields/Radio.tsx (100%) rename packages/cwp-template-aws/template/common/{apps => extensions}/theme/layouts/forms/DefaultFormLayout/fields/Select.tsx (100%) rename packages/cwp-template-aws/template/common/{apps => extensions}/theme/layouts/forms/DefaultFormLayout/fields/Textarea.tsx (100%) rename packages/cwp-template-aws/template/common/{apps => extensions}/theme/layouts/forms/DefaultFormLayout/fields/components/Field.tsx (100%) rename packages/cwp-template-aws/template/common/{apps => extensions}/theme/layouts/forms/DefaultFormLayout/fields/components/FieldErrorMessage.tsx (100%) rename packages/cwp-template-aws/template/common/{apps => extensions}/theme/layouts/forms/DefaultFormLayout/fields/components/FieldHelperMessage.tsx (100%) rename packages/cwp-template-aws/template/common/{apps => extensions}/theme/layouts/forms/DefaultFormLayout/fields/components/FieldLabel.tsx (100%) rename packages/cwp-template-aws/template/common/{apps => extensions}/theme/layouts/pages/Static.tsx (100%) rename packages/cwp-template-aws/template/common/{apps => extensions}/theme/layouts/pages/Static/Footer.tsx (100%) rename packages/cwp-template-aws/template/common/{apps => extensions}/theme/layouts/pages/Static/Header.tsx (100%) rename packages/cwp-template-aws/template/common/{apps => extensions}/theme/layouts/pages/Static/HeaderDesktop.tsx (100%) rename packages/cwp-template-aws/template/common/{apps => extensions}/theme/layouts/pages/Static/HeaderMobile.tsx (100%) rename packages/cwp-template-aws/template/common/{apps => extensions}/theme/layouts/pages/Static/Navigation.tsx (100%) rename packages/cwp-template-aws/template/common/{apps => extensions}/theme/layouts/pages/Static/assets/facebook-square-brands.svg (100%) rename packages/cwp-template-aws/template/common/{apps => extensions}/theme/layouts/pages/Static/assets/instagram-brands.svg (100%) rename packages/cwp-template-aws/template/common/{apps => extensions}/theme/layouts/pages/Static/assets/linkedin-brands.svg (100%) rename packages/cwp-template-aws/template/common/{apps => extensions}/theme/layouts/pages/Static/assets/twitter-square-brands.svg (100%) rename packages/cwp-template-aws/template/common/{apps => extensions}/theme/package.json (100%) rename packages/cwp-template-aws/template/common/{apps => extensions}/theme/theme.ts (100%) rename packages/cwp-template-aws/template/common/{apps => extensions}/theme/tsconfig.json (100%) diff --git a/packages/cwp-template-aws/template/common/apps/theme/global.scss b/packages/cwp-template-aws/template/common/extensions/theme/global.scss similarity index 100% rename from packages/cwp-template-aws/template/common/apps/theme/global.scss rename to packages/cwp-template-aws/template/common/extensions/theme/global.scss diff --git a/packages/cwp-template-aws/template/common/apps/theme/index.ts b/packages/cwp-template-aws/template/common/extensions/theme/index.ts similarity index 100% rename from packages/cwp-template-aws/template/common/apps/theme/index.ts rename to packages/cwp-template-aws/template/common/extensions/theme/index.ts diff --git a/packages/cwp-template-aws/template/common/apps/theme/layouts/forms/DefaultFormLayout.tsx b/packages/cwp-template-aws/template/common/extensions/theme/layouts/forms/DefaultFormLayout.tsx similarity index 100% rename from packages/cwp-template-aws/template/common/apps/theme/layouts/forms/DefaultFormLayout.tsx rename to packages/cwp-template-aws/template/common/extensions/theme/layouts/forms/DefaultFormLayout.tsx diff --git a/packages/cwp-template-aws/template/common/apps/theme/layouts/forms/DefaultFormLayout/Cell.tsx b/packages/cwp-template-aws/template/common/extensions/theme/layouts/forms/DefaultFormLayout/Cell.tsx similarity index 100% rename from packages/cwp-template-aws/template/common/apps/theme/layouts/forms/DefaultFormLayout/Cell.tsx rename to packages/cwp-template-aws/template/common/extensions/theme/layouts/forms/DefaultFormLayout/Cell.tsx diff --git a/packages/cwp-template-aws/template/common/apps/theme/layouts/forms/DefaultFormLayout/Field.tsx b/packages/cwp-template-aws/template/common/extensions/theme/layouts/forms/DefaultFormLayout/Field.tsx similarity index 100% rename from packages/cwp-template-aws/template/common/apps/theme/layouts/forms/DefaultFormLayout/Field.tsx rename to packages/cwp-template-aws/template/common/extensions/theme/layouts/forms/DefaultFormLayout/Field.tsx diff --git a/packages/cwp-template-aws/template/common/apps/theme/layouts/forms/DefaultFormLayout/ReCaptchaSection.tsx b/packages/cwp-template-aws/template/common/extensions/theme/layouts/forms/DefaultFormLayout/ReCaptchaSection.tsx similarity index 100% rename from packages/cwp-template-aws/template/common/apps/theme/layouts/forms/DefaultFormLayout/ReCaptchaSection.tsx rename to packages/cwp-template-aws/template/common/extensions/theme/layouts/forms/DefaultFormLayout/ReCaptchaSection.tsx diff --git a/packages/cwp-template-aws/template/common/apps/theme/layouts/forms/DefaultFormLayout/Row.tsx b/packages/cwp-template-aws/template/common/extensions/theme/layouts/forms/DefaultFormLayout/Row.tsx similarity index 100% rename from packages/cwp-template-aws/template/common/apps/theme/layouts/forms/DefaultFormLayout/Row.tsx rename to packages/cwp-template-aws/template/common/extensions/theme/layouts/forms/DefaultFormLayout/Row.tsx diff --git a/packages/cwp-template-aws/template/common/apps/theme/layouts/forms/DefaultFormLayout/SuccessMessage.tsx b/packages/cwp-template-aws/template/common/extensions/theme/layouts/forms/DefaultFormLayout/SuccessMessage.tsx similarity index 100% rename from packages/cwp-template-aws/template/common/apps/theme/layouts/forms/DefaultFormLayout/SuccessMessage.tsx rename to packages/cwp-template-aws/template/common/extensions/theme/layouts/forms/DefaultFormLayout/SuccessMessage.tsx diff --git a/packages/cwp-template-aws/template/common/apps/theme/layouts/forms/DefaultFormLayout/TermsOfServiceSection.tsx b/packages/cwp-template-aws/template/common/extensions/theme/layouts/forms/DefaultFormLayout/TermsOfServiceSection.tsx similarity index 100% rename from packages/cwp-template-aws/template/common/apps/theme/layouts/forms/DefaultFormLayout/TermsOfServiceSection.tsx rename to packages/cwp-template-aws/template/common/extensions/theme/layouts/forms/DefaultFormLayout/TermsOfServiceSection.tsx diff --git a/packages/cwp-template-aws/template/common/apps/theme/layouts/forms/DefaultFormLayout/buttons/Button.tsx b/packages/cwp-template-aws/template/common/extensions/theme/layouts/forms/DefaultFormLayout/buttons/Button.tsx similarity index 100% rename from packages/cwp-template-aws/template/common/apps/theme/layouts/forms/DefaultFormLayout/buttons/Button.tsx rename to packages/cwp-template-aws/template/common/extensions/theme/layouts/forms/DefaultFormLayout/buttons/Button.tsx diff --git a/packages/cwp-template-aws/template/common/apps/theme/layouts/forms/DefaultFormLayout/fields/Checkbox.tsx b/packages/cwp-template-aws/template/common/extensions/theme/layouts/forms/DefaultFormLayout/fields/Checkbox.tsx similarity index 100% rename from packages/cwp-template-aws/template/common/apps/theme/layouts/forms/DefaultFormLayout/fields/Checkbox.tsx rename to packages/cwp-template-aws/template/common/extensions/theme/layouts/forms/DefaultFormLayout/fields/Checkbox.tsx diff --git a/packages/cwp-template-aws/template/common/apps/theme/layouts/forms/DefaultFormLayout/fields/DateTime.tsx b/packages/cwp-template-aws/template/common/extensions/theme/layouts/forms/DefaultFormLayout/fields/DateTime.tsx similarity index 100% rename from packages/cwp-template-aws/template/common/apps/theme/layouts/forms/DefaultFormLayout/fields/DateTime.tsx rename to packages/cwp-template-aws/template/common/extensions/theme/layouts/forms/DefaultFormLayout/fields/DateTime.tsx diff --git a/packages/cwp-template-aws/template/common/apps/theme/layouts/forms/DefaultFormLayout/fields/Hidden.tsx b/packages/cwp-template-aws/template/common/extensions/theme/layouts/forms/DefaultFormLayout/fields/Hidden.tsx similarity index 100% rename from packages/cwp-template-aws/template/common/apps/theme/layouts/forms/DefaultFormLayout/fields/Hidden.tsx rename to packages/cwp-template-aws/template/common/extensions/theme/layouts/forms/DefaultFormLayout/fields/Hidden.tsx diff --git a/packages/cwp-template-aws/template/common/apps/theme/layouts/forms/DefaultFormLayout/fields/Input.tsx b/packages/cwp-template-aws/template/common/extensions/theme/layouts/forms/DefaultFormLayout/fields/Input.tsx similarity index 100% rename from packages/cwp-template-aws/template/common/apps/theme/layouts/forms/DefaultFormLayout/fields/Input.tsx rename to packages/cwp-template-aws/template/common/extensions/theme/layouts/forms/DefaultFormLayout/fields/Input.tsx diff --git a/packages/cwp-template-aws/template/common/apps/theme/layouts/forms/DefaultFormLayout/fields/Radio.tsx b/packages/cwp-template-aws/template/common/extensions/theme/layouts/forms/DefaultFormLayout/fields/Radio.tsx similarity index 100% rename from packages/cwp-template-aws/template/common/apps/theme/layouts/forms/DefaultFormLayout/fields/Radio.tsx rename to packages/cwp-template-aws/template/common/extensions/theme/layouts/forms/DefaultFormLayout/fields/Radio.tsx diff --git a/packages/cwp-template-aws/template/common/apps/theme/layouts/forms/DefaultFormLayout/fields/Select.tsx b/packages/cwp-template-aws/template/common/extensions/theme/layouts/forms/DefaultFormLayout/fields/Select.tsx similarity index 100% rename from packages/cwp-template-aws/template/common/apps/theme/layouts/forms/DefaultFormLayout/fields/Select.tsx rename to packages/cwp-template-aws/template/common/extensions/theme/layouts/forms/DefaultFormLayout/fields/Select.tsx diff --git a/packages/cwp-template-aws/template/common/apps/theme/layouts/forms/DefaultFormLayout/fields/Textarea.tsx b/packages/cwp-template-aws/template/common/extensions/theme/layouts/forms/DefaultFormLayout/fields/Textarea.tsx similarity index 100% rename from packages/cwp-template-aws/template/common/apps/theme/layouts/forms/DefaultFormLayout/fields/Textarea.tsx rename to packages/cwp-template-aws/template/common/extensions/theme/layouts/forms/DefaultFormLayout/fields/Textarea.tsx diff --git a/packages/cwp-template-aws/template/common/apps/theme/layouts/forms/DefaultFormLayout/fields/components/Field.tsx b/packages/cwp-template-aws/template/common/extensions/theme/layouts/forms/DefaultFormLayout/fields/components/Field.tsx similarity index 100% rename from packages/cwp-template-aws/template/common/apps/theme/layouts/forms/DefaultFormLayout/fields/components/Field.tsx rename to packages/cwp-template-aws/template/common/extensions/theme/layouts/forms/DefaultFormLayout/fields/components/Field.tsx diff --git a/packages/cwp-template-aws/template/common/apps/theme/layouts/forms/DefaultFormLayout/fields/components/FieldErrorMessage.tsx b/packages/cwp-template-aws/template/common/extensions/theme/layouts/forms/DefaultFormLayout/fields/components/FieldErrorMessage.tsx similarity index 100% rename from packages/cwp-template-aws/template/common/apps/theme/layouts/forms/DefaultFormLayout/fields/components/FieldErrorMessage.tsx rename to packages/cwp-template-aws/template/common/extensions/theme/layouts/forms/DefaultFormLayout/fields/components/FieldErrorMessage.tsx diff --git a/packages/cwp-template-aws/template/common/apps/theme/layouts/forms/DefaultFormLayout/fields/components/FieldHelperMessage.tsx b/packages/cwp-template-aws/template/common/extensions/theme/layouts/forms/DefaultFormLayout/fields/components/FieldHelperMessage.tsx similarity index 100% rename from packages/cwp-template-aws/template/common/apps/theme/layouts/forms/DefaultFormLayout/fields/components/FieldHelperMessage.tsx rename to packages/cwp-template-aws/template/common/extensions/theme/layouts/forms/DefaultFormLayout/fields/components/FieldHelperMessage.tsx diff --git a/packages/cwp-template-aws/template/common/apps/theme/layouts/forms/DefaultFormLayout/fields/components/FieldLabel.tsx b/packages/cwp-template-aws/template/common/extensions/theme/layouts/forms/DefaultFormLayout/fields/components/FieldLabel.tsx similarity index 100% rename from packages/cwp-template-aws/template/common/apps/theme/layouts/forms/DefaultFormLayout/fields/components/FieldLabel.tsx rename to packages/cwp-template-aws/template/common/extensions/theme/layouts/forms/DefaultFormLayout/fields/components/FieldLabel.tsx diff --git a/packages/cwp-template-aws/template/common/apps/theme/layouts/pages/Static.tsx b/packages/cwp-template-aws/template/common/extensions/theme/layouts/pages/Static.tsx similarity index 100% rename from packages/cwp-template-aws/template/common/apps/theme/layouts/pages/Static.tsx rename to packages/cwp-template-aws/template/common/extensions/theme/layouts/pages/Static.tsx diff --git a/packages/cwp-template-aws/template/common/apps/theme/layouts/pages/Static/Footer.tsx b/packages/cwp-template-aws/template/common/extensions/theme/layouts/pages/Static/Footer.tsx similarity index 100% rename from packages/cwp-template-aws/template/common/apps/theme/layouts/pages/Static/Footer.tsx rename to packages/cwp-template-aws/template/common/extensions/theme/layouts/pages/Static/Footer.tsx diff --git a/packages/cwp-template-aws/template/common/apps/theme/layouts/pages/Static/Header.tsx b/packages/cwp-template-aws/template/common/extensions/theme/layouts/pages/Static/Header.tsx similarity index 100% rename from packages/cwp-template-aws/template/common/apps/theme/layouts/pages/Static/Header.tsx rename to packages/cwp-template-aws/template/common/extensions/theme/layouts/pages/Static/Header.tsx diff --git a/packages/cwp-template-aws/template/common/apps/theme/layouts/pages/Static/HeaderDesktop.tsx b/packages/cwp-template-aws/template/common/extensions/theme/layouts/pages/Static/HeaderDesktop.tsx similarity index 100% rename from packages/cwp-template-aws/template/common/apps/theme/layouts/pages/Static/HeaderDesktop.tsx rename to packages/cwp-template-aws/template/common/extensions/theme/layouts/pages/Static/HeaderDesktop.tsx diff --git a/packages/cwp-template-aws/template/common/apps/theme/layouts/pages/Static/HeaderMobile.tsx b/packages/cwp-template-aws/template/common/extensions/theme/layouts/pages/Static/HeaderMobile.tsx similarity index 100% rename from packages/cwp-template-aws/template/common/apps/theme/layouts/pages/Static/HeaderMobile.tsx rename to packages/cwp-template-aws/template/common/extensions/theme/layouts/pages/Static/HeaderMobile.tsx diff --git a/packages/cwp-template-aws/template/common/apps/theme/layouts/pages/Static/Navigation.tsx b/packages/cwp-template-aws/template/common/extensions/theme/layouts/pages/Static/Navigation.tsx similarity index 100% rename from packages/cwp-template-aws/template/common/apps/theme/layouts/pages/Static/Navigation.tsx rename to packages/cwp-template-aws/template/common/extensions/theme/layouts/pages/Static/Navigation.tsx diff --git a/packages/cwp-template-aws/template/common/apps/theme/layouts/pages/Static/assets/facebook-square-brands.svg b/packages/cwp-template-aws/template/common/extensions/theme/layouts/pages/Static/assets/facebook-square-brands.svg similarity index 100% rename from packages/cwp-template-aws/template/common/apps/theme/layouts/pages/Static/assets/facebook-square-brands.svg rename to packages/cwp-template-aws/template/common/extensions/theme/layouts/pages/Static/assets/facebook-square-brands.svg diff --git a/packages/cwp-template-aws/template/common/apps/theme/layouts/pages/Static/assets/instagram-brands.svg b/packages/cwp-template-aws/template/common/extensions/theme/layouts/pages/Static/assets/instagram-brands.svg similarity index 100% rename from packages/cwp-template-aws/template/common/apps/theme/layouts/pages/Static/assets/instagram-brands.svg rename to packages/cwp-template-aws/template/common/extensions/theme/layouts/pages/Static/assets/instagram-brands.svg diff --git a/packages/cwp-template-aws/template/common/apps/theme/layouts/pages/Static/assets/linkedin-brands.svg b/packages/cwp-template-aws/template/common/extensions/theme/layouts/pages/Static/assets/linkedin-brands.svg similarity index 100% rename from packages/cwp-template-aws/template/common/apps/theme/layouts/pages/Static/assets/linkedin-brands.svg rename to packages/cwp-template-aws/template/common/extensions/theme/layouts/pages/Static/assets/linkedin-brands.svg diff --git a/packages/cwp-template-aws/template/common/apps/theme/layouts/pages/Static/assets/twitter-square-brands.svg b/packages/cwp-template-aws/template/common/extensions/theme/layouts/pages/Static/assets/twitter-square-brands.svg similarity index 100% rename from packages/cwp-template-aws/template/common/apps/theme/layouts/pages/Static/assets/twitter-square-brands.svg rename to packages/cwp-template-aws/template/common/extensions/theme/layouts/pages/Static/assets/twitter-square-brands.svg diff --git a/packages/cwp-template-aws/template/common/apps/theme/package.json b/packages/cwp-template-aws/template/common/extensions/theme/package.json similarity index 100% rename from packages/cwp-template-aws/template/common/apps/theme/package.json rename to packages/cwp-template-aws/template/common/extensions/theme/package.json diff --git a/packages/cwp-template-aws/template/common/apps/theme/theme.ts b/packages/cwp-template-aws/template/common/extensions/theme/theme.ts similarity index 100% rename from packages/cwp-template-aws/template/common/apps/theme/theme.ts rename to packages/cwp-template-aws/template/common/extensions/theme/theme.ts diff --git a/packages/cwp-template-aws/template/common/apps/theme/tsconfig.json b/packages/cwp-template-aws/template/common/extensions/theme/tsconfig.json similarity index 100% rename from packages/cwp-template-aws/template/common/apps/theme/tsconfig.json rename to packages/cwp-template-aws/template/common/extensions/theme/tsconfig.json diff --git a/packages/cwp-template-aws/template/ddb-es/dependencies.json b/packages/cwp-template-aws/template/ddb-es/dependencies.json index 296ad80cad4..1a764796bdc 100644 --- a/packages/cwp-template-aws/template/ddb-es/dependencies.json +++ b/packages/cwp-template-aws/template/ddb-es/dependencies.json @@ -53,9 +53,8 @@ "packages": [ "apps/admin", "apps/website", - "apps/theme", "apps/api/graphql", - "apps/api/headlessCMS", + "extensions/theme", "packages/*" ] }, diff --git a/packages/cwp-template-aws/template/ddb-os/dependencies.json b/packages/cwp-template-aws/template/ddb-os/dependencies.json index fec4ea06f6f..f048d02b241 100644 --- a/packages/cwp-template-aws/template/ddb-os/dependencies.json +++ b/packages/cwp-template-aws/template/ddb-os/dependencies.json @@ -54,9 +54,8 @@ "packages": [ "apps/admin", "apps/website", - "apps/theme", "apps/api/graphql", - "apps/api/headlessCMS", + "extensions/theme", "packages/*" ] }, diff --git a/packages/cwp-template-aws/template/ddb/dependencies.json b/packages/cwp-template-aws/template/ddb/dependencies.json index 74ae8d5733f..18b4457c226 100644 --- a/packages/cwp-template-aws/template/ddb/dependencies.json +++ b/packages/cwp-template-aws/template/ddb/dependencies.json @@ -53,9 +53,8 @@ "packages": [ "apps/admin", "apps/website", - "apps/theme", "apps/api/graphql", - "apps/api/headlessCMS", + "extensions/theme", "packages/*" ] }, From 3ca1c709a3545d51b69536c22a056543f6083f22 Mon Sep 17 00:00:00 2001 From: adrians5j Date: Mon, 6 May 2024 14:01:52 +0200 Subject: [PATCH 23/32] wip: move theme into extensions --- {apps => extensions}/theme/global.scss | 0 {apps => extensions}/theme/index.ts | 0 .../theme/layouts/forms/DefaultFormLayout.tsx | 0 .../theme/layouts/forms/DefaultFormLayout/Cell.tsx | 0 .../theme/layouts/forms/DefaultFormLayout/Field.tsx | 0 .../layouts/forms/DefaultFormLayout/ReCaptchaSection.tsx | 0 .../theme/layouts/forms/DefaultFormLayout/Row.tsx | 0 .../theme/layouts/forms/DefaultFormLayout/SuccessMessage.tsx | 0 .../layouts/forms/DefaultFormLayout/TermsOfServiceSection.tsx | 0 .../theme/layouts/forms/DefaultFormLayout/buttons/Button.tsx | 0 .../theme/layouts/forms/DefaultFormLayout/fields/Checkbox.tsx | 0 .../theme/layouts/forms/DefaultFormLayout/fields/DateTime.tsx | 0 .../theme/layouts/forms/DefaultFormLayout/fields/Hidden.tsx | 0 .../theme/layouts/forms/DefaultFormLayout/fields/Input.tsx | 0 .../theme/layouts/forms/DefaultFormLayout/fields/Radio.tsx | 0 .../theme/layouts/forms/DefaultFormLayout/fields/Select.tsx | 0 .../theme/layouts/forms/DefaultFormLayout/fields/Textarea.tsx | 0 .../forms/DefaultFormLayout/fields/components/Field.tsx | 0 .../DefaultFormLayout/fields/components/FieldErrorMessage.tsx | 0 .../fields/components/FieldHelperMessage.tsx | 0 .../forms/DefaultFormLayout/fields/components/FieldLabel.tsx | 0 {apps => extensions}/theme/layouts/pages/Static.tsx | 0 {apps => extensions}/theme/layouts/pages/Static/Footer.tsx | 0 {apps => extensions}/theme/layouts/pages/Static/Header.tsx | 0 .../theme/layouts/pages/Static/HeaderDesktop.tsx | 0 .../theme/layouts/pages/Static/HeaderMobile.tsx | 0 .../theme/layouts/pages/Static/Navigation.tsx | 0 .../layouts/pages/Static/assets/facebook-square-brands.svg | 0 .../theme/layouts/pages/Static/assets/instagram-brands.svg | 0 .../theme/layouts/pages/Static/assets/linkedin-brands.svg | 0 .../layouts/pages/Static/assets/twitter-square-brands.svg | 0 {apps => extensions}/theme/package.json | 0 {apps => extensions}/theme/theme.ts | 0 {apps => extensions}/theme/tsconfig.json | 0 package.json | 3 +-- yarn.lock | 4 ++-- 36 files changed, 3 insertions(+), 4 deletions(-) rename {apps => extensions}/theme/global.scss (100%) rename {apps => extensions}/theme/index.ts (100%) rename {apps => extensions}/theme/layouts/forms/DefaultFormLayout.tsx (100%) rename {apps => extensions}/theme/layouts/forms/DefaultFormLayout/Cell.tsx (100%) rename {apps => extensions}/theme/layouts/forms/DefaultFormLayout/Field.tsx (100%) rename {apps => extensions}/theme/layouts/forms/DefaultFormLayout/ReCaptchaSection.tsx (100%) rename {apps => extensions}/theme/layouts/forms/DefaultFormLayout/Row.tsx (100%) rename {apps => extensions}/theme/layouts/forms/DefaultFormLayout/SuccessMessage.tsx (100%) rename {apps => extensions}/theme/layouts/forms/DefaultFormLayout/TermsOfServiceSection.tsx (100%) rename {apps => extensions}/theme/layouts/forms/DefaultFormLayout/buttons/Button.tsx (100%) rename {apps => extensions}/theme/layouts/forms/DefaultFormLayout/fields/Checkbox.tsx (100%) rename {apps => extensions}/theme/layouts/forms/DefaultFormLayout/fields/DateTime.tsx (100%) rename {apps => extensions}/theme/layouts/forms/DefaultFormLayout/fields/Hidden.tsx (100%) rename {apps => extensions}/theme/layouts/forms/DefaultFormLayout/fields/Input.tsx (100%) rename {apps => extensions}/theme/layouts/forms/DefaultFormLayout/fields/Radio.tsx (100%) rename {apps => extensions}/theme/layouts/forms/DefaultFormLayout/fields/Select.tsx (100%) rename {apps => extensions}/theme/layouts/forms/DefaultFormLayout/fields/Textarea.tsx (100%) rename {apps => extensions}/theme/layouts/forms/DefaultFormLayout/fields/components/Field.tsx (100%) rename {apps => extensions}/theme/layouts/forms/DefaultFormLayout/fields/components/FieldErrorMessage.tsx (100%) rename {apps => extensions}/theme/layouts/forms/DefaultFormLayout/fields/components/FieldHelperMessage.tsx (100%) rename {apps => extensions}/theme/layouts/forms/DefaultFormLayout/fields/components/FieldLabel.tsx (100%) rename {apps => extensions}/theme/layouts/pages/Static.tsx (100%) rename {apps => extensions}/theme/layouts/pages/Static/Footer.tsx (100%) rename {apps => extensions}/theme/layouts/pages/Static/Header.tsx (100%) rename {apps => extensions}/theme/layouts/pages/Static/HeaderDesktop.tsx (100%) rename {apps => extensions}/theme/layouts/pages/Static/HeaderMobile.tsx (100%) rename {apps => extensions}/theme/layouts/pages/Static/Navigation.tsx (100%) rename {apps => extensions}/theme/layouts/pages/Static/assets/facebook-square-brands.svg (100%) rename {apps => extensions}/theme/layouts/pages/Static/assets/instagram-brands.svg (100%) rename {apps => extensions}/theme/layouts/pages/Static/assets/linkedin-brands.svg (100%) rename {apps => extensions}/theme/layouts/pages/Static/assets/twitter-square-brands.svg (100%) rename {apps => extensions}/theme/package.json (100%) rename {apps => extensions}/theme/theme.ts (100%) rename {apps => extensions}/theme/tsconfig.json (100%) diff --git a/apps/theme/global.scss b/extensions/theme/global.scss similarity index 100% rename from apps/theme/global.scss rename to extensions/theme/global.scss diff --git a/apps/theme/index.ts b/extensions/theme/index.ts similarity index 100% rename from apps/theme/index.ts rename to extensions/theme/index.ts diff --git a/apps/theme/layouts/forms/DefaultFormLayout.tsx b/extensions/theme/layouts/forms/DefaultFormLayout.tsx similarity index 100% rename from apps/theme/layouts/forms/DefaultFormLayout.tsx rename to extensions/theme/layouts/forms/DefaultFormLayout.tsx diff --git a/apps/theme/layouts/forms/DefaultFormLayout/Cell.tsx b/extensions/theme/layouts/forms/DefaultFormLayout/Cell.tsx similarity index 100% rename from apps/theme/layouts/forms/DefaultFormLayout/Cell.tsx rename to extensions/theme/layouts/forms/DefaultFormLayout/Cell.tsx diff --git a/apps/theme/layouts/forms/DefaultFormLayout/Field.tsx b/extensions/theme/layouts/forms/DefaultFormLayout/Field.tsx similarity index 100% rename from apps/theme/layouts/forms/DefaultFormLayout/Field.tsx rename to extensions/theme/layouts/forms/DefaultFormLayout/Field.tsx diff --git a/apps/theme/layouts/forms/DefaultFormLayout/ReCaptchaSection.tsx b/extensions/theme/layouts/forms/DefaultFormLayout/ReCaptchaSection.tsx similarity index 100% rename from apps/theme/layouts/forms/DefaultFormLayout/ReCaptchaSection.tsx rename to extensions/theme/layouts/forms/DefaultFormLayout/ReCaptchaSection.tsx diff --git a/apps/theme/layouts/forms/DefaultFormLayout/Row.tsx b/extensions/theme/layouts/forms/DefaultFormLayout/Row.tsx similarity index 100% rename from apps/theme/layouts/forms/DefaultFormLayout/Row.tsx rename to extensions/theme/layouts/forms/DefaultFormLayout/Row.tsx diff --git a/apps/theme/layouts/forms/DefaultFormLayout/SuccessMessage.tsx b/extensions/theme/layouts/forms/DefaultFormLayout/SuccessMessage.tsx similarity index 100% rename from apps/theme/layouts/forms/DefaultFormLayout/SuccessMessage.tsx rename to extensions/theme/layouts/forms/DefaultFormLayout/SuccessMessage.tsx diff --git a/apps/theme/layouts/forms/DefaultFormLayout/TermsOfServiceSection.tsx b/extensions/theme/layouts/forms/DefaultFormLayout/TermsOfServiceSection.tsx similarity index 100% rename from apps/theme/layouts/forms/DefaultFormLayout/TermsOfServiceSection.tsx rename to extensions/theme/layouts/forms/DefaultFormLayout/TermsOfServiceSection.tsx diff --git a/apps/theme/layouts/forms/DefaultFormLayout/buttons/Button.tsx b/extensions/theme/layouts/forms/DefaultFormLayout/buttons/Button.tsx similarity index 100% rename from apps/theme/layouts/forms/DefaultFormLayout/buttons/Button.tsx rename to extensions/theme/layouts/forms/DefaultFormLayout/buttons/Button.tsx diff --git a/apps/theme/layouts/forms/DefaultFormLayout/fields/Checkbox.tsx b/extensions/theme/layouts/forms/DefaultFormLayout/fields/Checkbox.tsx similarity index 100% rename from apps/theme/layouts/forms/DefaultFormLayout/fields/Checkbox.tsx rename to extensions/theme/layouts/forms/DefaultFormLayout/fields/Checkbox.tsx diff --git a/apps/theme/layouts/forms/DefaultFormLayout/fields/DateTime.tsx b/extensions/theme/layouts/forms/DefaultFormLayout/fields/DateTime.tsx similarity index 100% rename from apps/theme/layouts/forms/DefaultFormLayout/fields/DateTime.tsx rename to extensions/theme/layouts/forms/DefaultFormLayout/fields/DateTime.tsx diff --git a/apps/theme/layouts/forms/DefaultFormLayout/fields/Hidden.tsx b/extensions/theme/layouts/forms/DefaultFormLayout/fields/Hidden.tsx similarity index 100% rename from apps/theme/layouts/forms/DefaultFormLayout/fields/Hidden.tsx rename to extensions/theme/layouts/forms/DefaultFormLayout/fields/Hidden.tsx diff --git a/apps/theme/layouts/forms/DefaultFormLayout/fields/Input.tsx b/extensions/theme/layouts/forms/DefaultFormLayout/fields/Input.tsx similarity index 100% rename from apps/theme/layouts/forms/DefaultFormLayout/fields/Input.tsx rename to extensions/theme/layouts/forms/DefaultFormLayout/fields/Input.tsx diff --git a/apps/theme/layouts/forms/DefaultFormLayout/fields/Radio.tsx b/extensions/theme/layouts/forms/DefaultFormLayout/fields/Radio.tsx similarity index 100% rename from apps/theme/layouts/forms/DefaultFormLayout/fields/Radio.tsx rename to extensions/theme/layouts/forms/DefaultFormLayout/fields/Radio.tsx diff --git a/apps/theme/layouts/forms/DefaultFormLayout/fields/Select.tsx b/extensions/theme/layouts/forms/DefaultFormLayout/fields/Select.tsx similarity index 100% rename from apps/theme/layouts/forms/DefaultFormLayout/fields/Select.tsx rename to extensions/theme/layouts/forms/DefaultFormLayout/fields/Select.tsx diff --git a/apps/theme/layouts/forms/DefaultFormLayout/fields/Textarea.tsx b/extensions/theme/layouts/forms/DefaultFormLayout/fields/Textarea.tsx similarity index 100% rename from apps/theme/layouts/forms/DefaultFormLayout/fields/Textarea.tsx rename to extensions/theme/layouts/forms/DefaultFormLayout/fields/Textarea.tsx diff --git a/apps/theme/layouts/forms/DefaultFormLayout/fields/components/Field.tsx b/extensions/theme/layouts/forms/DefaultFormLayout/fields/components/Field.tsx similarity index 100% rename from apps/theme/layouts/forms/DefaultFormLayout/fields/components/Field.tsx rename to extensions/theme/layouts/forms/DefaultFormLayout/fields/components/Field.tsx diff --git a/apps/theme/layouts/forms/DefaultFormLayout/fields/components/FieldErrorMessage.tsx b/extensions/theme/layouts/forms/DefaultFormLayout/fields/components/FieldErrorMessage.tsx similarity index 100% rename from apps/theme/layouts/forms/DefaultFormLayout/fields/components/FieldErrorMessage.tsx rename to extensions/theme/layouts/forms/DefaultFormLayout/fields/components/FieldErrorMessage.tsx diff --git a/apps/theme/layouts/forms/DefaultFormLayout/fields/components/FieldHelperMessage.tsx b/extensions/theme/layouts/forms/DefaultFormLayout/fields/components/FieldHelperMessage.tsx similarity index 100% rename from apps/theme/layouts/forms/DefaultFormLayout/fields/components/FieldHelperMessage.tsx rename to extensions/theme/layouts/forms/DefaultFormLayout/fields/components/FieldHelperMessage.tsx diff --git a/apps/theme/layouts/forms/DefaultFormLayout/fields/components/FieldLabel.tsx b/extensions/theme/layouts/forms/DefaultFormLayout/fields/components/FieldLabel.tsx similarity index 100% rename from apps/theme/layouts/forms/DefaultFormLayout/fields/components/FieldLabel.tsx rename to extensions/theme/layouts/forms/DefaultFormLayout/fields/components/FieldLabel.tsx diff --git a/apps/theme/layouts/pages/Static.tsx b/extensions/theme/layouts/pages/Static.tsx similarity index 100% rename from apps/theme/layouts/pages/Static.tsx rename to extensions/theme/layouts/pages/Static.tsx diff --git a/apps/theme/layouts/pages/Static/Footer.tsx b/extensions/theme/layouts/pages/Static/Footer.tsx similarity index 100% rename from apps/theme/layouts/pages/Static/Footer.tsx rename to extensions/theme/layouts/pages/Static/Footer.tsx diff --git a/apps/theme/layouts/pages/Static/Header.tsx b/extensions/theme/layouts/pages/Static/Header.tsx similarity index 100% rename from apps/theme/layouts/pages/Static/Header.tsx rename to extensions/theme/layouts/pages/Static/Header.tsx diff --git a/apps/theme/layouts/pages/Static/HeaderDesktop.tsx b/extensions/theme/layouts/pages/Static/HeaderDesktop.tsx similarity index 100% rename from apps/theme/layouts/pages/Static/HeaderDesktop.tsx rename to extensions/theme/layouts/pages/Static/HeaderDesktop.tsx diff --git a/apps/theme/layouts/pages/Static/HeaderMobile.tsx b/extensions/theme/layouts/pages/Static/HeaderMobile.tsx similarity index 100% rename from apps/theme/layouts/pages/Static/HeaderMobile.tsx rename to extensions/theme/layouts/pages/Static/HeaderMobile.tsx diff --git a/apps/theme/layouts/pages/Static/Navigation.tsx b/extensions/theme/layouts/pages/Static/Navigation.tsx similarity index 100% rename from apps/theme/layouts/pages/Static/Navigation.tsx rename to extensions/theme/layouts/pages/Static/Navigation.tsx diff --git a/apps/theme/layouts/pages/Static/assets/facebook-square-brands.svg b/extensions/theme/layouts/pages/Static/assets/facebook-square-brands.svg similarity index 100% rename from apps/theme/layouts/pages/Static/assets/facebook-square-brands.svg rename to extensions/theme/layouts/pages/Static/assets/facebook-square-brands.svg diff --git a/apps/theme/layouts/pages/Static/assets/instagram-brands.svg b/extensions/theme/layouts/pages/Static/assets/instagram-brands.svg similarity index 100% rename from apps/theme/layouts/pages/Static/assets/instagram-brands.svg rename to extensions/theme/layouts/pages/Static/assets/instagram-brands.svg diff --git a/apps/theme/layouts/pages/Static/assets/linkedin-brands.svg b/extensions/theme/layouts/pages/Static/assets/linkedin-brands.svg similarity index 100% rename from apps/theme/layouts/pages/Static/assets/linkedin-brands.svg rename to extensions/theme/layouts/pages/Static/assets/linkedin-brands.svg diff --git a/apps/theme/layouts/pages/Static/assets/twitter-square-brands.svg b/extensions/theme/layouts/pages/Static/assets/twitter-square-brands.svg similarity index 100% rename from apps/theme/layouts/pages/Static/assets/twitter-square-brands.svg rename to extensions/theme/layouts/pages/Static/assets/twitter-square-brands.svg diff --git a/apps/theme/package.json b/extensions/theme/package.json similarity index 100% rename from apps/theme/package.json rename to extensions/theme/package.json diff --git a/apps/theme/theme.ts b/extensions/theme/theme.ts similarity index 100% rename from apps/theme/theme.ts rename to extensions/theme/theme.ts diff --git a/apps/theme/tsconfig.json b/extensions/theme/tsconfig.json similarity index 100% rename from apps/theme/tsconfig.json rename to extensions/theme/tsconfig.json diff --git a/package.json b/package.json index aeeb4df24fc..38bcb5d8438 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,6 @@ "apps/custom", "apps/website", "apps/website/prerendering/*", - "apps/theme", "apps/core/dynamoToElastic", "apps/api/apw/*", "apps/api/fileManager/*", @@ -18,9 +17,9 @@ "apps/api/pageBuilder/updateSettings", "apps/api/pageBuilder/import/*", "apps/api/pageBuilder/export/*", + "extensions/theme", "scripts/buildPackages", "scripts/prepublishOnly", - "plugins/myCustomPlugin" ] }, "author": "Webiny Ltd.", diff --git a/yarn.lock b/yarn.lock index aead5cb7489..7fbe442454a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -37672,9 +37672,9 @@ __metadata: languageName: node linkType: hard -"theme@^0.1.0, theme@workspace:apps/theme": +"theme@^0.1.0, theme@workspace:extensions/theme": version: 0.0.0-use.local - resolution: "theme@workspace:apps/theme" + resolution: "theme@workspace:extensions/theme" dependencies: "@apollo/react-hooks": ^3.1.5 "@emotion/react": ^11.10.6 From 41a89bd6168e90381a25b4273a32148e8cd41353 Mon Sep 17 00:00:00 2001 From: adrians5j Date: Mon, 6 May 2024 14:04:09 +0200 Subject: [PATCH 24/32] wip: move theme into extensions --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 38bcb5d8438..cbc963161e0 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "apps/api/pageBuilder/export/*", "extensions/theme", "scripts/buildPackages", - "scripts/prepublishOnly", + "scripts/prepublishOnly" ] }, "author": "Webiny Ltd.", From 90a12cdcd71e96fde69420884cccc3303a696723 Mon Sep 17 00:00:00 2001 From: adrians5j Date: Mon, 6 May 2024 14:25:05 +0200 Subject: [PATCH 25/32] wip: move theme into extensions --- apps/api/graphql/src/index.ts | 1 + package.json | 448 +++++++++++++++++----------------- 2 files changed, 225 insertions(+), 224 deletions(-) diff --git a/apps/api/graphql/src/index.ts b/apps/api/graphql/src/index.ts index be937e2ccf9..f8e8b115bfb 100644 --- a/apps/api/graphql/src/index.ts +++ b/apps/api/graphql/src/index.ts @@ -43,6 +43,7 @@ import { createCountDynamoDbTask } from "~/plugins/countDynamoDbTask"; import { createContinuingTask } from "~/plugins/continuingTask"; import { createWebsockets } from "@webiny/api-websockets"; import { createLockingMechanism } from "@webiny/api-locking-mechanism"; + import scaffoldsPlugins from "./plugins/scaffolds"; import { extensions } from "./extensions"; diff --git a/package.json b/package.json index cbc963161e0..43708a26ad6 100644 --- a/package.json +++ b/package.json @@ -1,226 +1,226 @@ { - "private": true, - "workspaces": { - "packages": [ - "packages/*", - "migrations", - "cypress-tests", - "apps/admin", - "apps/custom", - "apps/website", - "apps/website/prerendering/*", - "apps/core/dynamoToElastic", - "apps/api/apw/*", - "apps/api/fileManager/*", - "apps/api/graphql", - "apps/api/migration", - "apps/api/pageBuilder/updateSettings", - "apps/api/pageBuilder/import/*", - "apps/api/pageBuilder/export/*", - "extensions/theme", - "scripts/buildPackages", - "scripts/prepublishOnly" - ] - }, - "author": "Webiny Ltd.", - "repository": { - "type": "git", - "url": "https://github.com/webiny/webiny-js.git" - }, - "devDependencies": { - "@babel/cli": "^7.23.9", - "@babel/core": "^7.24.0", - "@babel/eslint-parser": "^7.23.9", - "@commitlint/cli": "^11.0.0", - "@commitlint/config-conventional": "^11.0.0", - "@octokit/rest": "^20.0.2", - "@types/fs-extra": "^8.0.1", - "@types/jest": "^29.5.11", - "@types/node": "^18.0.0", - "@types/prettier": "^2.7.3", - "@types/react": "17.0.39", - "@types/react-dom": "17.0.11", - "@typescript-eslint/eslint-plugin": "^5.5.0", - "@typescript-eslint/parser": "^5.5.0", - "adio": "^1.0.1", - "babel-jest": "29.7.0", - "babel-plugin-dynamic-import-node": "2.3.3", - "babel-plugin-macros": "3.1.0", - "babel-plugin-module-resolver": "^5.0.0", - "chalk": "^4.1.0", - "cross-env": "^5.2.0", - "deepmerge": "^4.3.1", - "env-ci": "2.0.1", - "eslint": "^8.56.0", - "eslint-config-standard": "^16.0.3", - "eslint-import-resolver-babel-module": "^5.3.1", - "eslint-plugin-import": "^2.25.3", - "eslint-plugin-jest": "^25.3.0", - "eslint-plugin-lodash": "^7.4.0", - "eslint-plugin-node": "^11.1.0", - "eslint-plugin-promise": "^5.2.0", - "eslint-plugin-react": "^7.27.1", - "eslint-plugin-standard": "^5.0.0", - "execa": "^5.1.1", - "folder-hash": "^4.0.0", - "fs-extra": "^7.0.0", - "get-stream": "^3.0.0", - "get-yarn-workspaces": "^1.0.2", - "git-cz": "^1.7.1", - "github-actions-wac": "^1.4.1", - "glob": "^7.1.3", - "graphql": "^15.7.2", - "husky": "^4.2.5", - "inquirer": "^7.0.0", - "inquirer-autocomplete-prompt": "^1.0.1", - "inquirer-checkbox-plus-prompt": "^1.0.1", - "inquirer-maxlength-input-prompt": "^1.0.0", - "jest": "^29.7.0", - "jest-environment-jsdom": "^29.7.0", - "jest-extended": "4.0.2", - "lerna": "8.1.2", - "lint-staged": "^15.2.2", - "listr": "^0.14.3", - "load-json-file": "^6.2.0", - "lodash": "4.17.21", - "longest": "^2.0.1", - "minimatch": "^5.1.0", - "nanoid": "^3.3.7", - "node-fetch": "^2.6.1", - "pm2": "^5.3.1", - "prettier": "^2.8.3", - "rimraf": "^5.0.5", - "semver": "^7.5.4", - "ts-expect": "^1.3.0", - "ts-jest": "^29.1.2", - "typescript": "4.7.4", - "typescript-transform-paths": "^3.4.6", - "verdaccio": "^5.29.1", - "write-json-file": "^4.2.0", - "yargs": "^17.0.1" - }, - "optionalDependencies": { - "fsevents": "^2.0.7" - }, - "scripts": { - "awp": "yarn add-webiny-package", - "add-webiny-package": "node scripts/addWebinyPackage.js", - "ci-workflows:build": "yarn ghawac build", - "ci-workflows:watch": "yarn ghawac watch", - "check-ts-configs": "node scripts/checkTsConfigs.js", - "check-package-dependencies": "node scripts/checkPackageNodeModules.js", - "deploy": "yarn webiny deploy", - "open": "yarn webiny open", - "eslint": "eslint \"**/*.{js,jsx,ts,tsx}\" --max-warnings=0", - "eslint:fix": "yarn eslint --fix", - "build": "node scripts/buildPackages", - "build:quick": "node scripts/buildPackages --build-overrides='{\"tsConfig\":{\"compilerOptions\":{\"skipLibCheck\":true}}}'", - "build:apps": "yarn webiny ws run build --scope='@webiny/app*'", - "build:api": "yarn webiny ws run build --scope='@webiny/api*' --scope='@webiny/handler*'", - "watch": "yarn webiny watch", - "watch:apps": "yarn webiny ws run watch --scope='@webiny/app*'", - "watch:api": "yarn webiny ws run watch --scope='@webiny/api*'", - "clear-dist": "yarn rimraf packages/*/dist", - "delete-empty-package-folders": "node scripts/deleteEmptyPackageFolders.js", - "cypress:open": "cd cypress-tests && yarn cypress open", - "cy:open": "yarn cypress:open", - "cypress:run": "cd cypress-tests && yarn cypress run", - "cy:run": "yarn cypress:run", - "cypress:ts": "cd cypress-tests && yarn tsc --noEmit", - "cy:ts": "yarn cypress:ts", - "webiny-versions": "node ./scripts/webinyVersions.js", - "trigger-release": "node ./scripts/release/triggerRelease.js", - "dispatch-github-event": "node ./scripts/dispatchGitHubEvent.js", - "lint-staged": "lint-staged", - "postinstall": "yarn node ./scripts/linkWorkspaces.js", - "prepublishOnly": "node scripts/prepublishOnly", - "prettier": "prettier \"**/**/*.{js,jsx,ts,tsx,json}\" --config .prettierrc.js", - "prettier:check": "yarn prettier --check", - "prettier:fix": "yarn prettier --write", - "lint:fix": "yarn eslint:fix && yarn prettier:fix", - "release": "node ./scripts/release/index.js", - "setup-project": "node scripts/setupProject", - "setup-env-files": "node scripts/setupEnvFiles", - "setup-cypress": "node scripts/setupCypress", - "test": "jest --runInBand --logHeapUsage --config jest.config.js", - "test:unit": "cross-env TEST_TYPE=unit yarn test", - "test:integration": "cross-env TEST_TYPE=integration yarn test", - "test:e2e": "cross-env TEST_TYPE=e2e yarn test", - "validate-packages": "node scripts/validatePackages.js", - "verdaccio:start": "yarn verdaccio -c ./.verdaccio.yaml", - "verdaccio:start:detached": "yarn pm2 start \"yarn verdaccio:start\"", - "webiny": "./node_modules/.bin/webiny", - "wby": "./node_modules/.bin/wby", - "webiny-ui-build-storybook": "cd packages/ui && cross-env OUT=../../netlify-static yarn build-storybook" - }, - "husky": { - "hooks": { - "pre-commit": "yarn && git add yarn.lock && yarn lint-staged && yarn adio && yarn check-ts-configs", - "commit-msg": "commitlint -E HUSKY_GIT_PARAMS" - } - }, - "lint-staged": { - "**/*.{js,ts,tsx}": [ - "prettier --write", - "eslint --max-warnings=0 --no-ignore" - ] - }, - "yargs": { - "populate--": true - }, - "commitlint": { - "extends": [ - "@commitlint/config-conventional" - ], - "rules": { - "type-enum": [ - 2, - "always", - [ - "feat", - "fix", - "docs", - "style", - "refactor", - "test", - "build", - "ci", - "chore", - "revert", - "merge", - "wip" - ] - ] - } - }, - "lerna": { - "version": "0.0.0", - "packages": [ - "packages/*" - ] - }, - "resolutions": { - "@emotion/react": "11.10.8", - "@octokit/rest": "^20.0.2", - "@types/react": "17.0.39", - "@types/jsdom": "link:./typings/void", - "@types/webpack": "^5.28.0", - "browserify-sign": "^4.2.2", - "@babel/traverse": "^7.24.0", - "jsdom": "24.0.0", - "react": "17.0.2", - "follow-redirects": "^1.15.6", - "crypto-js": "^4.2.0", - "ip": "^2.0.1", - "postcss": "^8.4.35", - "react-dom": "17.0.2", - "semver": "7.5.4", - "typescript": "4.7.4", - "codex-tooltip": "1.0.2", - "@types/eslint": "8.2.1", - "xml2js": "0.6.2", - "yargs": "^17.3.1", - "lerna@8.1.2": "patch:lerna@npm%3A8.1.2#./.yarn/patches/lerna-npm-8.1.2-be48ad2329.patch" - }, - "packageManager": "yarn@3.6.4" + "private": true, + "workspaces": { + "packages": [ + "packages/*", + "migrations", + "cypress-tests", + "apps/admin", + "apps/custom", + "apps/website", + "apps/website/prerendering/*", + "apps/core/dynamoToElastic", + "apps/api/apw/*", + "apps/api/fileManager/*", + "apps/api/graphql", + "apps/api/migration", + "apps/api/pageBuilder/updateSettings", + "apps/api/pageBuilder/import/*", + "apps/api/pageBuilder/export/*", + "extensions/theme", + "scripts/buildPackages", + "scripts/prepublishOnly" + ] + }, + "author": "Webiny Ltd.", + "repository": { + "type": "git", + "url": "https://github.com/webiny/webiny-js.git" + }, + "devDependencies": { + "@babel/cli": "^7.23.9", + "@babel/core": "^7.24.0", + "@babel/eslint-parser": "^7.23.9", + "@commitlint/cli": "^11.0.0", + "@commitlint/config-conventional": "^11.0.0", + "@octokit/rest": "^20.0.2", + "@types/fs-extra": "^8.0.1", + "@types/jest": "^29.5.11", + "@types/node": "^18.0.0", + "@types/prettier": "^2.7.3", + "@types/react": "17.0.39", + "@types/react-dom": "17.0.11", + "@typescript-eslint/eslint-plugin": "^5.5.0", + "@typescript-eslint/parser": "^5.5.0", + "adio": "^1.0.1", + "babel-jest": "29.7.0", + "babel-plugin-dynamic-import-node": "2.3.3", + "babel-plugin-macros": "3.1.0", + "babel-plugin-module-resolver": "^5.0.0", + "chalk": "^4.1.0", + "cross-env": "^5.2.0", + "deepmerge": "^4.3.1", + "env-ci": "2.0.1", + "eslint": "^8.56.0", + "eslint-config-standard": "^16.0.3", + "eslint-import-resolver-babel-module": "^5.3.1", + "eslint-plugin-import": "^2.25.3", + "eslint-plugin-jest": "^25.3.0", + "eslint-plugin-lodash": "^7.4.0", + "eslint-plugin-node": "^11.1.0", + "eslint-plugin-promise": "^5.2.0", + "eslint-plugin-react": "^7.27.1", + "eslint-plugin-standard": "^5.0.0", + "execa": "^5.1.1", + "folder-hash": "^4.0.0", + "fs-extra": "^7.0.0", + "get-stream": "^3.0.0", + "get-yarn-workspaces": "^1.0.2", + "git-cz": "^1.7.1", + "github-actions-wac": "^1.4.1", + "glob": "^7.1.3", + "graphql": "^15.7.2", + "husky": "^4.2.5", + "inquirer": "^7.0.0", + "inquirer-autocomplete-prompt": "^1.0.1", + "inquirer-checkbox-plus-prompt": "^1.0.1", + "inquirer-maxlength-input-prompt": "^1.0.0", + "jest": "^29.7.0", + "jest-environment-jsdom": "^29.7.0", + "jest-extended": "4.0.2", + "lerna": "8.1.2", + "lint-staged": "^15.2.2", + "listr": "^0.14.3", + "load-json-file": "^6.2.0", + "lodash": "4.17.21", + "longest": "^2.0.1", + "minimatch": "^5.1.0", + "nanoid": "^3.3.7", + "node-fetch": "^2.6.1", + "pm2": "^5.3.1", + "prettier": "^2.8.3", + "rimraf": "^5.0.5", + "semver": "^7.5.4", + "ts-expect": "^1.3.0", + "ts-jest": "^29.1.2", + "typescript": "4.7.4", + "typescript-transform-paths": "^3.4.6", + "verdaccio": "^5.29.1", + "write-json-file": "^4.2.0", + "yargs": "^17.0.1" + }, + "optionalDependencies": { + "fsevents": "^2.0.7" + }, + "scripts": { + "awp": "yarn add-webiny-package", + "add-webiny-package": "node scripts/addWebinyPackage.js", + "ci-workflows:build": "yarn ghawac build", + "ci-workflows:watch": "yarn ghawac watch", + "check-ts-configs": "node scripts/checkTsConfigs.js", + "check-package-dependencies": "node scripts/checkPackageNodeModules.js", + "deploy": "yarn webiny deploy", + "open": "yarn webiny open", + "eslint": "eslint \"**/*.{js,jsx,ts,tsx}\" --max-warnings=0", + "eslint:fix": "yarn eslint --fix", + "build": "node scripts/buildPackages", + "build:quick": "node scripts/buildPackages --build-overrides='{\"tsConfig\":{\"compilerOptions\":{\"skipLibCheck\":true}}}'", + "build:apps": "yarn webiny ws run build --scope='@webiny/app*'", + "build:api": "yarn webiny ws run build --scope='@webiny/api*' --scope='@webiny/handler*'", + "watch": "yarn webiny watch", + "watch:apps": "yarn webiny ws run watch --scope='@webiny/app*'", + "watch:api": "yarn webiny ws run watch --scope='@webiny/api*'", + "clear-dist": "yarn rimraf packages/*/dist", + "delete-empty-package-folders": "node scripts/deleteEmptyPackageFolders.js", + "cypress:open": "cd cypress-tests && yarn cypress open", + "cy:open": "yarn cypress:open", + "cypress:run": "cd cypress-tests && yarn cypress run", + "cy:run": "yarn cypress:run", + "cypress:ts": "cd cypress-tests && yarn tsc --noEmit", + "cy:ts": "yarn cypress:ts", + "webiny-versions": "node ./scripts/webinyVersions.js", + "trigger-release": "node ./scripts/release/triggerRelease.js", + "dispatch-github-event": "node ./scripts/dispatchGitHubEvent.js", + "lint-staged": "lint-staged", + "postinstall": "yarn node ./scripts/linkWorkspaces.js", + "prepublishOnly": "node scripts/prepublishOnly", + "prettier": "prettier \"**/**/*.{js,jsx,ts,tsx,json}\" --config .prettierrc.js", + "prettier:check": "yarn prettier --check", + "prettier:fix": "yarn prettier --write", + "lint:fix": "yarn eslint:fix && yarn prettier:fix", + "release": "node ./scripts/release/index.js", + "setup-project": "node scripts/setupProject", + "setup-env-files": "node scripts/setupEnvFiles", + "setup-cypress": "node scripts/setupCypress", + "test": "jest --runInBand --logHeapUsage --config jest.config.js", + "test:unit": "cross-env TEST_TYPE=unit yarn test", + "test:integration": "cross-env TEST_TYPE=integration yarn test", + "test:e2e": "cross-env TEST_TYPE=e2e yarn test", + "validate-packages": "node scripts/validatePackages.js", + "verdaccio:start": "yarn verdaccio -c ./.verdaccio.yaml", + "verdaccio:start:detached": "yarn pm2 start \"yarn verdaccio:start\"", + "webiny": "./node_modules/.bin/webiny", + "wby": "./node_modules/.bin/wby", + "webiny-ui-build-storybook": "cd packages/ui && cross-env OUT=../../netlify-static yarn build-storybook" + }, + "husky": { + "hooks": { + "pre-commit": "yarn && git add yarn.lock && yarn lint-staged && yarn adio && yarn check-ts-configs", + "commit-msg": "commitlint -E HUSKY_GIT_PARAMS" + } + }, + "lint-staged": { + "**/*.{js,ts,tsx}": [ + "prettier --write", + "eslint --max-warnings=0 --no-ignore" + ] + }, + "yargs": { + "populate--": true + }, + "commitlint": { + "extends": [ + "@commitlint/config-conventional" + ], + "rules": { + "type-enum": [ + 2, + "always", + [ + "feat", + "fix", + "docs", + "style", + "refactor", + "test", + "build", + "ci", + "chore", + "revert", + "merge", + "wip" + ] + ] + } + }, + "lerna": { + "version": "0.0.0", + "packages": [ + "packages/*" + ] + }, + "resolutions": { + "@emotion/react": "11.10.8", + "@octokit/rest": "^20.0.2", + "@types/react": "17.0.39", + "@types/jsdom": "link:./typings/void", + "@types/webpack": "^5.28.0", + "browserify-sign": "^4.2.2", + "@babel/traverse": "^7.24.0", + "jsdom": "24.0.0", + "react": "17.0.2", + "follow-redirects": "^1.15.6", + "crypto-js": "^4.2.0", + "ip": "^2.0.1", + "postcss": "^8.4.35", + "react-dom": "17.0.2", + "semver": "7.5.4", + "typescript": "4.7.4", + "codex-tooltip": "1.0.2", + "@types/eslint": "8.2.1", + "xml2js": "0.6.2", + "yargs": "^17.3.1", + "lerna@8.1.2": "patch:lerna@npm%3A8.1.2#./.yarn/patches/lerna-npm-8.1.2-be48ad2329.patch" + }, + "packageManager": "yarn@3.6.4" } From 7066825885c7e17c62bf0e1bf81274dc6d606926 Mon Sep 17 00:00:00 2001 From: adrians5j Date: Mon, 6 May 2024 15:04:52 +0200 Subject: [PATCH 26/32] wip: create essential plugins scaffold --- .../src/generators/utils/addPluginToApiApp.tsx | 6 +++--- .../src/generators/utils/addPluginToReactApp.tsx | 6 +++--- .../templates/admin/src/index.tsx | 4 ++-- .../templates/api/src/index.ts | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/cli-plugin-scaffold-extensions/src/generators/utils/addPluginToApiApp.tsx b/packages/cli-plugin-scaffold-extensions/src/generators/utils/addPluginToApiApp.tsx index 29650b74c56..6bbf7973b0e 100644 --- a/packages/cli-plugin-scaffold-extensions/src/generators/utils/addPluginToApiApp.tsx +++ b/packages/cli-plugin-scaffold-extensions/src/generators/utils/addPluginToApiApp.tsx @@ -12,8 +12,8 @@ export const addPluginToApiApp = async (params: Params): Promise => { const extensionsFilePath = path.join("apps", "api", "graphql", "src", "extensions.ts"); - const pluginsFactory = extensionName + "PluginsFactory"; - const importName = "{ createPlugins as " + pluginsFactory + " }"; + const extensionFactory = extensionName + "ExtensionFactory"; + const importName = "{ createExtension as " + extensionFactory + " }"; const importPath = packageName; const project = new Project(); @@ -45,7 +45,7 @@ export const addPluginToApiApp = async (params: Params): Promise => { Node.isArrayLiteralExpression(node) ) as ArrayLiteralExpression; - pluginsArray.addElement(`${pluginsFactory}()`); + pluginsArray.addElement(`${extensionFactory}()`); await source.save(); diff --git a/packages/cli-plugin-scaffold-extensions/src/generators/utils/addPluginToReactApp.tsx b/packages/cli-plugin-scaffold-extensions/src/generators/utils/addPluginToReactApp.tsx index 3afa401664c..bdf28fb8851 100644 --- a/packages/cli-plugin-scaffold-extensions/src/generators/utils/addPluginToReactApp.tsx +++ b/packages/cli-plugin-scaffold-extensions/src/generators/utils/addPluginToReactApp.tsx @@ -12,8 +12,8 @@ export const addPluginToReactApp = async (params: Params): Promise => { const extensionsFilePath = path.join("apps", "admin", "src", "Extensions.tsx"); - const pluginsFactory = extensionName + "PluginsFactory"; - const importName = "{ createPlugins as " + pluginsFactory + " }"; + const extensionFactory = extensionName + "ExtensionFactory"; + const importName = "{ createExtension as " + extensionFactory + " }"; const importPath = packageName; const project = new Project(); @@ -73,7 +73,7 @@ export const addPluginToReactApp = async (params: Params): Promise => { .trim(); extensionsArrowFnFragment.replaceWithText( - `<>{${extensionName}PluginsFactory()}${extensionsArrowFnFragmentChildrenText}` + `<>{${extensionName}ExtensionFactory()}${extensionsArrowFnFragmentChildrenText}` ); await source.save(); diff --git a/packages/cli-plugin-scaffold-extensions/templates/admin/src/index.tsx b/packages/cli-plugin-scaffold-extensions/templates/admin/src/index.tsx index 89aec64af47..9aca87d931c 100644 --- a/packages/cli-plugin-scaffold-extensions/templates/admin/src/index.tsx +++ b/packages/cli-plugin-scaffold-extensions/templates/admin/src/index.tsx @@ -1,5 +1,5 @@ import React from "react"; -export const createPlugins = () => { - return <>{/*Your plugins here.*/}; +export const createExtension = () => { + return <>{/* Your code here. */}; }; diff --git a/packages/cli-plugin-scaffold-extensions/templates/api/src/index.ts b/packages/cli-plugin-scaffold-extensions/templates/api/src/index.ts index 9b5ed911533..34b9cd491b3 100644 --- a/packages/cli-plugin-scaffold-extensions/templates/api/src/index.ts +++ b/packages/cli-plugin-scaffold-extensions/templates/api/src/index.ts @@ -1,5 +1,5 @@ -export const createPlugins = () => { +export const createExtension = () => { return [ - // Your plugins here. + // Your code here. ]; }; From c00b7f40adab509b9ba7f34f029186e053e07daf Mon Sep 17 00:00:00 2001 From: adrians5j Date: Mon, 6 May 2024 15:11:19 +0200 Subject: [PATCH 27/32] wip: create essential plugins scaffold --- .../src/index.ts | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/packages/cli-plugin-scaffold-extensions/src/index.ts b/packages/cli-plugin-scaffold-extensions/src/index.ts index 26d174c1c7a..36fd6d87fd3 100644 --- a/packages/cli-plugin-scaffold-extensions/src/index.ts +++ b/packages/cli-plugin-scaffold-extensions/src/index.ts @@ -23,13 +23,13 @@ interface Input { extensionName: string; packageName: string; location: string; - pluginType: string; + extensionType: string; } const EXTENSIONS_ROOT_FOLDER = 'extensions'; export default (): CliCommandScaffoldTemplate => ({ - name: "cli-plugin-scaffold-template-plugin", + name: "cli-plugin-scaffold-template-extensions", type: "cli-plugin-scaffold-template", scaffold: { name: "New Extension", @@ -37,7 +37,7 @@ export default (): CliCommandScaffoldTemplate => ({ questions: () => { return [ { - name: "pluginType", + name: "extensionType", message: "What type of an extension do you want to create?", type: "list", choices: [ @@ -48,7 +48,7 @@ export default (): CliCommandScaffoldTemplate => ({ { name: "extensionName", message: "Enter the extension name:", - default: "myCustomPlugin", + default: "myCustomExtension", validate: extensionName => { if (!extensionName) { return "Missing extension name."; @@ -56,7 +56,7 @@ export default (): CliCommandScaffoldTemplate => ({ const isValidName = extensionName === Case.camel(extensionName); if (!isValidName) { - return `Please use camel case when providing the name of the extension (for example "myCustomPlugin").`; + return `Please use camel case when providing the name of the extension (for example "myCustomExtension").`; } return true; @@ -75,7 +75,7 @@ export default (): CliCommandScaffoldTemplate => ({ const isValidName = validateNpmPackageName(pkgName); if (!isValidName) { - return `Package name must look something like "my-custom-plugin".`; + return `Package name must look something like "my-custom-extension".`; } return true; @@ -83,7 +83,7 @@ export default (): CliCommandScaffoldTemplate => ({ }, { name: "location", - message: `Enter the plugin location:`, + message: `Enter the extension location:`, default: (answers: Input) => { return `${EXTENSIONS_ROOT_FOLDER}/${answers.extensionName}`; }, @@ -107,12 +107,12 @@ export default (): CliCommandScaffoldTemplate => ({ ]; }, generate: async ({ input, ora }) => { - const { pluginType, extensionName, packageName, location } = input; + const { extensionType, extensionName, packageName, location } = input; try { - ora.start(`Creating ${extensionName} plugin...`); + ora.start(`Creating ${extensionName} extension...`); - const sourcePath = path.join(__dirname, "templates", pluginType); + const sourcePath = path.join(__dirname, "templates", extensionType); if (fs.existsSync(location)) { throw new WebinyError(`The target location already exists "${location}"`); @@ -146,16 +146,16 @@ export default (): CliCommandScaffoldTemplate => ({ await writeJson(rootPackageJsonPath, rootPackageJson); } - if (typeof generators[pluginType] === "function") { - await generators[pluginType]({ input }); + if (typeof generators[extensionType] === "function") { + await generators[extensionType]({ input }); } // Once everything is done, run `yarn` so the new packages are automatically installed. await execa("yarn"); - ora.succeed(`New plugin created in ${log.success.hl(location)}.`); + ora.succeed(`New extension created in ${log.success.hl(location)}.`); } catch (err) { - ora.fail("Could not create plugin. Please check the logs below."); + ora.fail("Could not create extension. Please check the logs below."); console.log(); console.log(err); } From e4ae8e53e80769800beed47ece4d1b9b551a23a8 Mon Sep 17 00:00:00 2001 From: adrians5j Date: Mon, 6 May 2024 16:44:25 +0200 Subject: [PATCH 28/32] chore: prettier --- .../src/generators/utils/addPluginToReactApp.tsx | 4 +++- packages/cli-plugin-scaffold-extensions/src/index.ts | 2 +- .../cwp-template-aws/template/common/webiny.project.ts | 1 - .../cwp-template-aws/template/ddb-es/dependencies.json | 8 +------- .../cwp-template-aws/template/ddb-os/dependencies.json | 8 +------- packages/cwp-template-aws/template/ddb/dependencies.json | 8 +------- 6 files changed, 7 insertions(+), 24 deletions(-) diff --git a/packages/cli-plugin-scaffold-extensions/src/generators/utils/addPluginToReactApp.tsx b/packages/cli-plugin-scaffold-extensions/src/generators/utils/addPluginToReactApp.tsx index bdf28fb8851..4fec895fa99 100644 --- a/packages/cli-plugin-scaffold-extensions/src/generators/utils/addPluginToReactApp.tsx +++ b/packages/cli-plugin-scaffold-extensions/src/generators/utils/addPluginToReactApp.tsx @@ -55,7 +55,9 @@ export const addPluginToReactApp = async (params: Params): Promise => { ); } - const extensionsArrowFn = extensionsIdentifier.getNextSibling(node => Node.isArrowFunction(node)); + const extensionsArrowFn = extensionsIdentifier.getNextSibling(node => + Node.isArrowFunction(node) + ); if (!extensionsArrowFn) { throw new Error( `Could not find the "Extensions" React component in "${extensionsFilePath}". Did you maybe change its definition? It should be an arrow function.` diff --git a/packages/cli-plugin-scaffold-extensions/src/index.ts b/packages/cli-plugin-scaffold-extensions/src/index.ts index 36fd6d87fd3..3594cbc803f 100644 --- a/packages/cli-plugin-scaffold-extensions/src/index.ts +++ b/packages/cli-plugin-scaffold-extensions/src/index.ts @@ -26,7 +26,7 @@ interface Input { extensionType: string; } -const EXTENSIONS_ROOT_FOLDER = 'extensions'; +const EXTENSIONS_ROOT_FOLDER = "extensions"; export default (): CliCommandScaffoldTemplate => ({ name: "cli-plugin-scaffold-template-extensions", diff --git a/packages/cwp-template-aws/template/common/webiny.project.ts b/packages/cwp-template-aws/template/common/webiny.project.ts index 1fa753b35d9..0e37a5ca086 100644 --- a/packages/cwp-template-aws/template/common/webiny.project.ts +++ b/packages/cwp-template-aws/template/common/webiny.project.ts @@ -9,7 +9,6 @@ import cliScaffoldAdminModule from "@webiny/cli-plugin-scaffold-admin-app-module import cliScaffoldExtensions from "@webiny/cli-plugin-scaffold-extensions"; import cliScaffoldCiCd from "@webiny/cli-plugin-scaffold-ci"; - export default { template: "[TEMPLATE_VERSION]", name: "[PROJECT_NAME]", diff --git a/packages/cwp-template-aws/template/ddb-es/dependencies.json b/packages/cwp-template-aws/template/ddb-es/dependencies.json index cdf5a4bf142..26550e55dde 100644 --- a/packages/cwp-template-aws/template/ddb-es/dependencies.json +++ b/packages/cwp-template-aws/template/ddb-es/dependencies.json @@ -50,13 +50,7 @@ "typescript": "4.7.4" }, "workspaces": { - "packages": [ - "apps/admin", - "apps/website", - "apps/api/graphql", - "extensions/theme", - "packages/*" - ] + "packages": ["apps/admin", "apps/website", "apps/api/graphql", "extensions/theme", "packages/*"] }, "scripts": { "test": "jest --config jest.config.js --passWithNoTests", diff --git a/packages/cwp-template-aws/template/ddb-os/dependencies.json b/packages/cwp-template-aws/template/ddb-os/dependencies.json index aaa40f148b2..667ed0a2aa9 100644 --- a/packages/cwp-template-aws/template/ddb-os/dependencies.json +++ b/packages/cwp-template-aws/template/ddb-os/dependencies.json @@ -51,13 +51,7 @@ "typescript": "4.7.4" }, "workspaces": { - "packages": [ - "apps/admin", - "apps/website", - "apps/api/graphql", - "extensions/theme", - "packages/*" - ] + "packages": ["apps/admin", "apps/website", "apps/api/graphql", "extensions/theme", "packages/*"] }, "scripts": { "test": "jest --config jest.config.js --passWithNoTests", diff --git a/packages/cwp-template-aws/template/ddb/dependencies.json b/packages/cwp-template-aws/template/ddb/dependencies.json index a8804bf3de6..2fd4a81b03a 100644 --- a/packages/cwp-template-aws/template/ddb/dependencies.json +++ b/packages/cwp-template-aws/template/ddb/dependencies.json @@ -50,13 +50,7 @@ "typescript": "4.7.4" }, "workspaces": { - "packages": [ - "apps/admin", - "apps/website", - "apps/api/graphql", - "extensions/theme", - "packages/*" - ] + "packages": ["apps/admin", "apps/website", "apps/api/graphql", "extensions/theme", "packages/*"] }, "scripts": { "test": "jest --config jest.config.js --passWithNoTests", From e65ce7ef4ca32ad75ab49418926f5991ea070a9a Mon Sep 17 00:00:00 2001 From: adrians5j Date: Mon, 6 May 2024 22:35:28 +0200 Subject: [PATCH 29/32] wip: create essential plugins scaffold --- .../generators/utils/addPluginToApiApp.tsx | 6 +- .../generators/utils/addPluginToReactApp.tsx | 8 +-- .../src/index.ts | 56 +++++++++++++------ .../src/types.ts | 2 +- 4 files changed, 46 insertions(+), 26 deletions(-) diff --git a/packages/cli-plugin-scaffold-extensions/src/generators/utils/addPluginToApiApp.tsx b/packages/cli-plugin-scaffold-extensions/src/generators/utils/addPluginToApiApp.tsx index 6bbf7973b0e..bbcaa75b252 100644 --- a/packages/cli-plugin-scaffold-extensions/src/generators/utils/addPluginToApiApp.tsx +++ b/packages/cli-plugin-scaffold-extensions/src/generators/utils/addPluginToApiApp.tsx @@ -3,16 +3,16 @@ import path from "path"; import { formatCode } from "@webiny/cli-plugin-scaffold/utils"; interface Params { - extensionName: string; + name: string; packageName: string; } export const addPluginToApiApp = async (params: Params): Promise => { - const { extensionName, packageName } = params; + const { name, packageName } = params; const extensionsFilePath = path.join("apps", "api", "graphql", "src", "extensions.ts"); - const extensionFactory = extensionName + "ExtensionFactory"; + const extensionFactory = name + "ExtensionFactory"; const importName = "{ createExtension as " + extensionFactory + " }"; const importPath = packageName; diff --git a/packages/cli-plugin-scaffold-extensions/src/generators/utils/addPluginToReactApp.tsx b/packages/cli-plugin-scaffold-extensions/src/generators/utils/addPluginToReactApp.tsx index 4fec895fa99..06c4891456d 100644 --- a/packages/cli-plugin-scaffold-extensions/src/generators/utils/addPluginToReactApp.tsx +++ b/packages/cli-plugin-scaffold-extensions/src/generators/utils/addPluginToReactApp.tsx @@ -3,16 +3,16 @@ import path from "path"; import { formatCode } from "@webiny/cli-plugin-scaffold/utils"; interface Params { - extensionName: string; + name: string; packageName: string; } export const addPluginToReactApp = async (params: Params): Promise => { - const { extensionName, packageName } = params; + const { name, packageName } = params; const extensionsFilePath = path.join("apps", "admin", "src", "Extensions.tsx"); - const extensionFactory = extensionName + "ExtensionFactory"; + const extensionFactory = name + "ExtensionFactory"; const importName = "{ createExtension as " + extensionFactory + " }"; const importPath = packageName; @@ -75,7 +75,7 @@ export const addPluginToReactApp = async (params: Params): Promise => { .trim(); extensionsArrowFnFragment.replaceWithText( - `<>{${extensionName}ExtensionFactory()}${extensionsArrowFnFragmentChildrenText}` + `<>{${name}ExtensionFactory()}${extensionsArrowFnFragmentChildrenText}` ); await source.save(); diff --git a/packages/cli-plugin-scaffold-extensions/src/index.ts b/packages/cli-plugin-scaffold-extensions/src/index.ts index 3594cbc803f..d10e1f55219 100644 --- a/packages/cli-plugin-scaffold-extensions/src/index.ts +++ b/packages/cli-plugin-scaffold-extensions/src/index.ts @@ -20,10 +20,10 @@ import { generators } from "./generators"; const ncp = util.promisify(ncpBase.ncp); interface Input { - extensionName: string; + type: string; + name: string; packageName: string; location: string; - extensionType: string; } const EXTENSIONS_ROOT_FOLDER = "extensions"; @@ -31,6 +31,7 @@ const EXTENSIONS_ROOT_FOLDER = "extensions"; export default (): CliCommandScaffoldTemplate => ({ name: "cli-plugin-scaffold-template-extensions", type: "cli-plugin-scaffold-template", + templateName: "new-extension", scaffold: { name: "New Extension", description: "Scaffolds essential files for creating a new extension.", @@ -66,7 +67,7 @@ export default (): CliCommandScaffoldTemplate => ({ name: "packageName", message: "Enter the package name:", default: (answers: Input) => { - return Case.kebab(answers.extensionName); + return Case.kebab(answers.name); }, validate: pkgName => { if (!pkgName) { @@ -85,7 +86,7 @@ export default (): CliCommandScaffoldTemplate => ({ name: "location", message: `Enter the extension location:`, default: (answers: Input) => { - return `${EXTENSIONS_ROOT_FOLDER}/${answers.extensionName}`; + return `${EXTENSIONS_ROOT_FOLDER}/${answers.name}`; }, validate: location => { if (!location) { @@ -107,26 +108,45 @@ export default (): CliCommandScaffoldTemplate => ({ ]; }, generate: async ({ input, ora }) => { - const { extensionType, extensionName, packageName, location } = input; + const { type, name } = input; + if (!type) { + throw new Error("Missing extension type."); + } - try { - ora.start(`Creating ${extensionName} extension...`); + const templatePath = path.join(__dirname, "templates", type); + const templateExists = fs.existsSync(templatePath); + if (!templateExists) { + throw new Error("Unknown extension type."); + } - const sourcePath = path.join(__dirname, "templates", extensionType); + if (!name) { + throw new Error("Missing extension name."); + } - if (fs.existsSync(location)) { - throw new WebinyError(`The target location already exists "${location}"`); - } + let { packageName, location } = input; + if (!packageName) { + packageName = Case.kebab(name); + } - const project = getProject(); + if (!location) { + location = `${EXTENSIONS_ROOT_FOLDER}/${name}`; + } - const baseTsConfigFullPath = path.resolve(project.root, "tsconfig.json"); - const baseTsConfigRelativePath = path.relative(location, baseTsConfigFullPath); + if (fs.existsSync(location)) { + throw new WebinyError(`The target location already exists "${location}"`); + } - fs.mkdirSync(location, { recursive: true }); + try { + ora.start(`Creating ${log.success.hl(name)} extension...`); // Copy template files - await ncp(sourcePath, location); + fs.mkdirSync(location, { recursive: true }); + await ncp(templatePath, location); + + const project = getProject(); + + const baseTsConfigFullPath = path.resolve(project.root, "tsconfig.json"); + const baseTsConfigRelativePath = path.relative(location, baseTsConfigFullPath); const codeReplacements = [ { find: "PACKAGE_NAME", replaceWith: packageName }, @@ -146,8 +166,8 @@ export default (): CliCommandScaffoldTemplate => ({ await writeJson(rootPackageJsonPath, rootPackageJson); } - if (typeof generators[extensionType] === "function") { - await generators[extensionType]({ input }); + if (typeof generators[type] === "function") { + await generators[type]({ input: { name, packageName } }); } // Once everything is done, run `yarn` so the new packages are automatically installed. diff --git a/packages/cli-plugin-scaffold-extensions/src/types.ts b/packages/cli-plugin-scaffold-extensions/src/types.ts index 50f63fe4c7b..034301c7096 100644 --- a/packages/cli-plugin-scaffold-extensions/src/types.ts +++ b/packages/cli-plugin-scaffold-extensions/src/types.ts @@ -1,6 +1,6 @@ interface PluginGeneratorParams { input: { - extensionName: string; + name: string; packageName: string; }; } From 2a77a292ac51cc076515646b9e00502cbd33b3f1 Mon Sep 17 00:00:00 2001 From: adrians5j Date: Mon, 6 May 2024 22:41:34 +0200 Subject: [PATCH 30/32] wip: create essential plugins scaffold --- packages/cli-plugin-scaffold/src/index.ts | 18 ++++- packages/cli-plugin-scaffold/src/scaffold.ts | 81 +++++++++++--------- packages/cli-plugin-scaffold/src/types.ts | 9 ++- 3 files changed, 68 insertions(+), 40 deletions(-) diff --git a/packages/cli-plugin-scaffold/src/index.ts b/packages/cli-plugin-scaffold/src/index.ts index 13a727e3a37..011b2c4a9b7 100644 --- a/packages/cli-plugin-scaffold/src/index.ts +++ b/packages/cli-plugin-scaffold/src/index.ts @@ -5,8 +5,20 @@ export default (): CliCommandPlugin => ({ type: "cli-command", name: "cli-command-scaffold", create({ yargs, context }) { - yargs.command("scaffold", "Generate boilerplate code", () => { - return scaffold({ context }); - }); + yargs.command( + "scaffold [template-name]", + "Generate boilerplate code", + (yargs: Record) => { + yargs.example("$0 scaffold"); + yargs.example("$0 scaffold new-extension --type admin --name customFilePreview"); + yargs.positional("templateName", { + describe: `Name of the scaffold to run (useful when running in non-interactive mode).`, + type: "string" + }); + }, + (argv: Record) => { + return scaffold(context, argv); + } + ); } }); diff --git a/packages/cli-plugin-scaffold/src/scaffold.ts b/packages/cli-plugin-scaffold/src/scaffold.ts index c04a8e9a1ca..ef4b012b362 100644 --- a/packages/cli-plugin-scaffold/src/scaffold.ts +++ b/packages/cli-plugin-scaffold/src/scaffold.ts @@ -1,7 +1,7 @@ import ora from "ora"; import inquirer from "inquirer"; import chalk from "chalk"; -import { CliCommandScaffoldTemplate } from "./types"; +import { CliCommandScaffold, CliCommandScaffoldTemplate } from "./types"; import { CliContext } from "@webiny/cli/types"; const wait = (ms?: number): Promise => { @@ -10,13 +10,7 @@ const wait = (ms?: number): Promise => { }); }; -interface ScaffoldArgs { - context: CliContext; -} - -export const scaffold = async (args: ScaffoldArgs) => { - const { context } = args; - +export const scaffold = async (context: CliContext, args: Record) => { const scaffoldPlugins = context.plugins.byType( "cli-plugin-scaffold-template" ); @@ -27,50 +21,65 @@ export const scaffold = async (args: ScaffoldArgs) => { process.exit(1); } - const choices = scaffoldPlugins.map(plugin => { - const { name, description } = plugin.scaffold; + let scaffold: CliCommandScaffold>; + let input: any; - return { - name: `${chalk.bold(name)}\n ${description}\n`, - short: name, - value: plugin.name - }; - }); + if (args.templateName) { + const scaffoldPlugin = scaffoldPlugins.find(p => p.templateName === args.templateName); + if (!scaffoldPlugin) { + console.log(`🚨 We couldn't find the scaffold with the "${args.templateName}" alias.`); + process.exit(1); + } - const { selectedPluginName } = await inquirer.prompt({ - type: "list", - pageSize: 18, - name: "selectedPluginName", - message: "Choose a scaffold:", - choices - }); + scaffold = scaffoldPlugin!.scaffold; + input = args; + } else { + const choices = scaffoldPlugins.map(plugin => { + const { name, description } = plugin.scaffold; - const { scaffold } = context.plugins.byName(selectedPluginName); + return { + name: `${chalk.bold(name)}\n ${description}\n`, + short: name, + value: plugin.name + }; + }); - const questions = - typeof scaffold.questions === "function" - ? scaffold.questions({ context }) - : scaffold.questions; + const { selectedPluginName } = await inquirer.prompt({ + type: "list", + pageSize: 18, + name: "selectedPluginName", + message: "Choose a scaffold:", + choices + }); + + const { scaffold } = context.plugins.byName(selectedPluginName); + + const questions = + typeof scaffold.questions === "function" + ? scaffold.questions({ context }) + : scaffold.questions; + + input = await inquirer.prompt(questions); + } - const input = await inquirer.prompt(questions); const oraInstance = ora(); const callbackArgs = { input, context, wait, ora: oraInstance, inquirer }; try { - if (typeof scaffold.onGenerate === "function") { - await scaffold.onGenerate(callbackArgs); + if (typeof scaffold!.onGenerate === "function") { + await scaffold!.onGenerate(callbackArgs); } - await scaffold.generate(callbackArgs); + await scaffold!.generate(callbackArgs); - if (typeof scaffold.onSuccess === "function") { - await scaffold.onSuccess(callbackArgs); + if (typeof scaffold!.onSuccess === "function") { + await scaffold!.onSuccess(callbackArgs); } } catch (e) { oraInstance.stop(); - if (typeof scaffold.onError === "function") { - await scaffold.onError({ ...callbackArgs, error: e }); + if (typeof scaffold!.onError === "function") { + await scaffold!.onError({ ...callbackArgs, error: e }); } else { console.log(e); } diff --git a/packages/cli-plugin-scaffold/src/types.ts b/packages/cli-plugin-scaffold/src/types.ts index 4f279d8bc24..f4771101c97 100644 --- a/packages/cli-plugin-scaffold/src/types.ts +++ b/packages/cli-plugin-scaffold/src/types.ts @@ -79,7 +79,7 @@ export interface CliCommandScaffoldCallableWithErrorArgs> { +export interface CliCommandScaffold> { /** * Name of the scaffold to be picked from list of choices. */ @@ -123,6 +123,13 @@ export interface CliCommandScaffoldTemplate = Reco * A type of the plugin. */ type: "cli-plugin-scaffold-template"; + + /** + * Template name. Can be used when running the scaffold command in + * non-interactive mode (for example: `webiny scaffold new-template`). + */ + templateName?: string; + /** * The scaffold definition. */ From 13fd3c8209be548eff2bd6027686395c3d564d41 Mon Sep 17 00:00:00 2001 From: adrians5j Date: Mon, 6 May 2024 22:45:52 +0200 Subject: [PATCH 31/32] wip: create essential plugins scaffold --- packages/cli-plugin-scaffold-extensions/src/index.ts | 10 +++++----- packages/cli-plugin-scaffold/src/scaffold.ts | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/cli-plugin-scaffold-extensions/src/index.ts b/packages/cli-plugin-scaffold-extensions/src/index.ts index d10e1f55219..eb812b22fce 100644 --- a/packages/cli-plugin-scaffold-extensions/src/index.ts +++ b/packages/cli-plugin-scaffold-extensions/src/index.ts @@ -38,7 +38,7 @@ export default (): CliCommandScaffoldTemplate => ({ questions: () => { return [ { - name: "extensionType", + name: "type", message: "What type of an extension do you want to create?", type: "list", choices: [ @@ -47,15 +47,15 @@ export default (): CliCommandScaffoldTemplate => ({ ] }, { - name: "extensionName", + name: "name", message: "Enter the extension name:", default: "myCustomExtension", - validate: extensionName => { - if (!extensionName) { + validate: name => { + if (!name) { return "Missing extension name."; } - const isValidName = extensionName === Case.camel(extensionName); + const isValidName = name === Case.camel(name); if (!isValidName) { return `Please use camel case when providing the name of the extension (for example "myCustomExtension").`; } diff --git a/packages/cli-plugin-scaffold/src/scaffold.ts b/packages/cli-plugin-scaffold/src/scaffold.ts index ef4b012b362..615547cdd24 100644 --- a/packages/cli-plugin-scaffold/src/scaffold.ts +++ b/packages/cli-plugin-scaffold/src/scaffold.ts @@ -52,7 +52,7 @@ export const scaffold = async (context: CliContext, args: Record) = choices }); - const { scaffold } = context.plugins.byName(selectedPluginName); + ({ scaffold } = context.plugins.byName(selectedPluginName)); const questions = typeof scaffold.questions === "function" From 413e3263a946022a71f2333bfe21658907aedf59 Mon Sep 17 00:00:00 2001 From: adrians5j Date: Tue, 7 May 2024 10:37:26 +0200 Subject: [PATCH 32/32] fix: correct `theme` path --- scripts/prepublishOnly/src/prepublishOnly.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/prepublishOnly/src/prepublishOnly.ts b/scripts/prepublishOnly/src/prepublishOnly.ts index d691f132242..29e3008b88e 100644 --- a/scripts/prepublishOnly/src/prepublishOnly.ts +++ b/scripts/prepublishOnly/src/prepublishOnly.ts @@ -135,7 +135,7 @@ const extraFiles: string[] = [ "packages/cwp-template-aws/template/ddb-es/apps/api/graphql/package.json", "packages/cwp-template-aws/template/ddb-os/apps/api/graphql/package.json", "packages/cwp-template-aws/template/common/apps/admin/package.json", - "packages/cwp-template-aws/template/common/apps/theme/package.json", + "packages/cwp-template-aws/template/common/extensions/theme/package.json", "packages/cwp-template-aws/template/common/apps/website/package.json" ];