From 6b54bf4132b700e63402d8fd2509039884f87c40 Mon Sep 17 00:00:00 2001 From: Dominic Saadi Date: Thu, 21 Sep 2023 18:42:58 -0700 Subject: [PATCH] chore: update files based on latest CRWA template (#103) The CRWA templated has changed in subtle ways since this repo was initialized. This PR brings some of the files up to date. --- .gitignore | 11 ++--- .redwood/README.md | 44 +++++++++++++++++++ api/src/directives/requireAuth/requireAuth.js | 3 +- api/src/lib/logger.js | 6 +-- web/package.json | 5 +-- web/public/README.md | 11 +++-- web/src/{App.js => App.jsx} | 0 web/src/{Routes.js => Routes.jsx} | 0 yarn.lock | 1 - 9 files changed, 57 insertions(+), 24 deletions(-) create mode 100644 .redwood/README.md rename web/src/{App.js => App.jsx} (100%) rename web/src/{Routes.js => Routes.jsx} (100%) diff --git a/.gitignore b/.gitignore index 8a66a2527..65854f73d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,8 @@ .DS_Store .env .netlify -.redwood +.redwood/* +!.redwood/README.md dev.db* dist dist-babel @@ -11,13 +12,7 @@ yarn-error.log web/public/mockServiceWorker.js web/types/graphql.d.ts api/types/graphql.d.ts -.pnp.* -.yarn/* -!.yarn/patches -!.yarn/plugins -!.yarn/releases -!.yarn/sdks -!.yarn/versions +api/src/lib/generateGraphiQLHeader.* .pnp.* .yarn/* !.yarn/patches diff --git a/.redwood/README.md b/.redwood/README.md new file mode 100644 index 000000000..f22b586a4 --- /dev/null +++ b/.redwood/README.md @@ -0,0 +1,44 @@ +# .redwood + +## What is this directory? + +Redwood uses this `.redwood` directory to store transitory data that aids in the smooth and convenient operation of your Redwood project. + +## Do I need to do anything with this directory? + +No. You shouldn't have to create, edit or delete anything in this directory in your day-to-day work with Redwood. + +You don't need to commit any other contents of this directory to your version control system. It's ignored by default. + +## What's in this directory? + +### Files + +| Name | Description | +| :---------------- | :------- | +| commandCache.json | This file contains mappings to assist the Redwood CLI in efficiently executing commands. | +| schema.graphql | This is the GraphQL schema which has been automatically generated from your Redwood project. | +| studio.db | The sqlite database used by the experimental `rw exp studio` feature. | +| telemetry.txt | Contains a unique ID used for telemetry. This value is rotated every 24 hours to protect your project's anonymity. | +| test.db | The sqlite database used when running tests. | + +### Directories + +| Name | Description | +| :---------- | :------- | +| locks | Stores temporary files that Redwood uses to keep track of the execution of async/background tasks between processes. | +| logs | Stores log files for background tasks such as update checking. | +| prebuild | Stores transpiled JavaScript that is generated as part of Redwood's build process. | +| telemetry | Stores the recent telemetry that the Redwood CLI has generated. You may inspect these files to see everything Redwood is anonymously collecting. | +| types | Stores the results of type generation. | +| updateCheck | Stores a file which contains the results of checking for Redwood updates. | + +We try to keep this README up to date but you may, from time to time, find other files or directories in this `.redwood` directory that have not yet been documented here. This is likely nothing to worry about but feel free to let us know and we'll update this list. + +### Telemetry + +RedwoodJS collects completely anonymous telemetry data about general usage. For transparency, that data is viewable in the respective directories and files. To learn more and manage your project's settings, visit [telemetry.redwoodjs.com](https://telemetry.redwoodjs.com). + +### Have any questions? + +Feel free to reach out to us in the [RedwoodJS Community](https://community.redwoodjs.com/) forum if you have any questions. diff --git a/api/src/directives/requireAuth/requireAuth.js b/api/src/directives/requireAuth/requireAuth.js index 9355e9f17..df6083b14 100644 --- a/api/src/directives/requireAuth/requireAuth.js +++ b/api/src/directives/requireAuth/requireAuth.js @@ -14,8 +14,7 @@ export const schema = gql` const validate = ({ directiveArgs }) => { const { roles } = directiveArgs - - applicationRequireAuth({ roles: roles }) + applicationRequireAuth({ roles }) } const requireAuth = createValidatorDirective(schema, validate) diff --git a/api/src/lib/logger.js b/api/src/lib/logger.js index be5dbf2aa..150a30976 100644 --- a/api/src/lib/logger.js +++ b/api/src/lib/logger.js @@ -4,13 +4,13 @@ import { createLogger } from '@redwoodjs/api/logger' * Creates a logger with RedwoodLoggerOptions * * These extend and override default LoggerOptions, - * can define a destination like a file or other supported pin log transport stream, - * and sets where or not to show the logger configuration settings (defaults to false) + * can define a destination like a file or other supported pino log transport stream, + * and sets whether or not to show the logger configuration settings (defaults to false) * * @param RedwoodLoggerOptions * * RedwoodLoggerOptions have - * @param {options} LoggerOptions - defines how to log, such as pretty printing, redaction, and format + * @param {options} LoggerOptions - defines how to log, such as redaction and format * @param {string | DestinationStream} destination - defines where to log, such as a transport stream or file * @param {boolean} showConfig - whether to display logger configuration on initialization */ diff --git a/web/package.json b/web/package.json index 6380e4e82..0034bd33b 100644 --- a/web/package.json +++ b/web/package.json @@ -7,13 +7,10 @@ "last 1 version" ], "production": [ - "defaults", - "not IE 11", - "not IE_Mob 11" + "defaults" ] }, "dependencies": { - "@redwoodjs/auth": "6.3.1", "@redwoodjs/auth-dbauth-web": "6.3.1", "@redwoodjs/forms": "6.3.1", "@redwoodjs/router": "6.3.1", diff --git a/web/public/README.md b/web/public/README.md index 6df2fa250..618395f02 100644 --- a/web/public/README.md +++ b/web/public/README.md @@ -1,5 +1,5 @@ # Static Assets -Use this folder to add static files directly to your app. All included files and folders will be copied directly into the `/dist` folder (created when Webpack builds for production). They will also be available during development when you run `yarn rw dev`. +Use this folder to add static files directly to your app. All included files and folders will be copied directly into the `/dist` folder (created when Vite builds for production). They will also be available during development when you run `yarn rw dev`. >Note: files will *not* hot reload while the development server is running. You'll need to manually stop/start to access file changes. ### Example Use @@ -12,14 +12,13 @@ and alt="Logo" /> ``` -Behind the scenes, we are using Webpack's ["copy-webpack-plugin"](https://github.com/webpack-contrib/copy-webpack-plugin). ## Best Practices -Because assets in this folder are bypassing the javascript module system, **this folder should be used sparingly** for assets such as favicons, robots.txt, manifests, libraries incompatible with Webpack, etc. +Because assets in this folder are bypassing the javascript module system, **this folder should be used sparingly** for assets such as favicons, robots.txt, manifests, libraries incompatible with Vite, etc. -In general, it's best to import files directly into a template, page, or component. This allows Webpack to include that file in the bundle, which ensures Webpack will correctly process and move assets into the distribution folder, providing error checks and correct paths along the way. +In general, it's best to import files directly into a template, page, or component. This allows Vite to include that file in the bundle when small enough, or to copy it over to the `dist` folder with a hash. -### Example Asset Import with Webpack +### Example Asset Import with Vite Instead of handling our logo image as a static file per the example above, we can do the following: ``` import React from "react" @@ -33,4 +32,4 @@ function Header() { export default Header ``` -Behind the scenes, we are using Webpack's ["file-loader"](https://webpack.js.org/loaders/file-loader/) and ["url-loader](https://webpack.js.org/loaders/url-loader/) (for files smaller than 10kb). +See Vite's docs for [static asset handling](https://vitejs.dev/guide/assets.html) diff --git a/web/src/App.js b/web/src/App.jsx similarity index 100% rename from web/src/App.js rename to web/src/App.jsx diff --git a/web/src/Routes.js b/web/src/Routes.jsx similarity index 100% rename from web/src/Routes.js rename to web/src/Routes.jsx diff --git a/yarn.lock b/yarn.lock index e7aea04cb..469248007 100644 --- a/yarn.lock +++ b/yarn.lock @@ -20328,7 +20328,6 @@ __metadata: version: 0.0.0-use.local resolution: "web@workspace:web" dependencies: - "@redwoodjs/auth": 6.3.1 "@redwoodjs/auth-dbauth-web": 6.3.1 "@redwoodjs/forms": 6.3.1 "@redwoodjs/router": 6.3.1