@motion-core/cli 0.1.0

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 ADDED
@@ -0,0 +1,130 @@
1
+ # @motion-core/cli
2
+
3
+ The official command-line interface for [Motion Core](https://motion-core.dev/), a Svelte library for high-quality animations and motion components.
4
+
5
+ This package serves as a Node.js wrapper around the native Rust binary, ensuring optimal performance while remaining easily installable via your favorite package manager.
6
+
7
+ ## Installation
8
+
9
+ You can run the CLI directly using `npx`, `bunx`, or `pnpm dlx` without installation:
10
+
11
+ ```bash
12
+ npx @motion-core/cli init
13
+ ```
14
+
15
+ Or install it globally:
16
+
17
+ ```bash
18
+ # using npm
19
+ npm install -g @motion-core/cli
20
+
21
+ # using pnpm
22
+ pnpm add -g @motion-core/cli
23
+
24
+ # using bun
25
+ bun add -g @motion-core/cli
26
+
27
+ # using yarn
28
+ yarn global add @motion-core/cli
29
+ ```
30
+
31
+ ## Usage
32
+
33
+ Once installed, you can use the `motion-core` command to scaffold projects, add components, and manage the local cache.
34
+
35
+ ### `init`
36
+
37
+ Initialize a new Motion Core configuration in your current project. This command detects your framework and sets up the necessary file structure.
38
+
39
+ ```bash
40
+ motion-core init [options]
41
+ ```
42
+
43
+ **Options:**
44
+
45
+ - `--dry-run`: Preview the initialization process without writing any files or changes.
46
+
47
+ ### `add`
48
+
49
+ Add a component (and its dependencies) to your project.
50
+
51
+ ```bash
52
+ motion-core add <component-names> [options]
53
+ ```
54
+
55
+ **Examples:**
56
+
57
+ ```bash
58
+ motion-core add glass-pane
59
+ motion-core add glass-pane image-trail
60
+ ```
61
+
62
+ **Options:**
63
+
64
+ - `--dry-run`: Preview the installation plan (files to create/update, dependencies to install) without applying changes.
65
+ - `-y, --yes`: Skip confirmation prompts. Useful for CI/CD environments.
66
+
67
+ ### `list`
68
+
69
+ List all available components in the registry.
70
+
71
+ ```bash
72
+ motion-core list [options]
73
+ ```
74
+
75
+ **Options:**
76
+
77
+ - `--json`: Output the registry data in JSON format instead of a human-readable table.
78
+
79
+ ### `cache`
80
+
81
+ Manage the local cache used to store registry data and component assets.
82
+
83
+ ```bash
84
+ motion-core cache [options]
85
+ ```
86
+
87
+ **Options:**
88
+
89
+ - `--clear`: Prepare to clear cached registry data and assets. **Must be used with `--force` to perform the deletion.**
90
+ - `--force`: Confirm the deletion of cached files.
91
+
92
+ ## How it Works
93
+
94
+ This package identifies your operating system and CPU architecture (Windows, macOS, Linux / x64, arm64) and delegates execution to the appropriate pre-compiled Rust binary. This approach combines the raw performance of native code with the convenience of Node.js package distribution.
95
+
96
+ ## Development
97
+
98
+ If you are contributing to the CLI or building it locally:
99
+
100
+ 1. **Prerequisites**: Ensure you have [Rust](https://www.rust-lang.org/tools/install) and Node.js installed.
101
+
102
+ 2. **Build the Rust binary**:
103
+ From the `motion-core-cli` root directory, build the binary for your current platform:
104
+
105
+ ```bash
106
+ cargo build --release
107
+ ```
108
+
109
+ _Note: You may need to specify a target if cross-compiling._
110
+
111
+ 3. **Place the binary**:
112
+ The Node.js wrapper expects the binary to be located in `dist/<target-triple>/`.
113
+
114
+ For example, on an Apple Silicon Mac:
115
+
116
+ ```bash
117
+ mkdir -p js/dist/aarch64-apple-darwin
118
+ cp target/release/motion-core js/dist/aarch64-apple-darwin/
119
+ ```
120
+
121
+ 4. **Run the wrapper**:
122
+ ```bash
123
+ cd js
124
+ bun link # or npm link
125
+ motion-core --help
126
+ ```
127
+
128
+ ## License
129
+
130
+ MIT
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { join, dirname } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ import { existsSync } from "node:fs";
6
+ import { spawnSync } from "node:child_process";
7
+
8
+ const __dirname = dirname(fileURLToPath(import.meta.url));
9
+
10
+ const platform = process.platform;
11
+ const arch = process.arch;
12
+
13
+ const targets = {
14
+ "darwin-arm64": "aarch64-apple-darwin",
15
+ "darwin-x64": "x86_64-apple-darwin",
16
+ "linux-arm64": "aarch64-unknown-linux-gnu",
17
+ "linux-x64": "x86_64-unknown-linux-gnu",
18
+ "win32-arm64": "aarch64-pc-windows-msvc",
19
+ "win32-x64": "x86_64-pc-windows-msvc",
20
+ };
21
+
22
+ const variant = `${platform}-${arch}`;
23
+ const target = targets[variant];
24
+
25
+ if (!target) {
26
+ console.error(
27
+ `motion-core: unsupported platform/architecture combination: ${variant}`,
28
+ );
29
+ console.error(
30
+ "Please open an issue at https://github.com/motion-core/motion-core/issues.",
31
+ );
32
+ process.exit(1);
33
+ }
34
+
35
+ const binaryName = platform === "win32" ? "motion-core.exe" : "motion-core";
36
+ const binaryPath = join(__dirname, "..", "dist", target, binaryName);
37
+
38
+ if (!existsSync(binaryPath)) {
39
+ console.error(`motion-core: binary not found for target ${target}.`);
40
+ console.error("Build the Rust CLI with:");
41
+ console.error(` cargo build --release --target ${target}`);
42
+ console.error("Then copy the resulting binary into js/dist/<target>/.");
43
+ process.exit(1);
44
+ }
45
+
46
+ const result = spawnSync(binaryPath, process.argv.slice(2), {
47
+ stdio: "inherit",
48
+ });
49
+
50
+ if (result.error) {
51
+ console.error(result.error);
52
+ process.exit(result.status ?? 1);
53
+ }
54
+
55
+ process.exit(result.status ?? 0);
package/dist/.gitkeep ADDED
@@ -0,0 +1 @@
1
+
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@motion-core/cli",
3
+ "version": "0.1.0",
4
+ "description": "Motion Core CLI tooling",
5
+ "license": "MIT",
6
+ "bin": {
7
+ "motion-core": "bin/motion-core.js"
8
+ },
9
+ "files": [
10
+ "bin",
11
+ "dist",
12
+ "README.md"
13
+ ],
14
+ "keywords": [
15
+ "motion-core",
16
+ "cli",
17
+ "svelte",
18
+ "tailwind"
19
+ ],
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/motion-core/motion-core.git",
23
+ "directory": "motion-core-cli/js"
24
+ },
25
+ "bugs": {
26
+ "url": "https://github.com/motion-core/motion-core/issues"
27
+ },
28
+ "homepage": "https://motion-core.dev/docs/cli-guide",
29
+ "type": "module",
30
+ "main": "./bin/motion-core.js",
31
+ "engines": {
32
+ "node": ">=18.0.0"
33
+ }
34
+ }