Init was wrong and shouldn't use opts in that function.

main
Zed A. Shaw 2 years ago
parent 62f7465e21
commit 498d88c26a
  1. 78
      README.md
  2. 6
      commands/init.js

@ -2,6 +2,82 @@
This is the template project that's checked out and configured when you run the bando-up command from ljsthw-bandolier. This is where the code really lives. This is the template project that's checked out and configured when you run the bando-up command from ljsthw-bandolier. This is where the code really lives.
## Installation
First, install the [ljsthw-bandolier](https://git.learnjsthehardway.com/learn-javascript-the-hard-way/ljsthw-bandolier#ljsthw-bandolier):
```
npm install git+https://git.learnjsthehardway.com/learn-javascript-the-hard-way/ljsthw-bandolier.git
```
That will create a command you'll use to manage installs and updates of the [Bandolier Template](https://git.learnjsthehardway.com/learn-javascript-the-hard-way/bandolier-template). The code for the framework lives there.
You should now be able to do this:
```
npx bando-up --version
npx bando-up --help
```
If you can't then refer to the documentation for `ljsthw-bandolier`, _especially if you get errors regarding SSL certificates on Windows_.
If you can run the `npx bando-up` command then use it to create your first project:
```
npx bando-up create my-project
```
This will checkout the [Bandolier Template](https://git.learnjsthehardway.com/learn-javascript-the-hard-way/bandolier-template) git repository into the `my-project` directory. Once it's done you can move on to _Configuration_.
## Configuration
If you checked out your first project into `my-project` then do this:
```
cd my-project
npm install
```
That will move you into the project directory and install all of the required software. If you get errors with `node-gyp` see below on how to fix them (maybe).
Once `npm install` finishes you can configure the application:
```
npm run knex migrate:latest
```
This will setup your database, and then you can finally do the initialize command to finish the setup:
```
node bando.js init
```
This will configure some items, rerun the migrations just in case, and copy any template files that may have been missed. It will skip files you already have, and then wait for you to start the app in another window.
Open another Terminal window and start the app in `DANGER_ADMIN` mode:
```
npm run DANGER_ADMIN
```
This starts the app in developer mode, but it's called `DANGER_ADMIN` so you know for sure you should _not_ be running it this way in production on the internet.
Once it's running, switch back to the other window and hit `ENTER`. This will open your browser to `http://localhost:5001` so you can register a first user. Fill out the registration form with a fake user and hit the `Register and Continue to Payment` button.
When your developer user is first registered it's not an administrator. Switch back to the window running `node bando.js init` and hit `ENTER` again. The command will then set the first user to `admin=1` and report `FINISHED!`.
The final test is switch back to the browser and refresh the page to see that you are now administrator.
## The `bando.js` Script
If you're on OSX or Linux you can just run `./bando.js` directly rather than `node bando.js`. If you're on Windows you can use the PowerShell script `./bando` instead. To make these instructions work for people who skim I'm using `node bando.js`.
This command is a simple "runner" script that looks in the directory `commands` for all `.js` files to provide them as commands. You can go in there right now and look at the `commands/init.js` file to see what it did. The code is fairly simple, and a good one to study first. Feel free to look at the other commands as well.
## More to Come
That's the end of the first docs. There will be more work to clean this code up and test it by implementing various sites as demonstrations. Give it a tour and feel free to ask questions you may have.
## Install Error with Playwright ## Install Error with Playwright
In theory you shouldn't need playwright to download browsers, so just tell it not to. In theory you shouldn't need playwright to download browsers, so just tell it not to.
@ -12,6 +88,8 @@ PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install
This isn't as needed on Linux as OSX, because the Playwright project forces people to upgrade their OS by claiming all versions of their project can't support any slightly older Safari versions. You also just don't need Safari, so skip the download. This isn't as needed on Linux as OSX, because the Playwright project forces people to upgrade their OS by claiming all versions of their project can't support any slightly older Safari versions. You also just don't need Safari, so skip the download.
## Errors Related to `node-gyp`
If this doesn't work then this might https://github.com/nodejs/node-gyp/blob/main/docs/Updating-npm-bundled-node-gyp.md which says that npm updates don't update the node-gyp it uses internally. Depending on your version you will have to run different commands, but this works for 7,8, and 9 versions: If this doesn't work then this might https://github.com/nodejs/node-gyp/blob/main/docs/Updating-npm-bundled-node-gyp.md which says that npm updates don't update the node-gyp it uses internally. Depending on your version you will have to run different commands, but this works for 7,8, and 9 versions:
``` ```

@ -19,7 +19,7 @@ const error = console.error;
const dirs = ["./debug/email","./debug/errors","./secrets"]; const dirs = ["./debug/email","./debug/errors","./secrets"];
const copy_templates = (templates) => { const copy_templates = (templates, force) => {
good("Copying templates to your project. You can commit these to git."); good("Copying templates to your project. You can commit these to git.");
const source_files = glob(`${templates}/**/*`); const source_files = glob(`${templates}/**/*`);
@ -28,7 +28,7 @@ const copy_templates = (templates) => {
// need to add a . for the path to be local // need to add a . for the path to be local
const dest = "." + template.slice(templates.length); const dest = "." + template.slice(templates.length);
if(opts.force || !exists(dest)) { if(force || !exists(dest)) {
good(template, "->", dest); good(template, "->", dest);
copy(template, dest); copy(template, dest);
} else { } else {
@ -44,7 +44,7 @@ export const main = async (opts) => {
warn("!!! WARNING!: Do not add the contents of secrets to your git repository."); warn("!!! WARNING!: Do not add the contents of secrets to your git repository.");
copy_templates(opts.templates); copy_templates(opts.templates, opts.force);
good("Starting redis for your OS so you can register an admin."); good("Starting redis for your OS so you can register an admin.");
devsvc({start: true, noexit: true}); devsvc({start: true, noexit: true});

Loading…
Cancel
Save