Skip to content

Commit e067f76

Browse files
docs: Update contributing docs and add bash script (#141)
* docs: Update contributing docs Co-authored-by: Tony Ward <8069555+ynotdraw@users.noreply.github.com> Co-authored-by: Dan Wenzel <11724146+danwenzel@users.noreply.github.com> * Added local setup script * added: options to setup script @ynotdraw mentioned we should give the users to option to clear the caches. So I added in a menu users can select from. I also added in print_info (cyan) and print_warning (yellow) functions. * docs: update contributing doc --------- Co-authored-by: Dan Wenzel <11724146+danwenzel@users.noreply.github.com>
1 parent 5accc78 commit e067f76

File tree

2 files changed

+162
-19
lines changed

2 files changed

+162
-19
lines changed

CONTRIBUTING.md

+46-19
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ ember-toucan-core uses [pnpm](https://pnpm.io) as a package manager. If you're u
3535

3636
```bash
3737
cd ember-toucan-core
38-
pnpm install
38+
pnpm install # can also: pnpm i
3939
```
4040

4141
## Adding components
@@ -45,34 +45,52 @@ When developing a new component, add it to the `packages/ember-toucan-core` dire
4545
1. Components are added under `packages/ember-toucan-core/src/components`
4646
2. When adding a new component, it needs to be added to the template registry so that Glint picks it up. To do that, add a line in `packages/ember-toucan-core/src/template-registry.ts`.
4747

48-
## Running the docs/test-app
48+
## Viewing changes in the docs/test-app
4949

50-
Prior to running the `docs-app` or `test-app`, you'll need to install dependencies:
50+
### Option 1: run the bash script
5151

52-
```bash
53-
cd docs-app
54-
pnpm i
55-
pnpm start
56-
```
52+
For the time being you can use `pnpm link` to create a symlink between the addon and the apps. This will allow you to make a change in the addon and immediately see the change in the app rather than having to stop the app, rebuild, resync dependencies, etc.
53+
54+
There are two ways to do this:
55+
56+
### Option 1: run the bash script
57+
58+
In the root of the repo, run:
5759

5860
```bash
59-
cd test-app
60-
pnpm i
61-
pnpm start
61+
./local-setup.bash
6262
```
6363

64-
## Viewing changes in the docs/test-app
64+
This will run a bash script, where you can choose to install and symlink.
65+
66+
You will also have the option of deleting the turbo repo, and/or deleting the node_modules, dist, and tsc cache. But running these takes longer.
6567

66-
[We're working on making this better](https://github.com/CrowdStrike/ember-toucan-core/issues/40), but for the time being you can use `pnpm link` to create a symlink between the addon and the apps. This will allow you to make a change in the addon and immediately see the change in the app rather than having to stop the app, rebuild, resync dependencies, etc.
68+
### Option 2: symlink manually
6769

6870
```bash
69-
# Create a symlink in the addon
71+
# Create a symlink in the ember-toucan-core addon
7072
cd packages/ember-toucan-core
73+
pnpm build
7174
pnpm link .
7275

73-
# Link the docs-app
74-
cd ../docs-app
75-
pnpm link @crowdstrike/ember-toucan-core
76+
# Create a symlink in the forms addon (required even if you aren't using it)
77+
cd ../ember-toucan-form
78+
pnpm link @crowdstrike/ember-toucan-core # need to link this because ember-toucan-forms depends on it
79+
pnpm build
80+
pnpm link .
81+
82+
# Link ember-toucan-core docs-app
83+
cd ../../docs-app
84+
pnpm link @crowdstrike/ember-toucan-core # note @crowdstrike here
85+
pnpm link @crowdstrike/ember-toucan-form # note @crowdstrike here
86+
pnpm i
87+
88+
The test-app also needs to link `ember-toucan-form`.
89+
90+
# Link ember-toucan-core to the test-app
91+
cd ../test-app
92+
pnpm link @crowdstrike/ember-toucan-core # note @crowdstrike here
93+
pnpm link @crowdstrike/ember-toucan-form # note @crowdstrike here
7694
pnpm i
7795
```
7896

@@ -84,8 +102,17 @@ cd packages/ember-toucan-core
84102
pnpm start
85103
# ember-toucan-core is now in watch mode and will rebuild automatically
86104

87-
# In a second terminal
88-
cd docs-app
105+
106+
# In a second terminal, cd to the root of the repo
107+
cd root-of-repo-where-that-is-for-you
108+
pnpm start:docs # using turbo here
109+
110+
# In a third terminal, switch to the test-app
111+
cd root-of-repo-where-that-is-for-you/test-app
112+
pnpm start # and then navigate to /tests
113+
114+
# IF you are making changes in ember-toucan-form, start a fourth terminal
115+
cd packages/ember-toucan-form
89116
pnpm start
90117
```
91118

local-setup.bash

+116
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
#!/bin/bash
2+
3+
# COLORS
4+
CYAN='\033[0;36m'
5+
YELLOW='\033[0;33m'
6+
ENDCOLOR="\033[0m"
7+
8+
print_info() {
9+
echo -e "${CYAN} $1 ${ENDCOLOR}"
10+
}
11+
12+
print_warning() {
13+
echo -e "${YELLOW}$1 ${ENDCOLOR}"
14+
}
15+
16+
# VARIABLES
17+
install_and_symlink=false
18+
del_turbo_cache=false
19+
del_node_modules_dist_and_tsc_cache=false
20+
21+
PS3='Please choose an option: '
22+
options=(
23+
"Only install and symlink"
24+
"Please delete node_modules, dist, and typescript cache, and then install and symlink"
25+
"Please delete turbo cache, node modules, typescript cache, and install and symlink"
26+
"Quit"
27+
)
28+
29+
select opt in "${options[@]}"
30+
do
31+
case $opt in
32+
"Only install and symlink")
33+
print_info "choosing simple install"
34+
install_and_symlink=true
35+
break
36+
;;
37+
"Please delete node_modules, dist, and typescript cache, and then install and symlink")
38+
del_node_modules_dist_and_tsc_cache=true
39+
install_and_symlink=true
40+
break
41+
;;
42+
"Please delete turbo cache, node modules, typescript cache, and install and symlink")
43+
del_turbo_cache=true
44+
del_node_modules_dist_and_tsc_cache=true
45+
install_and_symlink=true
46+
break;
47+
;;
48+
"Quit")
49+
print_info "Quitting"
50+
exit 0
51+
break
52+
;;
53+
esac
54+
done
55+
56+
print_info "running a git check"
57+
if [[ $(git diff --stat) != '' ]]; then
58+
print_warning "You have changes not checked into git, please stash or commit them and try again"
59+
exit 1
60+
else
61+
print_info "Git status is good, moving on to local setup..."
62+
fi
63+
64+
if [[ "$del_turbo_cache" = true ]]
65+
then
66+
print_info "deleting turbo cache..."
67+
find . -name ".turbo" -type d -prune -exec rm -rf "{}" \;
68+
rm -rf node_modules/.cache
69+
fi
70+
71+
if [[ "$del_node_modules_dist_and_tsc_cache" = true ]]
72+
then
73+
print_info "nukin' node_modules, declaration, dist directories, and tsc build cache"
74+
rm -rf node_modules/.cache;
75+
find . -name "node_modules" -type d -prune -exec rm -rf "{}" \;
76+
find . -name "declarations" -type d -prune -exec rm -rf "{}" \;
77+
find . -name "dist" -type d -prune -exec rm -rf "{}" \;
78+
find . -name "tsconfig.tsbuildinfo" -type f -exec rm -rf "{}" \;
79+
fi
80+
81+
if [[ "$install_and_symlink" = true ]]
82+
then
83+
pnpm i
84+
85+
print_info "--installed node modules--"
86+
87+
print_info "building ember-toucan-core"
88+
cd packages/ember-toucan-core
89+
pnpm build
90+
pnpm link .
91+
92+
print_info "building ember-toucan-form"
93+
cd ../ember-toucan-form
94+
pnpm link @crowdstrike/ember-toucan-core
95+
pnpm build
96+
pnpm link .
97+
98+
print_info "linking the docs app"
99+
cd ../../docs-app
100+
pnpm link @crowdstrike/ember-toucan-core
101+
pnpm link @crowdstrike/ember-toucan-form
102+
103+
print_info "linking the test app"
104+
cd ../test-app
105+
pnpm link @crowdstrike/ember-toucan-core
106+
pnpm link @crowdstrike/ember-toucan-form
107+
108+
pnpm i # this should link all of them
109+
fi
110+
111+
print_info "Done"
112+
echo "Please open a terminal in the packages/ember-toucan-core and pnpm start"
113+
echo "Please open a new terminal in the root of the app and run pnpm start:docs"
114+
echo "Please open another terminal in the test-app folder and run pnpm start"
115+
echo "Please open a terminal in the packages/ember-toucan-forms and pnpm start"
116+
echo "REMEMBER to not check in these changes to the package.json and pnpm-lock yaml files"

0 commit comments

Comments
 (0)