Skip to content

Commit

Permalink
fix: setup issues
Browse files Browse the repository at this point in the history
  • Loading branch information
arpowers committed Mar 19, 2020
1 parent 3a907f7 commit 5c88c3c
Show file tree
Hide file tree
Showing 26 changed files with 96 additions and 117 deletions.
12 changes: 0 additions & 12 deletions @factor/api/server.ts
Expand Up @@ -11,18 +11,6 @@ export const setup = (): void => {
const url = productionUrl()

if (!url) {
pushToFilter({
key: "appUrl",
hook: "setup-needed",
item: {
title: "Production Url",
value:
"The production URL setting is missing. This is needed for email and other tools",
file: ".env",
name: "FACTOR_URL"
}
})

pushToFilter({
key: "appUrl",
hook: "cli-add-setup",
Expand Down
2 changes: 1 addition & 1 deletion @factor/cli/cli.ts
Expand Up @@ -91,7 +91,7 @@ export const runCommand = async (options: CommandOptions): Promise<void> => {
* Make sure all package dependencies are installed and updated
*/
if (install && !skipVerifyDeps) {
await bar.update({ percent: 25, msg: `checking dependencies (${getCliExecutor()})` })
await bar.update({ percent: 25, msg: `checking dependencies with ${getCliExecutor()}` })

const verifyDepProcess = execa(getCliExecutor(), ["install"])
await verifyDepProcess
Expand Down
17 changes: 7 additions & 10 deletions @factor/cli/setup.ts
Expand Up @@ -18,7 +18,6 @@ import inquirer, { Answers } from "inquirer"
import json2yaml from "json2yaml"
import { FactorPackageJson } from "@factor/cli/types"

import { getCliExecutor } from "./util"
export interface SetupCliConfig {
name: string;
value: string;
Expand Down Expand Up @@ -58,7 +57,7 @@ export const logNotices = (): void => {
if (notices.length > 0) {
log.log()
notices.forEach((_: string) => {
log.info(chalk.bold(_))
log.info(typeof _ == "string" ? chalk.bold(_) : _)
})
log.log()
}
Expand Down Expand Up @@ -169,14 +168,6 @@ export const logSetupNeeded = (command = ""): void => {
const lines = setupNeeded.map((_: { title: string; value: string }) => {
return { title: _.title, value: _.value, indent: true }
})
if (process.env.FACTOR_COMMAND !== "setup") {
const cmd = getCliExecutor()
lines.push({
title: `Run '${cmd == "npm" ? "npx" : cmd} factor setup'`,
value: "",
indent: false
})
}

log.formatted({ title: "Setup Needed", lines, color: "cyan" })
}
Expand Down Expand Up @@ -218,12 +209,18 @@ export const writeFiles = (
}

fs.writeFileSync(configFile, JSON.stringify(packageJson, null, " "))

// In case the built file is used later in process
delete require.cache[configFile]
}

if (file == "private") {
const sec = deepMerge([privateConfig, values])

fs.writeFileSync(secretsFile, envfile.stringifySync(sec))

// In case the built file is used later in process
delete require.cache[secretsFile]
}
}

Expand Down
2 changes: 1 addition & 1 deletion @factor/cli/util.ts
Expand Up @@ -67,7 +67,7 @@ export const serverInfo = async ({

lines.push(`Running in ${chalk.bold(NODE_ENV)} mode`)
if (command && ["dev", "serve", "start"].includes(command)) {
lines.push(`Serving locally at ${chalk.cyan(localhostUrl())}`)
lines.push(`Serving at ${chalk.cyan(localhostUrl())}`)
}

getLatestVersion()
Expand Down
45 changes: 12 additions & 33 deletions @factor/create-factor-app/saofile.js
Expand Up @@ -17,25 +17,8 @@ const config = {
prompts: [
{
name: "name",
message: "What's the name of your app?",
default: "{outFolder}"
},
{
name: "description",
message: "... and a quick description?",
default: `My ${superb.random()} Factor project`,
when: answers => !config.isUnitTest(answers)
},
{
name: "email",
type: "string",
message: "Admin user email address?",
default: "{gitUser.email}",
when: answers => !config.isUnitTest(answers),
validate: v => {
const re = /^(([^\s"(),.:;<>@[\\\]]+(\.[^\s"(),.:;<>@[\\\]]+)*)|(".+"))@((\[(?:\d{1,3}\.){3}\d{1,3}])|(([\d-AZa-z-]+\.)+[A-Za-z]{2,}))$/
return re.test(v) ? true : "Enter a valid email address"
}
message: "Project name?",
default: `${superb.random()} project`
}
],
isUnitTest(answers) {
Expand Down Expand Up @@ -100,17 +83,17 @@ const config = {

return actions
},
async diagnostic({ email }) {
async diagnostic({ id }) {
try {
await axios.get(
`https://factor.dev/__track_event__?event=factorInstall&action=createFactorApp&label=${email}`
`https://factor.dev/__track_event__?event=factorInstall&action=createFactorApp&label=${id}`
)
} catch (error) {
/* silence */
}
},
async completed() {
config.diagnostic({ email: answers.email })
config.diagnostic({ id: answers.name })

this.gitInit()

Expand All @@ -134,14 +117,15 @@ const config = {
}
}

const runner = this.npmClient == "npm" ? "npx" : "yarn"
console.log()
console.log()
console.log(this.chalk.bold(` ${figures.tick} Ready! Now start your dev server:\n`))
cd()
console.log()
console.log(
this.chalk.bold(
` ${figures.tick} Well, that was fast! Now start your dev server:\n`
)
`\t${this.chalk.magenta.bold(`${runner} `) + this.chalk.bold("factor dev")}\n`
)
cd()
console.log(`\t${this.chalk.magenta.bold("npx ") + this.chalk.bold("factor dev")}\n`)
console.log()
console.log(
` ${this.chalk.cyan.bold(`${figures.arrowRight} Docs:`)} ${this.chalk.bold(
Expand All @@ -153,12 +137,7 @@ const config = {
"https://go.factor.dev/slack"
)}`
)
console.log(
` ${this.chalk.cyan.bold(
`${figures.arrowRight} Bugs or Requests:`
)} ${this.chalk.bold("https://go.factor.dev/issues")}`
)

console.log()
console.log()
}
}
Expand Down
2 changes: 0 additions & 2 deletions @factor/create-factor-app/template/README.md
@@ -1,7 +1,5 @@
# <%= name %>

_<%= description %>_

## Built with [Factor](https://factor.dev)

```bash
Expand Down
7 changes: 0 additions & 7 deletions @factor/create-factor-app/template/_env
@@ -1,6 +1,3 @@
# -- Admins - Initial admins by email (must be verified) - separate by a comma
FACTOR_ADMINS="<%= email %>"

# -- Database - MongoDB/Mongoose compatible connection URL
<% if(db){ %>DB_CONNECTION="<%= db %>"
<% } else { %># DB_CONNECTION="<YOUR MONGODB CONNECTION STRING>"<% } %>
Expand All @@ -13,7 +10,3 @@ TOKEN_SECRET="RANDOMLY-GENERATED-<%= randomString %>"
# SMTP_USERNAME="<SMTP USERNAME - ANY SMTP PROVIDER>"
# SMTP_PASSWORD="<SMTP PASSWORD - ANY SMTP PROVIDER>"
# SMTP_HOST="<SMTP HOST - ANY SMTP PROVIDER>"

# -- Production URL - Needed for links in emails
# FACTOR_URL="https://www.example.com"

14 changes: 2 additions & 12 deletions @factor/create-factor-app/template/_package.json
@@ -1,25 +1,15 @@
{
"name": "<%= urlName %>",
"version": "1.0.0",
"description": "<%= description %>",
"description": "",
"main": "src/index",
"private": true,
"factor": {
"load": [{ "app": "index", "server": "server" }],
"app": {
"name": "<%= name %>",
"description": "<%= description %>",
"email": "<%= email %>",
"url": ""
}
},
"dependencies": {
"@factor/core": "^1.0.0",
"@factor/plugin-notify": "^1.0.0",
"@factor/plugin-seo": "^1.0.0",
"@factor/plugin-sitemap": "^1.0.0",
"@factor/plugin-contact-form": "^1.0.0",
"@factor/plugin-storage-s3": "^1.0.0",
"@factor/theme-zeno": "^1.0.0"
"@factor/plugin-storage-s3": "^1.0.0"
}
}
4 changes: 2 additions & 2 deletions @factor/create-factor-app/template/factor/src/index.ts
@@ -1,5 +1,5 @@
/**
* This is your app control file (set in package.json)
* This is your app main file
*
* Use it to manipulate your application environment (routes, hooks/filters, events)
* Use it to do anything you want in your Factor app
*/
5 changes: 0 additions & 5 deletions @factor/create-factor-app/template/factor/src/server.ts

This file was deleted.

1 change: 1 addition & 0 deletions @factor/loader/app-dist/assets/css/5.5d16cc47.chunk.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions @factor/loader/app-dist/assets/css/5.733c43e0.chunk.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions @factor/loader/app-dist/assets/css/5.a8d59090.chunk.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions @factor/loader/app-dist/assets/css/5.bafc7c9e.chunk.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5c88c3c

Please sign in to comment.