create-primitiv-ui 0.1.2 → 0.1.4

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.
package/README.md CHANGED
@@ -1,24 +1,39 @@
1
1
  # create-primitiv-ui
2
2
 
3
- Set up **Primitiv UI** in a new or existing Vite / Next.js project with a
3
+ Set up **Primitiv UI** in an existing Vite or Next.js project with a
4
4
  single command.
5
5
 
6
6
  ## Usage
7
7
 
8
8
  ```sh
9
+ # pnpm
10
+ pnpm create primitiv-ui
11
+
12
+ # npm
9
13
  npm create primitiv-ui@latest
10
- # or: pnpm create primitiv-ui
14
+
15
+ # yarn / bun
16
+ yarn create primitiv-ui
17
+ bun create primitiv-ui
11
18
  ```
12
19
 
13
- It detects your package manager, installs
14
- [`primitiv-ui`](https://www.npmjs.com/package/primitiv-ui) as a dev
15
- dependency, then runs `primitiv init` to scaffold configuration. Any
16
- arguments you pass are forwarded to `primitiv init`.
20
+ This runs `primitiv init` via `npx primitiv-ui@latest init` — no local
21
+ install needed. It walks you through choosing a stylesheet format, brand
22
+ colour, and styles path, then writes `primitiv.json` and generates the
23
+ shared token layer.
24
+
25
+ Any arguments you pass are forwarded to `primitiv init`:
26
+
27
+ ```sh
28
+ pnpm create primitiv-ui --yes # accept all defaults
29
+ pnpm create primitiv-ui --format scss # choose SCSS up front
30
+ ```
17
31
 
18
32
  Once set up, add components with:
19
33
 
20
34
  ```sh
21
- npx primitiv add button
35
+ pnpm dlx primitiv-ui@latest add button
36
+ # or: npx primitiv-ui@latest add button
22
37
  ```
23
38
 
24
39
  > **Needs a real Node environment.** The CLI runs a native binary, so this
@@ -0,0 +1,7 @@
1
+ export function spawnCommand(extraArgs) {
2
+ return {
3
+ cmd: 'npx',
4
+ args: ['primitiv-ui@latest', 'init', ...extraArgs],
5
+ options: { stdio: 'inherit', shell: true },
6
+ };
7
+ }
package/create.mjs CHANGED
@@ -1,19 +1,7 @@
1
1
  #!/usr/bin/env node
2
- // Entry point for `pnpm create primitiv-ui` / `npm create primitiv-ui`.
3
- // Installs primitiv-ui as a dev dependency, then delegates to `primitiv init`.
4
- import { execSync, spawnSync } from 'child_process';
5
- import { existsSync } from 'fs';
2
+ import { spawnSync } from 'child_process';
3
+ import { spawnCommand } from './create-logic.mjs';
6
4
 
7
- const pm = existsSync('pnpm-lock.yaml') ? 'pnpm'
8
- : existsSync('yarn.lock') ? 'yarn'
9
- : existsSync('bun.lockb') ? 'bun'
10
- : 'npm';
11
-
12
- const addCmd = pm === 'npm' ? 'install --save-dev' : 'add -D';
13
-
14
- process.stdout.write(`\nInstalling primitiv-ui via ${pm}…\n`);
15
- execSync(`${pm} ${addCmd} primitiv-ui`, { stdio: 'inherit' });
16
-
17
- const args = process.argv.slice(2);
18
- const result = spawnSync('primitiv', ['init', ...args], { stdio: 'inherit' });
5
+ const { cmd, args, options } = spawnCommand(process.argv.slice(2));
6
+ const result = spawnSync(cmd, args, options);
19
7
  process.exit(result.status ?? 1);
package/package.json CHANGED
@@ -1,18 +1,34 @@
1
1
  {
2
2
  "name": "create-primitiv-ui",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Set up Primitiv UI in an existing Vite or Next.js project. Use with: pnpm create primitiv-ui",
5
- "keywords": ["primitiv", "design-system", "cli", "create", "react"],
5
+ "keywords": [
6
+ "primitiv",
7
+ "design-system",
8
+ "cli",
9
+ "create",
10
+ "react"
11
+ ],
6
12
  "bin": {
7
13
  "create-primitiv-ui": "./create.mjs"
8
14
  },
9
- "files": ["create.mjs"],
10
- "engines": { "node": ">=18" },
15
+ "files": [
16
+ "create.mjs",
17
+ "create-logic.mjs"
18
+ ],
19
+ "scripts": {
20
+ "test": "node --test create.test.mjs"
21
+ },
22
+ "engines": {
23
+ "node": ">=18"
24
+ },
11
25
  "repository": {
12
26
  "type": "git",
13
27
  "url": "https://github.com/primitiv-ui/primitiv.git",
14
28
  "directory": "npm/create-primitiv-ui"
15
29
  },
16
30
  "license": "MIT",
17
- "publishConfig": { "access": "public" }
31
+ "publishConfig": {
32
+ "access": "public"
33
+ }
18
34
  }