Skip to content

Commit

Permalink
Merge branch 'main' of github.com:redwoodjs/redwood into feature/prer…
Browse files Browse the repository at this point in the history
…ender-p1

* 'main' of github.com:redwoodjs/redwood:
  v0.25.0
  yarn rw prisma commands now show a little tip (redwoodjs#1772)
  FIx typo (redwoodjs#1779)
  Ensure all data is removed during the teardown step (redwoodjs#1714)
  [v0.25] revert to @prisma/cli; recreate yarn.lock (redwoodjs#1774)
  use prisma db push for test DB (redwoodjs#1768)
  Disable --version and -v for prisma alias. (redwoodjs#1767)
  Rebuild Prisma Client between upgrades (redwoodjs#1155)
  upgrade Prisma v2.16.1 (redwoodjs#1766)
  [v0.25] Remove warning if you scaffold a model with a relation (redwoodjs#1757)
  [v0.25] Scaffolded many-to-many relationship fixes (redwoodjs#1758)
  add forrest and kim-adeline; update all contribs (redwoodjs#1763)
  Run clean and then build the js.
  Fix: applying afterQuery in storybook mocks (redwoodjs#1740)
  restructure and update Deploy command and change Setup Deploy command template [breaking] (redwoodjs#1747)
  Fixes prisma command when path has spaces
  Make tutorial work with workspaces.
  Add "packages/*" to the template.
  • Loading branch information
dac09 committed Feb 12, 2021
2 parents 3468fd0 + 5e354a0 commit 200d212
Show file tree
Hide file tree
Showing 50 changed files with 758 additions and 420 deletions.
116 changes: 62 additions & 54 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lerna.json
@@ -1,5 +1,5 @@
{
"version": "0.24.0",
"version": "0.25.0",
"npmClient": "yarn",
"useWorkspaces": true,
"command": {
Expand Down
2 changes: 1 addition & 1 deletion packages/api-server/package.json
@@ -1,7 +1,7 @@
{
"name": "@redwoodjs/api-server",
"description": "Redwood's HTTP server for Serverless Functions",
"version": "0.24.0",
"version": "0.25.0",
"bin": {
"api-server": "./dist/index.js"
},
Expand Down
10 changes: 5 additions & 5 deletions packages/api/package.json
@@ -1,6 +1,6 @@
{
"name": "@redwoodjs/api",
"version": "0.24.0",
"version": "0.25.0",
"files": [
"dist"
],
Expand All @@ -9,8 +9,8 @@
"license": "MIT",
"dependencies": {
"@graphql-tools/merge": "^6.2.4",
"@prisma/client": "2.16.0",
"@redwoodjs/internal": "^0.24.0",
"@prisma/client": "2.16.1",
"@redwoodjs/internal": "^0.25.0",
"apollo-server-lambda": "2.18.2",
"core-js": "3.6.5",
"graphql": "^15.3.0",
Expand All @@ -22,8 +22,8 @@
"lodash.omitby": "^4.6.0"
},
"devDependencies": {
"@redwoodjs/auth": "^0.24.0",
"@redwoodjs/dev-server": "^0.24.0",
"@redwoodjs/auth": "^0.25.0",
"@redwoodjs/dev-server": "^0.25.0",
"@types/jsonwebtoken": "^8.3.9",
"@types/lodash.merge": "^4.6.6",
"@types/lodash.omitby": "^4.6.6"
Expand Down
2 changes: 1 addition & 1 deletion packages/auth/package.json
@@ -1,6 +1,6 @@
{
"name": "@redwoodjs/auth",
"version": "0.24.0",
"version": "0.25.0",
"files": [
"dist"
],
Expand Down
10 changes: 5 additions & 5 deletions packages/cli/package.json
@@ -1,7 +1,7 @@
{
"name": "@redwoodjs/cli",
"description": "The Redwood Command Line",
"version": "0.24.0",
"version": "0.25.0",
"license": "MIT",
"bin": {
"redwood": "./dist/index.js",
Expand All @@ -13,10 +13,10 @@
"dist"
],
"dependencies": {
"@prisma/sdk": "2.16.0",
"@redwoodjs/internal": "^0.24.0",
"@redwoodjs/prerender": "^0.24.0",
"@redwoodjs/structure": "^0.24.0",
"@prisma/sdk": "2.16.1",
"@redwoodjs/internal": "^0.25.0",
"@redwoodjs/prerender": "^0.25.0",
"@redwoodjs/structure": "^0.25.0",
"boxen": "^4.2.0",
"camelcase": "^6.0.0",
"chalk": "^4.1.0",
Expand Down
8 changes: 4 additions & 4 deletions packages/cli/src/commands/deploy.js
@@ -1,14 +1,14 @@
export const command = 'deploy <command>'
export const command = 'deploy <target>'
export const description = 'Deploy your Redwood project'
import terminalLink from 'terminal-link'

export const builder = (yargs) =>
yargs
.commandDir('./deploy', { recurse: true })
.commandDir('./deploy', { recurse: false })
.demandCommand()
.epilogue(
`Also see the ${terminalLink(
'Redwood CLI Reference',
'https://redwoodjs.com/reference/command-line-interface#deploy'
)}`
'https://redwoodjs.com/docs/cli-commands#deploy'
)}\n`
)
@@ -1,18 +1,18 @@
export const preRequisites = [
{
title: 'Checking if serverless is installed...',
title: 'Checking if Serverless framework is installed...',
command: ['serverless', ['--version']],
errorMessage: [
'Looks like serverless is not installed.',
'Please follow the steps at https://www.serverless.com/framework/docs/providers/aws/guide/installation/ to install serverless.',
'Looks like Serverless is not installed.',
'Please follow the steps at https://www.serverless.com/framework/docs/providers/aws/guide/installation/ to install Serverless.',
],
},
{
title: 'Checking if @netlify/zip-it-and-ship-it is installed...',
command: ['yarn', ['zip-it-and-ship-it', '--version']],
errorMessage: [
'Looks like @netlify/zip-it-and-ship-it is not installed.',
'Either run `yarn rw g deploy aws_serverless` or add it seperately as a dev dependency in the api workspace.',
'Either run `yarn rw setup aws-serverless` or add it seperately as a dev dependency in the api workspace.',
],
},
]
Expand Down
Expand Up @@ -8,31 +8,38 @@ import terminalLink from 'terminal-link'
import { getPaths } from 'src/lib'
import c from 'src/lib/colors'

export const command = 'api <provider>'
export const description = 'Deploy the API using the selected provider'
export const command = 'aws [provider]'
export const description = 'Deploy to AWS using the selected provider'
export const builder = (yargs) => {
const SUPPORTED_PROVIDERS = fs
.readdirSync(path.resolve(__dirname, 'providers'))
.readdirSync(path.resolve(__dirname, 'aws-providers'))
.map((file) => path.basename(file, '.js'))
.filter((file) => file !== 'README.md')

yargs
.positional('provider', {
choices: SUPPORTED_PROVIDERS,
description: 'API Deploy provider to configure',
default: 'serverless',
description: 'AWS Deploy provider to configure',
type: 'string',
})
.option('side', {
describe: 'which Side(s) to deploy',
choices: ['api'],
default: 'api',
type: 'array',
})
.epilogue(
`Also see the ${terminalLink(
'Redwood CLI Reference',
'https://redwoodjs.com/reference/command-line-interface#deploy-api'
)}`
'https://redwoodjs.com/docs/cli-commands#deploy'
)}\n`
)
}

export const handler = async ({ provider }) => {
const BASE_DIR = getPaths().base
const providerData = await import(`./providers/${provider}`)
const providerData = await import(`./aws-providers/${provider}`)

const tasks = new Listr(
[
Expand Down
53 changes: 53 additions & 0 deletions packages/cli/src/commands/deploy/helpers/helpers.js
@@ -0,0 +1,53 @@
import execa from 'execa'
import terminalLink from 'terminal-link'

import { getPaths } from '@redwoodjs/internal'

export const deployBuilder = (yargs) => {
yargs
.option('build', {
description: 'Build for production',
type: 'boolean',
default: 'true',
})
.option('prisma', {
description: 'Apply database migrations',
type: 'boolean',
default: 'true',
})
.option('data-migrate', {
description: 'Migrate the data in your database',
type: 'boolean',
default: 'true',
alias: 'dm',
})
.epilogue(
`For more commands, options, and examples, see ${terminalLink(
'Redwood CLI Reference',
'https://redwoodjs.com/docs/cli-commands#deploy'
)}`
)
}

export const deployHandler = async ({ build, prisma, dm: dataMigrate }) => {
const paths = getPaths()

let commandSet = []
if (build) {
commandSet.push('yarn rw build')
}
if (prisma) {
commandSet.push('yarn rw prisma migrate deploy')
}
if (dataMigrate) {
commandSet.push('yarn rw dataMigrate up')
}

execa(commandSet.join(' && '), {
shell: true,
stdio: 'inherit',
cwd: paths.base,
extendEnv: true,
cleanup: true,
})
}
8 changes: 8 additions & 0 deletions packages/cli/src/commands/deploy/netlify.js
@@ -0,0 +1,8 @@
import { deployBuilder, deployHandler } from './helpers/helpers'

export const command = 'netlify [...commands]'
export const description = 'Build command for Netlify deploy'

export const builder = (yargs) => deployBuilder(yargs)

export const handler = deployHandler
8 changes: 8 additions & 0 deletions packages/cli/src/commands/deploy/vercel.js
@@ -0,0 +1,8 @@
import { deployBuilder, deployHandler } from './helpers/helpers'

export const command = 'vercel [...commands]'
export const description = 'Build command for Vercel deploy'

export const builder = (yargs) => deployBuilder(yargs)

export const handler = deployHandler
23 changes: 1 addition & 22 deletions packages/cli/src/commands/generate/scaffold/scaffold.js
@@ -1,9 +1,7 @@
import fs from 'fs'
import path from 'path'

import boxen from 'boxen'
import camelcase from 'camelcase'
import chalk from 'chalk'
import humanize from 'humanize-string'
import Listr from 'listr'
import { paramCase } from 'param-case'
Expand Down Expand Up @@ -449,29 +447,10 @@ export const handler = async ({
javascript,
}) => {
const { model, path } = splitPathAndModel(modelArg)

const t = tasks({ model, path, force, typescript, javascript })
const schema = await getSchema(pascalcase(pluralize.singular(model)))
const line1 =
chalk.bold.yellow('WARNING') +
`: Because the data model "${pascalcase(model)}" contains a`
const line2 = 'Prisma @relation, the generated CRUD code and test must be'
const line3 =
'manually modified to work correctly. See this doc for more info:'
const line4 = chalk.underline.blue(
'https://redwoodjs.com/docs/schema-relations'
)

try {
await t.run()
if (relationsForModel(schema).length) {
console.log(
boxen(line1 + '\n' + line2 + '\n' + line3 + '\n' + line4, {
padding: 1,
margin: 1,
borderStyle: 'single',
})
)
}
} catch (e) {
console.log(c.error(e.message))
}
Expand Down
25 changes: 24 additions & 1 deletion packages/cli/src/commands/generate/sdl/sdl.js
@@ -1,6 +1,8 @@
import path from 'path'

import boxen from 'boxen'
import camelcase from 'camelcase'
import chalk from 'chalk'
import Listr from 'listr'
import pascalcase from 'pascalcase'
import pluralize from 'pluralize'
Expand All @@ -22,6 +24,26 @@ import { files as serviceFiles } from '../service/service'

const IGNORE_FIELDS_FOR_INPUT = ['id', 'createdAt', 'updatedAt']

const missingIdConsoleMessage = () => {
const line1 =
chalk.bold.yellow('WARNING') +
': Cannot generate CRUD SDL without an `@id` database column.'
const line2 = 'If you are trying to generate for a many-to-many join table '
const line3 = "you'll need to update your schema definition to include"
const line4 = 'an `@id` column. Read more here: '
const line5 = chalk.underline.blue(
'https://redwoodjs.com/docs/schema-relations'
)

console.error(
boxen(line1 + '\n\n' + line2 + '\n' + line3 + '\n' + line4 + '\n' + line5, {
padding: 1,
margin: { top: 1, bottom: 3, right: 1, left: 2 },
borderStyle: 'single',
})
)
}

const modelFieldToSDL = (field, required = true, types = {}) => {
if (Object.entries(types).length) {
field.type =
Expand Down Expand Up @@ -71,7 +93,8 @@ const idType = (model, crud) => {

const idField = model.fields.find((field) => field.isId)
if (!idField) {
throw new Error('Cannot generate CRUD SDL without an `id` database column')
missingIdConsoleMessage()
throw new Error('Failed: Could not generate SDL')
}
return idField.type
}
Expand Down

0 comments on commit 200d212

Please sign in to comment.