Skip to content

Commit

Permalink
chore: update files based on latest CRWA template (#103)
Browse files Browse the repository at this point in the history
The CRWA templated has changed in subtle ways since this repo was
initialized. This PR brings some of the files up to date.
  • Loading branch information
jtoar authored Sep 22, 2023
1 parent f303997 commit 6b54bf4
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 24 deletions.
11 changes: 3 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
.DS_Store
.env
.netlify
.redwood
.redwood/*
!.redwood/README.md
dev.db*
dist
dist-babel
Expand All @@ -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
Expand Down
44 changes: 44 additions & 0 deletions .redwood/README.md
Original file line number Diff line number Diff line change
@@ -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.
3 changes: 1 addition & 2 deletions api/src/directives/requireAuth/requireAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ export const schema = gql`

const validate = ({ directiveArgs }) => {
const { roles } = directiveArgs

applicationRequireAuth({ roles: roles })
applicationRequireAuth({ roles })
}

const requireAuth = createValidatorDirective(schema, validate)
Expand Down
6 changes: 3 additions & 3 deletions api/src/lib/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
5 changes: 1 addition & 4 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
11 changes: 5 additions & 6 deletions web/public/README.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -12,14 +12,13 @@ and
<img src="/static-files/my-logo.jpg"> 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"
Expand All @@ -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)
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6b54bf4

Please sign in to comment.