@reactloom/cli 0.0.0-stage → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +34 -2
  3. package/bin/cli.mjs +142 -0
  4. package/package.json +50 -3
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ReactLoom UI contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,35 @@
1
- # Temporary Holding Version
1
+ # @reactloom/cli
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Set up a ReactLoom theme in your React project in one command.
4
+
5
+ ```bash
6
+ npx @reactloom/cli init
7
+ ```
8
+
9
+ It asks for an accent colour and a corner radius, then writes:
10
+
11
+ - `src/theme.ts`: your brand theme (`brandTheme`), made with `createTheme` from `@reactloom/theme`
12
+ - `src/App.tsx`: a small starter page, only if you don't have one yet
13
+
14
+ Then install the packages:
15
+
16
+ ```bash
17
+ pnpm add @reactloom/ui @reactloom/theme
18
+ ```
19
+
20
+ ## Options
21
+
22
+ ```bash
23
+ npx @reactloom/cli init --accent teal --radius rounded --yes
24
+ ```
25
+
26
+ | Option | Values | Default |
27
+ | --- | --- | --- |
28
+ | `--accent` | `indigo`, `teal`, `emerald`, `amber`, `rose` | `indigo` |
29
+ | `--radius` | `sharp`, `default`, `rounded`, `pill` | `default` |
30
+ | `--yes` | Use the options given (or the defaults) without asking | |
31
+ | `--force` | Replace an existing `src/theme.ts` | |
32
+
33
+ Without `--force` the CLI never overwrites `src/theme.ts`. Requires Node.js 22 or later.
34
+
35
+ Theming guide: <https://www.reactloom.dev/docs/theming>
package/bin/cli.mjs ADDED
@@ -0,0 +1,142 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * ReactLoom CLI (`npx @reactloom/cli init`)
4
+ * Generates `src/theme.ts` and a starter `src/App.tsx` with your chosen accent, radius, and font.
5
+ */
6
+ import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
7
+ import { dirname, join } from 'node:path';
8
+ import { createInterface } from 'node:readline/promises';
9
+ import { stdin as input, stdout as output } from 'node:process';
10
+
11
+ const PALETTES = {
12
+ indigo: {
13
+ 50: '#EEF2FF', 100: '#E0E7FF', 200: '#C7D2FE', 300: '#A5B4FC', 400: '#818CF8',
14
+ 500: '#6366F1', 600: '#4F46E5', 700: '#4338CA', 800: '#3730A3', 900: '#312E81', 950: '#1E1B4B',
15
+ },
16
+ teal: {
17
+ 50: '#EFFCF9', 100: '#C9F5EC', 200: '#95EBDA', 300: '#59D8C3', 400: '#2BBCA8',
18
+ 500: '#14A08F', 600: '#0D7F73', 700: '#0F665D', 800: '#11514B', 900: '#12443F', 950: '#042826',
19
+ },
20
+ emerald: {
21
+ 50: '#ECFDF5', 100: '#D1FAE5', 200: '#A7F3D0', 300: '#6EE7B7', 400: '#34D399',
22
+ 500: '#10B981', 600: '#059669', 700: '#047857', 800: '#065F46', 900: '#064E3B', 950: '#022C22',
23
+ },
24
+ amber: {
25
+ 50: '#FFFBEB', 100: '#FEF3C7', 200: '#FDE68A', 300: '#FCD34D', 400: '#FBBF24',
26
+ 500: '#F59E0B', 600: '#D97706', 700: '#B45309', 800: '#92400E', 900: '#78350F', 950: '#451A03',
27
+ },
28
+ rose: {
29
+ 50: '#FFF1F2', 100: '#FFE4E6', 200: '#FECDD3', 300: '#FDA4AF', 400: '#FB7185',
30
+ 500: '#F43F5E', 600: '#E11D48', 700: '#BE123C', 800: '#9F1239', 900: '#881337', 950: '#4C0519',
31
+ },
32
+ };
33
+
34
+ const RADII = {
35
+ sharp: { md: '2px', lg: '4px' },
36
+ default: { md: '6px', lg: '10px' },
37
+ rounded: { md: '10px', lg: '14px' },
38
+ pill: { md: '14px', lg: '18px' },
39
+ };
40
+
41
+ function argValue(flag) {
42
+ const idx = process.argv.indexOf(flag);
43
+ return idx !== -1 && process.argv[idx + 1] ? process.argv[idx + 1] : null;
44
+ }
45
+
46
+ const cmd = process.argv[2];
47
+ if (!cmd || cmd === '--help' || cmd === '-h') {
48
+ console.log(`Usage: reactloom init [--accent indigo|teal|emerald|amber|rose] [--radius sharp|default|rounded|pill] [--yes] [--force]
49
+
50
+ Writes src/theme.ts (your brand theme) and, if missing, a starter src/App.tsx.
51
+ --yes use the given or default options without asking
52
+ --force replace an existing src/theme.ts`);
53
+ process.exit(0);
54
+ }
55
+
56
+ if (cmd !== 'init') {
57
+ console.error(`Unknown command: ${cmd}`);
58
+ process.exit(1);
59
+ }
60
+
61
+ const yes = process.argv.includes('--yes') || process.argv.includes('-y');
62
+ const force = process.argv.includes('--force');
63
+ let accent = argValue('--accent') ?? 'indigo';
64
+ let radius = argValue('--radius') ?? 'default';
65
+ if (!PALETTES[accent]) {
66
+ console.error(`Unknown --accent "${accent}". Choose one of: ${Object.keys(PALETTES).join(', ')}.`);
67
+ process.exit(1);
68
+ }
69
+ if (!RADII[radius]) {
70
+ console.error(`Unknown --radius "${radius}". Choose one of: ${Object.keys(RADII).join(', ')}.`);
71
+ process.exit(1);
72
+ }
73
+
74
+ const cwd = process.cwd();
75
+ const themePath = join(cwd, 'src', 'theme.ts');
76
+ // Never overwrite someone's theme by accident.
77
+ if (existsSync(themePath) && !force) {
78
+ console.error(`${themePath} already exists. Nothing was changed; run again with --force to replace it.`);
79
+ process.exit(1);
80
+ }
81
+
82
+ if (!yes && process.stdin.isTTY) {
83
+ const rl = createInterface({ input, output });
84
+ const a = (await rl.question(`Accent palette (${Object.keys(PALETTES).join('/')}) [${accent}]: `)).trim();
85
+ if (a && PALETTES[a]) accent = a;
86
+ const r = (await rl.question(`Radius preset (${Object.keys(RADII).join('/')}) [${radius}]: `)).trim();
87
+ if (r && RADII[r]) radius = r;
88
+ rl.close();
89
+ }
90
+
91
+ const palette = PALETTES[accent];
92
+ const rad = RADII[radius];
93
+
94
+ const themeTs = `import { createTheme, type ColorScale } from '@reactloom/theme';
95
+
96
+ const accentScale: ColorScale = ${JSON.stringify(palette, null, 2)};
97
+
98
+ export const brandTheme = createTheme({
99
+ name: 'brand',
100
+ palettes: { accent: accentScale },
101
+ radius: ${JSON.stringify(rad)},
102
+ });
103
+ `;
104
+
105
+ const starterApp = `import '@reactloom/theme/theme.css';
106
+ import '@reactloom/ui/styles.css';
107
+ import { ThemeProvider } from '@reactloom/theme';
108
+ import { Button, Card, Stack } from '@reactloom/ui';
109
+ import { brandTheme } from './theme';
110
+
111
+ export function App() {
112
+ return (
113
+ <ThemeProvider theme={brandTheme}>
114
+ <Card style={{ maxWidth: 420, margin: '48px auto' }}>
115
+ <Card.Header>
116
+ <Card.Title level={2}>Welcome to ReactLoom</Card.Title>
117
+ <Card.Description>Your custom theme is configured and ready.</Card.Description>
118
+ </Card.Header>
119
+ <Stack direction="row" gap="3">
120
+ <Button>Get started</Button>
121
+ <Button variant="secondary">Read docs</Button>
122
+ </Stack>
123
+ </Card>
124
+ </ThemeProvider>
125
+ );
126
+ }
127
+ `;
128
+
129
+ mkdirSync(dirname(themePath), { recursive: true });
130
+ writeFileSync(themePath, themeTs, 'utf8');
131
+ console.log(`✓ Created ${themePath}`);
132
+
133
+ const appPath = join(cwd, 'src', 'App.tsx');
134
+ if (!existsSync(appPath)) {
135
+ writeFileSync(appPath, starterApp, 'utf8');
136
+ console.log(`✓ Created ${appPath}`);
137
+ } else {
138
+ console.log(`• Kept existing ${appPath} (import brandTheme from './theme')`);
139
+ }
140
+
141
+ console.log('\nNext step:\n pnpm add @reactloom/ui @reactloom/theme\n');
142
+
package/package.json CHANGED
@@ -1,6 +1,53 @@
1
1
  {
2
2
  "name": "@reactloom/cli",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "1.0.1",
4
+ "description": "ReactLoom CLI: run `npx @reactloom/cli init` to generate a brand theme and a starter page for your React project.",
5
+ "keywords": [
6
+ "react",
7
+ "reactloom",
8
+ "accessible",
9
+ "a11y",
10
+ "wcag",
11
+ "typescript",
12
+ "cli",
13
+ "theme",
14
+ "scaffold",
15
+ "starter",
16
+ "init",
17
+ "generator"
18
+ ],
19
+ "homepage": "https://www.reactloom.dev/docs/theming",
20
+ "bugs": {
21
+ "url": "https://www.reactloom.dev/docs/feedback"
22
+ },
23
+ "license": "MIT",
24
+ "type": "module",
25
+ "bin": {
26
+ "reactloom": "./bin/cli.mjs"
27
+ },
28
+ "files": [
29
+ "bin",
30
+ "README.md"
31
+ ],
32
+ "engines": {
33
+ "node": ">=22.0.0"
34
+ },
35
+ "publishConfig": {
36
+ "access": "public"
37
+ },
38
+ "funding": [
39
+ {
40
+ "type": "github",
41
+ "url": "https://github.com/sponsors/Bindhani1995"
42
+ },
43
+ {
44
+ "type": "ko_fi",
45
+ "url": "https://ko-fi.com/bindhani1995"
46
+ }
47
+ ],
48
+ "scripts": {
49
+ "typecheck": "node --check bin/cli.mjs",
50
+ "lint": "node --check bin/cli.mjs",
51
+ "test": "node --test test/cli.test.mjs"
52
+ }
6
53
  }