diff --git a/.gitignore b/.gitignore index bc27e662a583..d22d1b0f40a9 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,3 @@ node_modules dist lerna-debug.log yarn-error.log - -packages/hammer-api/graphql diff --git a/LICENSE b/LICENSE index c3dd79aebf98..f943bbba4cb0 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2019 hammerframework +Copyright (c) 2020 Redwood Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/packages/api/src/makeMergedSchema.ts b/packages/api/src/makeMergedSchema.ts index eff8afeb561e..e8ba0c4cc30e 100644 --- a/packages/api/src/makeMergedSchema.ts +++ b/packages/api/src/makeMergedSchema.ts @@ -27,12 +27,12 @@ export const makeMergedSchema = ( scalar Time scalar DateTime - type HammerFramework { + type Redwood { version: String } type Query { - hammerframework: HammerFramework + redwood: Redwood } ` @@ -41,7 +41,7 @@ export const makeMergedSchema = ( Time: GraphQLTime, DateTime: GraphQLDateTime, Query: { - hammerframework: () => ({ + redwood: () => ({ version: '0.0.0', }), }, diff --git a/packages/cli/src/commands/Dev/Dev.js b/packages/cli/src/commands/Dev/Dev.js index 75da84c661b4..29b4830cae28 100644 --- a/packages/cli/src/commands/Dev/Dev.js +++ b/packages/cli/src/commands/Dev/Dev.js @@ -3,20 +3,20 @@ // $ redwood dev import concurrently from 'concurrently' -import { getHammerBaseDir } from '@redwoodjs/core' +import { getBaseDir } from '@redwoodjs/core' const Dev = () => { - const baseDir = getHammerBaseDir() + const baseDir = getBaseDir() concurrently( [ { - command: `cd ${baseDir}/web && yarn webpack-dev-server --config ./config/webpack.dev.js`, + command: `cd ${baseDir}/web && yarn dev`, name: 'web', prefixColor: 'yellow', }, { - command: `cd ${baseDir}/api && yarn hammer-dev-server`, + command: `cd ${baseDir}/api && yarn dev`, name: 'api', prefixColor: 'green', }, diff --git a/packages/cli/src/commands/Generate/Generate.js b/packages/cli/src/commands/Generate/Generate.js index fa6f5186cb10..95c46bbaad9f 100644 --- a/packages/cli/src/commands/Generate/Generate.js +++ b/packages/cli/src/commands/Generate/Generate.js @@ -2,7 +2,7 @@ import path from 'path' import React from 'react' import { Box, Text, Color } from 'ink' -import { getHammerBaseDir } from '@redwoodjs/core' +import { getBaseDir } from '@redwoodjs/core' import { readFile, writeFile, bytes } from 'src/lib' @@ -15,17 +15,17 @@ import sdl from './generators/sdl' import service from './generators/service' const GENERATORS = [cell, component, layout, page, scaffold, sdl, service] -const ROUTES_PATH = path.join(getHammerBaseDir(), 'web', 'src', 'Routes.js') +const ROUTES_PATH = path.join(getBaseDir(), 'web', 'src', 'Routes.js') const Generate = ({ args, generators = GENERATORS, fileWriter = writeFile, }) => { - if (!getHammerBaseDir()) { + if (!getBaseDir()) { return ( - The `generate` command has to be run in your redwood project directory. + The `generate` command has to be run in your Redwood project directory. ) } @@ -34,7 +34,7 @@ const Generate = ({ return Object.keys(files).map((filename) => { const contents = files[filename] try { - fileWriter(path.join(getHammerBaseDir(), filename), contents) + fileWriter(path.join(getBaseDir(), filename), contents) return ( Wrote {filename} {bytes(contents)} bytes diff --git a/packages/cli/src/commands/Generate/README.md b/packages/cli/src/commands/Generate/README.md index 7571035b1272..fb91fe0367cc 100644 --- a/packages/cli/src/commands/Generate/README.md +++ b/packages/cli/src/commands/Generate/README.md @@ -2,7 +2,7 @@ Generators go in `src/commands/Generate/generators` and should be named for the generate command that invokes them (not required). For example, for page generator invoked with: - hammer generate page foo + redwood generate page foo you would create `src/commands/Generate/generators/page.js`. The file name does not have to match the generator command (the name is pulled from the object returned when importing the generator) but it is clearest to have the command and the name match. @@ -22,9 +22,9 @@ The generator must export a default hash containing the following keys: | `name` | The name of the generator | Yes | | `command` | The command line input that triggers the generator | Yes | | `description` | Text that is shown on the generator's help message | Yes | -| `files` | A function which accepts the array of arguments given to the `hammer` command. Returns an object containing filenames and contents of those files to be created | No | -| `routes` | A function which accepts the array of arguments given to the `hammer` command. Returns an array of `` tags to append to the Routes.js file | No | -| `generate` | A function which accepts the array of arguments given to the `hammer` command. Returns an array of an array of arguments that would be passed to the Generate function in the same order the commands would be sent in from a command line call to `hammer generate` | No | +| `files` | A function which accepts the array of arguments given to the `redwood` command. Returns an object containing filenames and contents of those files to be created | No | +| `routes` | A function which accepts the array of arguments given to the `redwood` command. Returns an array of `` tags to append to the Routes.js file | No | +| `generate` | A function which accepts the array of arguments given to the `redwood` command. Returns an array of an array of arguments that would be passed to the Generate function in the same order the commands would be sent in from a command line call to `redwood generate` | No | An example generator's return: @@ -32,7 +32,7 @@ An example generator's return: { name: "Page", command: "page", - description: "Generates a Hammer page component", + description: "Generates a page component", files: name => ({ 'pages/FooPage/FooPage.js': 'const FooPage = () => { ... }' }), diff --git a/packages/cli/src/commands/Generate/generators/cell.js b/packages/cli/src/commands/Generate/generators/cell.js index dcab7b4c86d1..f906aa2b48f6 100644 --- a/packages/cli/src/commands/Generate/generators/cell.js +++ b/packages/cli/src/commands/Generate/generators/cell.js @@ -24,6 +24,6 @@ const files = (args) => { export default { name: 'Cell', command: 'cell', - description: 'Generates a Hammer cell component', + description: 'Generates a cell component', files: (args) => files(args), } diff --git a/packages/cli/src/commands/Generate/generators/layout.js b/packages/cli/src/commands/Generate/generators/layout.js index 37c1d9db00ad..4843f841042e 100644 --- a/packages/cli/src/commands/Generate/generators/layout.js +++ b/packages/cli/src/commands/Generate/generators/layout.js @@ -21,6 +21,6 @@ const files = (args) => { export default { name: 'Layout', command: 'layout', - description: 'Generates a Hammer layout component', + description: 'Generates a layout component', files: (args) => files(args), } diff --git a/packages/cli/src/commands/Generate/generators/page.js b/packages/cli/src/commands/Generate/generators/page.js index 5444d7b06363..757b50f84a90 100644 --- a/packages/cli/src/commands/Generate/generators/page.js +++ b/packages/cli/src/commands/Generate/generators/page.js @@ -31,7 +31,7 @@ const routes = ([pageName, ..._rest]) => { export default { name: 'Page', command: 'page', - description: 'Generates a Hammer page component', + description: 'Generates a page component', files: (args) => files(args), routes: (args) => routes(args), } diff --git a/packages/cli/src/commands/Generate/generators/sdl.js b/packages/cli/src/commands/Generate/generators/sdl.js index ee6199ebb2b8..91100505762e 100644 --- a/packages/cli/src/commands/Generate/generators/sdl.js +++ b/packages/cli/src/commands/Generate/generators/sdl.js @@ -77,7 +77,7 @@ const generate = (args) => { export default { name: 'SDL', command: 'sdl', - description: 'Generates a GraphQL SDL file and Hammer service object', + description: 'Generates a GraphQL SDL file and service object', files: async (args) => await files(args), generate: (args) => generate(args), } diff --git a/packages/cli/src/commands/Generate/generators/service.js b/packages/cli/src/commands/Generate/generators/service.js index c6d190304c30..91c6e31c44ec 100644 --- a/packages/cli/src/commands/Generate/generators/service.js +++ b/packages/cli/src/commands/Generate/generators/service.js @@ -24,6 +24,6 @@ const files = (args) => { export default { name: 'Service', command: 'service', - description: 'Generates a Hammer service object', + description: 'Generates a service object', files: (args) => files(args), } diff --git a/packages/cli/src/components/Header.js b/packages/cli/src/components/Header.js index 9e1dd112387c..7935f74446b1 100644 --- a/packages/cli/src/components/Header.js +++ b/packages/cli/src/components/Header.js @@ -6,7 +6,7 @@ import { version } from '../../package.json' export default (props) => ( - ⚒ Hammer - Build something. (https://example.org) + Redwood - Build something. (https://redwoodjs.com) {' '} | v{version} diff --git a/packages/cli/src/lib/index.js b/packages/cli/src/lib/index.js index e51328625f99..b6ee7803463c 100644 --- a/packages/cli/src/lib/index.js +++ b/packages/cli/src/lib/index.js @@ -3,7 +3,6 @@ import path from 'path' import requireDir from 'require-dir' import parse from 'yargs-parser' -import { getHammerConfig } from '@redwoodjs/core' import lodash from 'lodash/string' export const templateRoot = path.join( @@ -43,8 +42,6 @@ export const writeFile = ( export const bytes = (contents) => Buffer.byteLength(contents, 'utf8') -export const hammerBaseDir = () => getHammerConfig().baseDir - const validateCommandExports = ({ commandProps, ...rest }) => { if (typeof rest.default !== 'function') { throw 'you must export a default function' diff --git a/packages/core/README.md b/packages/core/README.md index 45f4604661ab..b69688a34b3e 100644 --- a/packages/core/README.md +++ b/packages/core/README.md @@ -1,5 +1,5 @@ -# The Hammer Core +# The Core -This package searches for and parses the `hammer.toml` configuration -file. The `hammer.toml` file is used to designate the base -directory of a hammer app. +This package searches for and parses the `redwood.toml` configuration +file. The `redwood.toml` file is used to designate the base +directory of a Redwood app. diff --git a/packages/core/src/main.ts b/packages/core/src/main.ts index 46a727a45b76..545b60b1ad0e 100644 --- a/packages/core/src/main.ts +++ b/packages/core/src/main.ts @@ -4,25 +4,23 @@ import path from 'path' import findUp from 'findup-sync' import toml from 'toml' -const HAMMER_CONFIG_FILE = 'hammer.toml' +const CONFIG_FILE_NAME = 'redwood.toml' -export const getHammerConfigPath = (): string => { - const configPath = findUp(HAMMER_CONFIG_FILE) +export const getConfigPath = (): string => { + const configPath = findUp(CONFIG_FILE_NAME) if (!configPath) { throw new Error( - `Could not find a "${HAMMER_CONFIG_FILE}" file, are you in a hammer project?` + `Could not find a "${CONFIG_FILE_NAME}" file, are you sure you're in a Redwood project?` ) } return configPath } -export const getHammerBaseDir = ( - configPath: string = getHammerConfigPath() -): string => { +export const getBaseDir = (configPath: string = getConfigPath()): string => { return path.dirname(configPath) } -export interface HammerConfig { +export interface ConfigInterface { baseDir: string web: { port: number @@ -38,13 +36,13 @@ export interface HammerConfig { } } -export const getHammerConfig = (): HammerConfig => { - const configPath = getHammerConfigPath() - const baseDir = getHammerBaseDir(configPath) +export const getConfig = (): ConfigInterface => { + const configPath = getConfigPath() + const baseDir = getBaseDir(configPath) try { const config = toml.parse( fs.readFileSync(configPath, 'utf8') - ) as HammerConfig + ) as ConfigInterface return { ...config, diff --git a/packages/dev-server/README.md b/packages/dev-server/README.md index 874fbfd771fb..037df17813dc 100644 --- a/packages/dev-server/README.md +++ b/packages/dev-server/README.md @@ -1,7 +1,7 @@ # The Development Server -The hamer dev server looks for "lambda functions" in the directory -(default: `./api/src/functions`) specified in your `hammer.toml` +The dev server looks for "lambda functions" in the directory +(default: `./api/src/functions`) specified by your `redwood.toml` configuration file. Each lambda function is mapped to a URI based on their filename, as @@ -12,7 +12,7 @@ The `./api` directory is watched for modifications, when they are detected the modules are reimported. A lambda function must export a `handler`. You can execute the -supplied callback function: +supplied callback function to return a response: ```js export const handler = (event, context, callback) => { diff --git a/packages/dev-server/src/main.ts b/packages/dev-server/src/main.ts index d1cace680611..67504a39325b 100755 --- a/packages/dev-server/src/main.ts +++ b/packages/dev-server/src/main.ts @@ -3,7 +3,7 @@ import path from 'path' import { Response, Request } from 'express' import { APIGatewayProxyResult, APIGatewayProxyEvent } from 'aws-lambda' -import { getHammerConfig } from '@redwoodjs/core' +import { getConfig } from '@redwoodjs/core' import express from 'express' // @ts-ignore import expressLogging from 'express-logging' @@ -15,30 +15,30 @@ import chokidar from 'chokidar' // @ts-ignore import babelRegister from '@babel/register' -const hammerConfig = getHammerConfig() -const hammerApiDir = path.join(hammerConfig.baseDir, 'api') +const config = getConfig() +const API_DIR = path.join(config.baseDir, 'api') babelRegister({ - extends: path.join(hammerApiDir, '.babelrc.js'), + extends: path.join(API_DIR, '.babelrc.js'), extensions: ['.js', '.ts'], - only: [hammerApiDir], + only: [API_DIR], ignore: ['node_modules'], }) // TODO: Convert to yargs. args - .option('port', '', hammerConfig.api.port) + .option('port', '', config.api.port) .option( 'path', 'The path to your lambda functions', - hammerConfig.api.paths.functions + config.api.paths.functions ) const { port: PORT, path: PATH } = args.parse(process.argv) const HOSTNAME = `http://localhost:${PORT}` const showHeader = (lambdas: Record) => { console.log(`◌ Listening on ${HOSTNAME}`) - console.log(`◌ Watching ${hammerApiDir}`) + console.log(`◌ Watching ${API_DIR}`) console.log('\nNow serving\n') console.log( Object.keys(lambdas) @@ -190,7 +190,7 @@ const startServer = () => app.listen(PORT, () => showHeader(lambdaFunctions)) const server = startServer() server.setTimeout(10 * 1000) -const watcher = chokidar.watch(hammerApiDir, { +const watcher = chokidar.watch(API_DIR, { ignored: (path: string) => path.includes('node_modules'), }) diff --git a/packages/eslint-config/index.js b/packages/eslint-config/index.js index bf611b35fc35..b28aa35d0eb0 100644 --- a/packages/eslint-config/index.js +++ b/packages/eslint-config/index.js @@ -1,5 +1,4 @@ -// -// Hammer's ESLint configuration is a mixture between ESLint's recommended +// Our ESLint configuration is a mixture between ESLint's recommended // rules [^1], React's recommended rules [^2], and a bit of our own stylistic // flair: // - no semicolons @@ -46,7 +45,7 @@ module.exports = { globals: { gql: 'readonly', React: 'readonly', - __HAMMER__: 'readonly', + __REDWOOD__: 'readonly', }, rules: { 'prettier/prettier': 'error', diff --git a/packages/router/src/index.js b/packages/router/src/index.js index eacc426e5c0f..f99295bf3a3c 100644 --- a/packages/router/src/index.js +++ b/packages/router/src/index.js @@ -1,4 +1,4 @@ -// This is Hammer's routing mechanism. It takes inspiration from both Ruby on +// This is Redwood's routing mechanism. It takes inspiration from both Ruby on // Rails' routing approach and from both React Router and Reach Router (the // latter of which has closely inspired some of this code). diff --git a/packages/scripts/config/webpack.config.js b/packages/scripts/config/webpack.config.js index d8bfa43e2f9f..a4486ff98ab5 100644 --- a/packages/scripts/config/webpack.config.js +++ b/packages/scripts/config/webpack.config.js @@ -7,10 +7,10 @@ const DirectoryNamedWebpackPlugin = require('directory-named-webpack-plugin') const MiniCssExtractPlugin = require('mini-css-extract-plugin') const FaviconsWebpackPlugin = require('favicons-webpack-plugin') const Dotenv = require('dotenv-webpack') -const { getHammerConfig } = require('@redwoodjs/core') +const { getConfig } = require('@redwoodjs/core') -const hammerConfig = getHammerConfig() -const BASE_DIR = hammerConfig.baseDir +const config = getConfig() +const BASE_DIR = config.baseDir // I've borrowed and learnt extensively from the `create-react-app` // repo: https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/config/webpack.config.js @@ -76,9 +76,7 @@ module.exports = (webpackEnv) => { gql: ['@redwoodjs/web', 'gql'], }), new webpack.DefinePlugin({ - '__HAMMER__.apiProxyPath': JSON.stringify( - hammerConfig.web.apiProxyPath - ), + '__REDWOOD__.apiProxyPath': JSON.stringify(config.web.apiProxyPath), __filename: webpack.DefinePlugin.runtimeValue((runtimeValue) => { // absolute path of imported file return JSON.stringify(runtimeValue.module.resource) diff --git a/packages/scripts/config/webpackDevServer.config.js b/packages/scripts/config/webpackDevServer.config.js index da7c691f9bc3..72972812245b 100644 --- a/packages/scripts/config/webpackDevServer.config.js +++ b/packages/scripts/config/webpackDevServer.config.js @@ -1,11 +1,11 @@ /* eslint-disable import/no-extraneous-dependencies */ const merge = require('webpack-merge') const escapeRegExp = require('lodash.escaperegexp') -const { getHammerConfig } = require('@redwoodjs/core') +const { getConfig } = require('@redwoodjs/core') const webpackConfig = require('./webpack.config.js') -const hammerConfig = getHammerConfig() +const config = getConfig() module.exports = merge(webpackConfig('development'), { devServer: { @@ -18,12 +18,12 @@ module.exports = merge(webpackConfig('development'), { injectClient: false, quiet: true, historyApiFallback: true, - port: hammerConfig.web.port, + port: config.web.port, proxy: { - [hammerConfig.web.apiProxyPath]: { - target: `http://localhost:${hammerConfig.api.port}`, + [config.web.apiProxyPath]: { + target: `http://localhost:${config.api.port}`, pathRewrite: { - [`^${escapeRegExp(hammerConfig.web.apiProxyPath)}`]: '', + [`^${escapeRegExp(config.web.apiProxyPath)}`]: '', }, }, }, diff --git a/packages/web/src/HammerProvider.js b/packages/web/src/RedwoodProvider.js similarity index 83% rename from packages/web/src/HammerProvider.js rename to packages/web/src/RedwoodProvider.js index 9758c1327dca..9153184a3185 100644 --- a/packages/web/src/HammerProvider.js +++ b/packages/web/src/RedwoodProvider.js @@ -7,7 +7,7 @@ export const useAuth = () => { return USE_AUTH() } -const HammerProvider = ({ auth = {}, children }) => { +const RedwoodProvider = ({ auth = {}, children }) => { const { AuthProvider = React.Fragment, GraphQLProvider = RealGraphQLProvider, @@ -21,7 +21,7 @@ const HammerProvider = ({ auth = {}, children }) => { ) } -HammerProvider.propTypes = { +RedwoodProvider.propTypes = { auth: PropTypes.shape({ AuthProvider: PropTypes.func.isRequired, useAuth: PropTypes.func.isRequired, @@ -29,4 +29,4 @@ HammerProvider.propTypes = { }), } -export default HammerProvider +export default RedwoodProvider diff --git a/packages/web/src/graphql/index.js b/packages/web/src/graphql/index.js index aee25335410b..b09b518cc1c8 100644 --- a/packages/web/src/graphql/index.js +++ b/packages/web/src/graphql/index.js @@ -4,7 +4,7 @@ import { ApolloProvider } from '@apollo/react-hooks' export { withCell } from './withCell' const DEFAULT_CLIENT_CONFIG = { - uri: `${__HAMMER__.apiProxyPath}/graphql`, + uri: `${__REDWOOD__.apiProxyPath}/graphql`, } export const createGraphQLClient = (config) => { diff --git a/packages/web/src/index.js b/packages/web/src/index.js index ec560e580c29..154ecd2aed66 100644 --- a/packages/web/src/index.js +++ b/packages/web/src/index.js @@ -1,4 +1,4 @@ -export { default as HammerProvider, useAuth } from './HammerProvider' +export { default as RedwoodProvider, useAuth } from './RedwoodProvider' export { default as gql } from 'graphql-tag' export * from './graphql'