Skip to content

Commit bcbfd98

Browse files
committed
feat: wrap up install method into bin/dev script
1 parent 4296d9b commit bcbfd98

File tree

3 files changed

+67
-24
lines changed

3 files changed

+67
-24
lines changed

README.md

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,6 @@
22

33
`ably-ui` is the of home of the Ably design system library ([https://ably-ui.herokuapp.com/](https://ably-ui.herokuapp.com/)). It provides a showcase, development/test environment and a publishing pipeline for different distributables.
44

5-
## Getting started
6-
7-
`ably-ui` is a library built in mind with supporting a variety of websites/apps based on core web technologies. That's why where possible we build based on those but publish in a way that is easy to consume for frameworks we use across our properties.
8-
9-
As an example, the `Logo` component has two templates, for a [React](https://reactjs.org/) component and [view-component](https://viewcomponent.org/) but uses the same CSS classes and same JavaScript hooks (`data-id`).
10-
11-
In some cases, this is impractical. Some components will be more specialized and take advantage of a given framework, and we will have no need to make it available in multiple frameworks (for example, something that is only used within signed in, SPA like areas).
12-
13-
### Guiding principles
14-
15-
1. Provide easy access to common patterns and assets, from brand colours to navigation.
16-
2. Use the web platform as much as possible without relying on frameworks.
17-
3. Be flexible in how the library can be integrated.
18-
195
### Library structure
206

217
The library is built out of modules, assets, and JavaScript components. A module is a container for all of those.
@@ -24,19 +10,13 @@ For example, the `core` module provides the most general elements one can build
2410

2511
Components do not require assets directly — instead, it's up to the consumer to load the assets and pass them to the components. This ensures flexibility in terms of URLs.
2612

27-
Each module, apart from components, exposes a `scripts.js` and `styles.css`. `scripts.js` contains helper functions. `styles.css` contains CSS that does not belong to any module in particular.
28-
2913
### Installation
3014

3115
### NPM
3216

3317
This type of installation gives you access to module/components assets as well as React components.
3418

3519
```bash
36-
npm install @ably/ui
37-
38-
# or
39-
4020
pnpm add @ably/ui # Preferred
4121
```
4222

@@ -211,6 +191,24 @@ An important part of ably-ui is ensuring the produced UI is accessible to as wid
211191

212192
To visualise the assets in `ably-ui`, there is a Storybook instance, which serves as both a showcase and a development environment.
213193

194+
### Quick Start
195+
196+
The easiest way to get started is to use the development script:
197+
198+
```bash
199+
./bin/dev
200+
```
201+
202+
This script will:
203+
204+
- Check that all required tools (Node.js, pnpm) are installed at the correct versions via asdf
205+
- Install all project dependencies
206+
- Start Storybook automatically
207+
208+
### Manual Setup
209+
210+
If you prefer to run commands manually:
211+
214212
Firstly, ensure you have all of the required project dependencies by running `pnpm install` in the project root.
215213

216214
Then, to run Storybook, run `pnpm storybook` in the project root - it should open automatically in your browser.
@@ -282,8 +280,8 @@ All components live in `src` and follow a directory and filename convention:
282280
- module directory (TitleCase)
283281
- module asset files: `scripts.js` for JavaScript and `styles.css` for CSS
284282
- component directory (TitleCase)
285-
- `component.js` - supporting/legacy JS script
286-
- `component.css` - additional CSS
283+
- `component.js` - supporting JS script (legacy)
284+
- `component.css` - additional CSS (legacy)
287285
- `[ComponentName].stories.tsx` - if React, a Storybook presentation file
288286
- if React, `[ComponentName].tsx` at a sibling level to the component directory
289287

bin/dev

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Check for asdf
5+
if ! command -v asdf >/dev/null 2>&1; then
6+
echo "❌ asdf is not installed. Please install asdf first." >&2
7+
exit 1
8+
fi
9+
10+
# Check all tools in .tool-versions
11+
while read -r tool version; do
12+
# Skip empty lines
13+
[[ -z "$tool" || -z "$version" ]] && continue
14+
15+
echo "🛠️ Checking $tool version..."
16+
17+
# Check if tool is installed via asdf
18+
if ! asdf where "$tool" >/dev/null 2>&1; then
19+
echo "🛠️ $tool is not installed via asdf, installing $version..."
20+
asdf plugin add "$tool" 2>/dev/null || true
21+
asdf install "$tool" "$version"
22+
else
23+
# Check if the correct version is installed
24+
if ! asdf list "$tool" | grep -q "$version"; then
25+
echo "🛠️ Installing $tool $version..."
26+
asdf install "$tool" "$version"
27+
fi
28+
fi
29+
done < .tool-versions
30+
31+
# Ensure asdf shims are up to date
32+
asdf reshim
33+
34+
# Install JS dependencies
35+
if ! command -v pnpm >/dev/null 2>&1; then
36+
echo "❌ pnpm is not installed or not in PATH. Please check asdf setup." >&2
37+
exit 1
38+
fi
39+
40+
echo "📦 Installing JS dependencies with pnpm..."
41+
pnpm install
42+
43+
# Run Storybook
44+
echo "📚 Starting Storybook..."
45+
pnpm storybook

scripts/generate-icons.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,11 +330,11 @@ async function generateIcons() {
330330
fs.writeFileSync(iconJsonPath, generatedIconGroups, "utf-8");
331331

332332
console.log(
333-
`${spriteCliIcons[key]} ${key} icons generated successfully! (${icons.length} total)`,
333+
`${spriteCliIcons[key]} ${key} icons generated successfully! (${icons.length} total)`,
334334
);
335335
}
336336

337-
console.log("✅ Icons generation completed successfully!");
337+
console.log("✅ Icon generation completed successfully!");
338338
} catch (error) {
339339
console.error("Error generating icons:", error);
340340
process.exit(1);

0 commit comments

Comments
 (0)