Skip to content

Commit 84d32a4

Browse files
author
kaptron
committed
Updated setup scripts to include master collections
1 parent 728f921 commit 84d32a4

File tree

4 files changed

+45
-11
lines changed

4 files changed

+45
-11
lines changed

.env.example

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ AWS_ACCESS_KEY_ID=XXXX
1717
AWS_SECRET_ACCESS_KEY=XXXXX
1818
S3_UPLOADS_BUCKET=shape-uploads-production
1919

20+
# required Collection IDs (replace with your master collections or run rails db:seed with these values)
21+
GETTING_STARTED_TEMPLATE_ID=100
22+
ORG_MASTER_TEMPLATES_ID=200
23+
24+
2025
# monitoring
2126
APPSIGNAL_APP_NAME=shape
2227
APPSIGNAL_PUSH_API_KEY=xxxxxxxx

README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,24 @@ gem install bundler
3030
- https://github.com/ideo/network-react-components
3131
- https://github.com/ideo/network-api-ruby
3232

33-
**Clone the app and install the gems:**
33+
**Clone the app and run the setup script:**
34+
35+
Note: `./dev.sh -s` will run `rails db:setup` which will also seed your database with two required collections, marked by the following `ENV` ids:
36+
37+
- `ENV['GETTING_STARTED_TEMPLATE_ID']`
38+
- `ENV['ORG_MASTER_TEMPLATES_ID']`
39+
40+
If these two collections don't exist then you won't be able to create a new organization and setup your first account.
3441

3542
```
3643
git clone https://github.com/ideo/shape
3744
cd shape
45+
# Setup the `.env` file with valid credentials: (get these from the IDEO team)
46+
cp .env.example .env
3847
# run our setup script (install gems, packages, setup database)
3948
./dev.sh -s
4049
```
4150

42-
**Setup the `.env` file with valid credentials:**
43-
44-
```
45-
cp .env.example .env
46-
# modify credentials
47-
```
48-
4951
**Setup your text editor and linter:**
5052

5153
Ensure your text editor has [eslint](https://eslint.org/) and [rubocop](https://rubocop.readthedocs.io/en/latest/) installed (e.g. for Atom you would install [linter-eslint](https://github.com/AtomLinter/linter-eslint) and [linter-rubocop](https://atom.io/packages/linter-rubocop)). For JS code we are using [prettier](https://prettier.io/), so if you have your linter running, it will automatically format properly on save.

db/seeds.rb

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,32 @@
55
#
66
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
77
# Character.create(name: 'Luke', movie: movies.first)
8+
9+
org = Organization.find_or_create_by(id: 1)
10+
if ENV['GETTING_STARTED_TEMPLATE_ID']
11+
c = Collection.find_or_initialize_by(
12+
id: ENV['GETTING_STARTED_TEMPLATE_ID'],
13+
)
14+
if c.new_record?
15+
c.name = 'Seeded Content for My Collection'
16+
c.organization = org
17+
c.save
18+
19+
# just to give it one item
20+
FactoryBot.create(:collection_card_text, parent: c)
21+
end
22+
end
23+
24+
if ENV['ORG_MASTER_TEMPLATES_ID']
25+
c = Collection.find_or_initialize_by(
26+
id: ENV['ORG_MASTER_TEMPLATES_ID'],
27+
)
28+
if c.new_record?
29+
c.name = 'Master Templates'
30+
c.organization = org
31+
c.save
32+
33+
# just to give it one template
34+
FactoryBot.create(:collection, master_template: true, num_cards: 1, parent_collection: c)
35+
end
36+
end

script/dev-setup

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ if [ ! -f "$DIR/.env" ]; then
2121
fi
2222

2323
yarn install
24-
2524
bundle install
26-
25+
# setup runs db:create, db:schema:load and db:seed
2726
bin/rails db:setup
28-
bin/rails db:migrate

0 commit comments

Comments
 (0)