@editora/cli 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 (3) hide show
  1. package/README.md +26 -0
  2. package/bin/editora.js +286 -0
  3. package/package.json +45 -0
package/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # @editora/cli
2
+
3
+ Official CLI for quickly adding Editora packages.
4
+
5
+ ## Usage
6
+
7
+ ```bash
8
+ npx @editora/cli add button
9
+ npx @editora/cli add modal
10
+ npx @editora/cli add datatable
11
+ npx @editora/cli add editor
12
+ npx @editora/cli add toast
13
+ npx @editora/cli add accordion
14
+ npx @editora/cli add ui-select
15
+ ```
16
+
17
+ ## More commands
18
+
19
+ ```bash
20
+ npx @editora/cli add react-icons
21
+ npx @editora/cli add light-code-editor
22
+ npx @editora/cli add all
23
+ npx @editora/cli add editor --dry-run
24
+ ```
25
+
26
+ Any exported `@editora/ui-react` component name is accepted by `editora add`.
package/bin/editora.js ADDED
@@ -0,0 +1,286 @@
1
+ #!/usr/bin/env node
2
+
3
+ /* eslint-disable no-console */
4
+ const { spawnSync } = require("child_process");
5
+
6
+ const helpText = `
7
+ Editora CLI
8
+
9
+ Usage:
10
+ editora add <feature> [feature...] [--dry-run]
11
+
12
+ Examples:
13
+ npx @editora/cli add button
14
+ npx @editora/cli add modal
15
+ npx @editora/cli add datatable
16
+ npx @editora/cli add editor
17
+ npx @editora/cli add toast
18
+ npx @editora/cli add accordion avatar select
19
+ npx @editora/cli add ui-accordion ui-select
20
+ npx @editora/cli add button modal toast
21
+ `;
22
+
23
+ const uiReactComponents = [
24
+ "accordion",
25
+ "alert",
26
+ "alert-dialog",
27
+ "alert-dialog-provider",
28
+ "app-header",
29
+ "aspect-ratio",
30
+ "avatar",
31
+ "badge",
32
+ "block-controls",
33
+ "box",
34
+ "breadcrumb",
35
+ "button",
36
+ "calendar",
37
+ "chart",
38
+ "checkbox",
39
+ "collapsible",
40
+ "color-picker",
41
+ "combobox",
42
+ "command-palette",
43
+ "container",
44
+ "context-menu",
45
+ "data-table",
46
+ "date-picker",
47
+ "date-range-picker",
48
+ "date-range-time-picker",
49
+ "date-time-picker",
50
+ "dialog",
51
+ "dialog-provider",
52
+ "direction-provider",
53
+ "drawer",
54
+ "dropdown",
55
+ "empty-state",
56
+ "field",
57
+ "flex",
58
+ "floating-toolbar",
59
+ "form",
60
+ "gantt",
61
+ "grid",
62
+ "hover-card",
63
+ "icon",
64
+ "input",
65
+ "label",
66
+ "layout",
67
+ "menu",
68
+ "menubar",
69
+ "navigation-menu",
70
+ "pagination",
71
+ "plugin-panel",
72
+ "popover",
73
+ "portal",
74
+ "presence",
75
+ "progress",
76
+ "quick-actions",
77
+ "radio-group",
78
+ "scroll-area",
79
+ "section",
80
+ "select",
81
+ "selection-popup",
82
+ "separator",
83
+ "sidebar",
84
+ "skeleton",
85
+ "slider",
86
+ "slot",
87
+ "stepper",
88
+ "switch",
89
+ "table",
90
+ "tabs",
91
+ "textarea",
92
+ "theme-provider",
93
+ "time-picker",
94
+ "timeline",
95
+ "toast",
96
+ "toast-api",
97
+ "toggle",
98
+ "toggle-group",
99
+ "toolbar",
100
+ "tooltip",
101
+ "visually-hidden",
102
+ "wizard"
103
+ ];
104
+
105
+ const specialRegistry = {
106
+ modal: {
107
+ packages: ["@editora/ui-react"],
108
+ note: "Use Dialog from @editora/ui-react as modal primitive"
109
+ },
110
+ card: {
111
+ packages: ["@editora/ui-react"],
112
+ note: "Use Box/Card composition from @editora/ui-react"
113
+ },
114
+ "ui-react": {
115
+ packages: ["@editora/ui-react"],
116
+ note: "Install all React wrappers from @editora/ui-react"
117
+ },
118
+ "ui-components": {
119
+ packages: ["@editora/ui-react"],
120
+ note: "Alias for ui-react package install"
121
+ },
122
+ toast: {
123
+ packages: ["@editora/toast"],
124
+ note: "Notification runtime"
125
+ },
126
+ editor: {
127
+ packages: ["@editora/react", "@editora/plugins", "@editora/themes"],
128
+ note: "Rich text editor stack for React"
129
+ },
130
+ "react-icons": {
131
+ packages: ["@editora/react-icons"],
132
+ note: "React icon components"
133
+ },
134
+ "light-code-editor": {
135
+ packages: ["@editora/light-code-editor"],
136
+ note: "Embeddable code editor"
137
+ },
138
+ all: {
139
+ packages: [
140
+ "@editora/ui-react",
141
+ "@editora/toast",
142
+ "@editora/react",
143
+ "@editora/plugins",
144
+ "@editora/themes",
145
+ "@editora/react-icons",
146
+ "@editora/light-code-editor"
147
+ ],
148
+ note: "Complete React + UI + editor stack"
149
+ }
150
+ };
151
+
152
+ function normalizeTarget(value) {
153
+ return value
154
+ .trim()
155
+ .toLowerCase()
156
+ .replace(/^ui[-_]/, "")
157
+ .replace(/[^a-z0-9]/g, "");
158
+ }
159
+
160
+ const uiReactLookup = new Map();
161
+ for (const name of uiReactComponents) {
162
+ uiReactLookup.set(normalizeTarget(name), name);
163
+ }
164
+
165
+ const specialLookup = new Map();
166
+ for (const name of Object.keys(specialRegistry)) {
167
+ specialLookup.set(normalizeTarget(name), name);
168
+ }
169
+
170
+ function resolveTarget(rawTarget) {
171
+ const isExplicitUiTarget = /^ui[-_]/i.test(rawTarget.trim());
172
+ const normalized = normalizeTarget(rawTarget);
173
+
174
+ if (isExplicitUiTarget) {
175
+ const uiName = uiReactLookup.get(normalized);
176
+ if (uiName) {
177
+ return {
178
+ canonicalName: uiName,
179
+ entry: {
180
+ packages: ["@editora/ui-react"],
181
+ note: `UI component (${uiName}) from @editora/ui-react`
182
+ }
183
+ };
184
+ }
185
+ }
186
+
187
+ const specialName = specialLookup.get(normalized);
188
+ if (specialName) {
189
+ return { canonicalName: specialName, entry: specialRegistry[specialName] };
190
+ }
191
+
192
+ const uiName = uiReactLookup.get(normalized);
193
+ if (uiName) {
194
+ return {
195
+ canonicalName: uiName,
196
+ entry: {
197
+ packages: ["@editora/ui-react"],
198
+ note: `UI component (${uiName}) from @editora/ui-react`
199
+ }
200
+ };
201
+ }
202
+
203
+ return null;
204
+ }
205
+
206
+ function detectPackageManager() {
207
+ const userAgent = process.env.npm_config_user_agent || "";
208
+ if (userAgent.startsWith("pnpm")) return "pnpm";
209
+ if (userAgent.startsWith("yarn")) return "yarn";
210
+ if (userAgent.startsWith("bun")) return "bun";
211
+ return "npm";
212
+ }
213
+
214
+ function installCommand(pm, packages) {
215
+ if (pm === "pnpm") return ["pnpm", ["add", ...packages]];
216
+ if (pm === "yarn") return ["yarn", ["add", ...packages]];
217
+ if (pm === "bun") return ["bun", ["add", ...packages]];
218
+ return ["npm", ["install", ...packages]];
219
+ }
220
+
221
+ function main() {
222
+ const args = process.argv.slice(2);
223
+ if (args.length === 0 || args.includes("-h") || args.includes("--help")) {
224
+ console.log(helpText.trim());
225
+ process.exit(0);
226
+ }
227
+
228
+ const command = args[0];
229
+ const dryRun = args.includes("--dry-run");
230
+ const filteredArgs = args.filter((arg) => arg !== "--dry-run");
231
+
232
+ if (command !== "add") {
233
+ console.error(`Unknown command: ${command}`);
234
+ console.log(helpText.trim());
235
+ process.exit(1);
236
+ }
237
+
238
+ const targets = filteredArgs.slice(1);
239
+ if (targets.length === 0) {
240
+ console.error("Missing feature name(s).");
241
+ console.log(helpText.trim());
242
+ process.exit(1);
243
+ }
244
+
245
+ const resolvedTargets = targets.map((target) => ({
246
+ input: target,
247
+ resolved: resolveTarget(target)
248
+ }));
249
+
250
+ const unknown = resolvedTargets
251
+ .filter((item) => !item.resolved)
252
+ .map((item) => item.input);
253
+
254
+ if (unknown.length > 0) {
255
+ console.error(`Unknown feature(s): ${unknown.join(", ")}`);
256
+ console.error("Supported:");
257
+ console.error("- all exported @editora/ui-react component names");
258
+ console.error(`- special: ${Object.keys(specialRegistry).sort().join(", ")}`);
259
+ process.exit(1);
260
+ }
261
+
262
+ const packageSet = new Set();
263
+ for (const item of resolvedTargets) {
264
+ for (const pkg of item.resolved.entry.packages) packageSet.add(pkg);
265
+ }
266
+ const packages = Array.from(packageSet);
267
+
268
+ const pm = detectPackageManager();
269
+ const [cmd, cmdArgs] = installCommand(pm, packages);
270
+
271
+ console.log(`\nEditora add targets: ${targets.join(", ")}`);
272
+ for (const item of resolvedTargets) {
273
+ console.log(`- ${item.resolved.canonicalName}: ${item.resolved.entry.note}`);
274
+ }
275
+ console.log(`\nInstalling with ${pm}: ${[cmd, ...cmdArgs].join(" ")}`);
276
+
277
+ if (dryRun) {
278
+ console.log("\nDry run enabled. No packages were installed.");
279
+ process.exit(0);
280
+ }
281
+
282
+ const result = spawnSync(cmd, cmdArgs, { stdio: "inherit" });
283
+ process.exit(result.status == null ? 1 : result.status);
284
+ }
285
+
286
+ main();
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@editora/cli",
3
+ "version": "1.0.1",
4
+ "description": "Official Editora CLI for quickly adding UI components, editor packages, and SaaS-ready building blocks.",
5
+ "author": "Ajay Kumar <ajaykr089@gmail.com>",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/ajaykr089/Editora.git",
10
+ "directory": "packages/cli"
11
+ },
12
+ "homepage": "https://editora-ecosystem.netlify.app/docs/reference/cli",
13
+ "bugs": {
14
+ "url": "https://github.com/ajaykr089/Editora/issues"
15
+ },
16
+ "bin": {
17
+ "editora": "bin/editora.js"
18
+ },
19
+ "files": [
20
+ "bin",
21
+ "README.md"
22
+ ],
23
+ "scripts": {
24
+ "build": "node -e \"console.log('editora cli: no build step required')\"",
25
+ "dev": "node -e \"console.log('editora cli: no dev server')\"",
26
+ "clean": "node -e \"console.log('editora cli: no artifacts to clean')\"",
27
+ "prepublishOnly": "npm run build"
28
+ },
29
+ "keywords": [
30
+ "editora",
31
+ "editora cli",
32
+ "npx @editora/cli",
33
+ "react ui library",
34
+ "react component library",
35
+ "saas ui components",
36
+ "enterprise react components",
37
+ "modern design system",
38
+ "rich text editor react",
39
+ "component generator"
40
+ ],
41
+ "publishConfig": {
42
+ "access": "public"
43
+ },
44
+ "gitHead": "7883627e823aa99dd5ecb66a5201116df972f88b"
45
+ }