create-gridland 0.2.54 → 0.2.56
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 +43 -0
- package/dist/index.js +39 -4
- package/package.json +1 -1
- package/templates/next/components.json +2 -0
- package/templates/vite/components.json +2 -0
package/README.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# create-gridland
|
|
2
|
+
|
|
3
|
+
Scaffold a new [Gridland](https://gridland.io) project.
|
|
4
|
+
|
|
5
|
+
Gridland is a React framework for building terminal apps that also run in the browser — same source, same components, two runtime targets.
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
bunx create-gridland my-app
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
You'll be prompted to choose a template:
|
|
14
|
+
|
|
15
|
+
- **CLI app** — Bun-powered terminal app (`@gridland/bun`)
|
|
16
|
+
- **Vite** — Browser app that renders TUI components on an HTML canvas (`@gridland/web`)
|
|
17
|
+
- **Next.js** — Next.js site with embedded Gridland TUI components
|
|
18
|
+
|
|
19
|
+
Then:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
cd my-app
|
|
23
|
+
bun install
|
|
24
|
+
bun dev
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Adding components
|
|
28
|
+
|
|
29
|
+
After scaffolding, add Gridland components from the registry:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
bunx create-gridland add spinner
|
|
33
|
+
bunx create-gridland add modal side-nav --yes
|
|
34
|
+
bunx create-gridland add spinner --dry-run # preview without running
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Components are fetched from `https://gridland.io/r/{name}.json` and written into your project via the shadcn CLI. Already-namespaced names (`@gridland/modal`) work too.
|
|
38
|
+
|
|
39
|
+
## Documentation
|
|
40
|
+
|
|
41
|
+
Full docs at [gridland.io/docs](https://gridland.io/docs)
|
|
42
|
+
|
|
43
|
+
Source: [github.com/thoughtfulllc/gridland](https://github.com/thoughtfulllc/gridland)
|
package/dist/index.js
CHANGED
|
@@ -79,6 +79,7 @@ var require_picocolors = __commonJS({
|
|
|
79
79
|
|
|
80
80
|
// src/index.ts
|
|
81
81
|
var import_picocolors = __toESM(require_picocolors(), 1);
|
|
82
|
+
import { spawnSync } from "child_process";
|
|
82
83
|
import { Command } from "commander";
|
|
83
84
|
|
|
84
85
|
// src/scaffold.ts
|
|
@@ -137,10 +138,10 @@ var DEFAULT_NAME = "my-gridland-app";
|
|
|
137
138
|
|
|
138
139
|
// src/helpers/package-manager.ts
|
|
139
140
|
var commands = {
|
|
140
|
-
npm: { install: "npm install", dev: "npm run dev" },
|
|
141
|
-
yarn: { install: "yarn", dev: "yarn dev" },
|
|
142
|
-
pnpm: { install: "pnpm install", dev: "pnpm dev" },
|
|
143
|
-
bun: { install: "bun install", dev: "bun dev" }
|
|
141
|
+
npm: { install: "npm install", dev: "npm run dev", dlx: ["npx"] },
|
|
142
|
+
yarn: { install: "yarn", dev: "yarn dev", dlx: ["yarn", "dlx"] },
|
|
143
|
+
pnpm: { install: "pnpm install", dev: "pnpm dev", dlx: ["pnpm", "dlx"] },
|
|
144
|
+
bun: { install: "bun install", dev: "bun dev", dlx: ["bunx"] }
|
|
144
145
|
};
|
|
145
146
|
function detectPackageManager() {
|
|
146
147
|
const userAgent = process.env.npm_config_user_agent ?? "";
|
|
@@ -155,6 +156,9 @@ function getInstallCommand(pm) {
|
|
|
155
156
|
function getDevCommand(pm) {
|
|
156
157
|
return commands[pm].dev;
|
|
157
158
|
}
|
|
159
|
+
function getDlxCommand(pm) {
|
|
160
|
+
return commands[pm].dlx;
|
|
161
|
+
}
|
|
158
162
|
|
|
159
163
|
// src/helpers/install.ts
|
|
160
164
|
import { execSync } from "child_process";
|
|
@@ -215,6 +219,7 @@ function resolveTargetDir(projectName) {
|
|
|
215
219
|
|
|
216
220
|
// src/index.ts
|
|
217
221
|
var program = new Command();
|
|
222
|
+
program.enablePositionalOptions();
|
|
218
223
|
program.name("create-gridland").description("Create a new Gridland project").version("0.1.0").argument("[project-name]", "Name of the project").option("--framework <framework>", "Framework to use (vite or next)").option("--no-install", "Skip dependency installation").option("--no-git", "Skip git initialization").option("--yes", "Use defaults for all prompts").option("--overwrite", "Overwrite existing directory").action(async (projectNameArg, options) => {
|
|
219
224
|
const pm = detectPackageManager();
|
|
220
225
|
const isNonInteractive = options.yes || projectNameArg && options.framework;
|
|
@@ -308,4 +313,34 @@ async function runScaffold({
|
|
|
308
313
|
console.log(import_picocolors.default.cyan(` ${getDevCommand(pm)}`));
|
|
309
314
|
console.log();
|
|
310
315
|
}
|
|
316
|
+
program.command("add [components...]").description("Add Gridland components to the current project via the shadcn registry").option("--yes", "Skip prompts \u2014 accept all defaults").option("--overwrite", "Overwrite existing files without prompting").option("--cwd <path>", "Working directory (defaults to current)").option("--dry-run", "Print the resolved command without executing it").action((components, opts) => {
|
|
317
|
+
if (!components || components.length === 0) {
|
|
318
|
+
console.error(import_picocolors.default.red("Specify at least one component, e.g. create-gridland add spinner"));
|
|
319
|
+
process.exit(1);
|
|
320
|
+
}
|
|
321
|
+
const names = components.map(toGridlandRef);
|
|
322
|
+
const [dlxFile, ...dlxPrefix] = getDlxCommand(detectPackageManager());
|
|
323
|
+
const flags = [];
|
|
324
|
+
if (opts.yes) flags.push("--yes");
|
|
325
|
+
if (opts.overwrite) flags.push("--overwrite");
|
|
326
|
+
if (opts.cwd) flags.push("--cwd", opts.cwd);
|
|
327
|
+
const args = [...dlxPrefix, "shadcn@latest", "add", ...names, ...flags];
|
|
328
|
+
if (opts.dryRun) {
|
|
329
|
+
console.log([dlxFile, ...args].join(" "));
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
console.log(import_picocolors.default.cyan(`\u2192 ${dlxFile} ${args.join(" ")}`));
|
|
333
|
+
const result = spawnSync(dlxFile, args, {
|
|
334
|
+
cwd: opts.cwd ?? process.cwd(),
|
|
335
|
+
stdio: "inherit"
|
|
336
|
+
});
|
|
337
|
+
if (result.error || result.status != null && result.status !== 0) {
|
|
338
|
+
console.error(import_picocolors.default.red("Failed to add components."));
|
|
339
|
+
process.exit(result.status ?? 1);
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
function toGridlandRef(raw) {
|
|
343
|
+
if (raw.startsWith("@")) return raw;
|
|
344
|
+
return `@gridland/${raw}`;
|
|
345
|
+
}
|
|
311
346
|
program.parse();
|
package/package.json
CHANGED