@editora/cli 1.0.6 → 1.0.7
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 +128 -66
- package/bin/editora.js +74 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,106 +1,168 @@
|
|
|
1
|
-
|
|
1
|
+
<h1 align="center">@editora/cli</h1>
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
<p align="center">
|
|
4
|
+
Add Editora to a project with one command. <code>npx @editora/cli add editor</code> installs the rich text editor,
|
|
5
|
+
<code>add toast</code> the notifications, <code>add data-table</code> a component. It picks the packages and runs
|
|
6
|
+
your package manager.
|
|
7
|
+
</p>
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
<p align="center">
|
|
10
|
+
<a href="https://www.npmjs.com/package/@editora/cli"><img src="https://img.shields.io/npm/v/@editora/cli.svg" alt="npm version"></a>
|
|
11
|
+
<a href="https://www.npmjs.com/package/@editora/cli"><img src="https://img.shields.io/npm/dm/@editora/cli.svg" alt="npm downloads"></a>
|
|
12
|
+
<a href="https://github.com/ajaykr089/Editora/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/@editora/cli.svg" alt="license"></a>
|
|
13
|
+
<a href="https://www.npmjs.com/package/@editora/cli"><img src="https://img.shields.io/node/v/@editora/cli.svg" alt="Node.js version"></a>
|
|
14
|
+
</p>
|
|
9
15
|
|
|
10
|
-
|
|
16
|
+
<p align="center">
|
|
17
|
+
<a href="https://editora-ecosystem.netlify.app/docs/reference/cli">Documentation</a> ·
|
|
18
|
+
<a href="https://github.com/ajaykr089/Editora">GitHub</a>
|
|
19
|
+
</p>
|
|
11
20
|
|
|
12
|
-
|
|
21
|
+
<p align="center">
|
|
22
|
+
<img src="https://raw.githubusercontent.com/ajaykr089/Editora/main/packages/cli/docs/images/add.png" alt="A terminal running npx @editora/cli add editor --dry-run, which prints that it will run npm install @editora/react @editora/plugins @editora/themes, and the same for add button modal toast, which installs @editora/ui-react and @editora/toast" width="760">
|
|
23
|
+
</p>
|
|
13
24
|
|
|
14
|
-
|
|
15
|
-
npm install -g @editora/cli
|
|
16
|
-
# or
|
|
17
|
-
pnpm add -g @editora/cli
|
|
18
|
-
# or
|
|
19
|
-
yarn global add @editora/cli
|
|
20
|
-
```
|
|
25
|
+
## What it does
|
|
21
26
|
|
|
22
|
-
|
|
27
|
+
`editora add` turns a name you know, such as `editor` or `button`, into the packages behind it and installs them with
|
|
28
|
+
npm, pnpm, yarn or bun. That is all it does: it does not create files, change your configuration or write code, so what
|
|
29
|
+
changes in your project is what your package manager changes (`package.json`, the lock file, `node_modules`).
|
|
23
30
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
31
|
+
- **One command, several packages.** `add editor` installs three, `add all` seven.
|
|
32
|
+
- **Look before you install.** `--dry-run` prints the command and stops.
|
|
33
|
+
- **Your package manager.** npm, pnpm, yarn or bun, detected or chosen with a flag.
|
|
34
|
+
- **No dependencies.** It needs Node.js 16 or later.
|
|
27
35
|
|
|
28
|
-
|
|
36
|
+
## Quick start
|
|
29
37
|
|
|
30
38
|
```bash
|
|
31
|
-
editora
|
|
39
|
+
npx @editora/cli add editor
|
|
32
40
|
```
|
|
33
41
|
|
|
34
|
-
|
|
42
|
+
Add `--dry-run` to see what it would run without installing anything:
|
|
43
|
+
|
|
44
|
+
```text
|
|
45
|
+
$ npx @editora/cli add editor --dry-run
|
|
46
|
+
Editora add targets: editor
|
|
47
|
+
- editor: Rich text editor stack for React
|
|
48
|
+
|
|
49
|
+
Installing with npm: npm install @editora/react @editora/plugins @editora/themes
|
|
35
50
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
51
|
+
Dry run enabled. No packages were installed.
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
To use it as a command, install it once and run `editora`:
|
|
40
55
|
|
|
41
56
|
```bash
|
|
42
57
|
npm install -g @editora/cli
|
|
43
|
-
|
|
44
|
-
source ~/.zshrc
|
|
45
|
-
ed add button
|
|
58
|
+
editora add editor
|
|
46
59
|
```
|
|
47
60
|
|
|
48
|
-
##
|
|
61
|
+
## What you can add
|
|
49
62
|
|
|
50
|
-
|
|
63
|
+
| You type | It installs | Then read |
|
|
64
|
+
| --- | --- | --- |
|
|
65
|
+
| `editor` | `@editora/react`, `@editora/plugins`, `@editora/themes` | [`@editora/react`](https://www.npmjs.com/package/@editora/react) |
|
|
66
|
+
| `toast` | `@editora/toast` | [`@editora/toast`](https://www.npmjs.com/package/@editora/toast) |
|
|
67
|
+
| `react-icons` | `@editora/react-icons` | [`@editora/react-icons`](https://www.npmjs.com/package/@editora/react-icons) |
|
|
68
|
+
| `light-code-editor` | `@editora/light-code-editor` | [`@editora/light-code-editor`](https://www.npmjs.com/package/@editora/light-code-editor) |
|
|
69
|
+
| `button`, `data-table`, `tabs`, `modal`, ... | `@editora/ui-react` | [`@editora/ui-react`](https://www.npmjs.com/package/@editora/ui-react) |
|
|
70
|
+
| `all` | all of the above | |
|
|
51
71
|
|
|
52
|
-
|
|
72
|
+
The last two rows are the components of [`@editora/ui-react`](https://www.npmjs.com/package/@editora/ui-react): every
|
|
73
|
+
component it exports can be added by name, written the way you like (`data-table`, `datatable` and `DataTable` are the
|
|
74
|
+
same). A leading `ui-` is allowed, so `ui-select` is `select`. Parts of a compound component, such as `AlertTitle`, come
|
|
75
|
+
with the component they belong to. `modal` is a name for `Dialog` and installs the same package.
|
|
53
76
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
77
|
+
Two names are not what they seem. `toast` is the notification package, `@editora/toast`, and `ui-toast` is the toast
|
|
78
|
+
component of `@editora/ui-react`. And `editor` installs the packages, but you still need `react` and `react-dom` in your
|
|
79
|
+
project, and `@editora/core`, which `@editora/react` lists as a peer dependency: npm 7 and later install it for you, and
|
|
80
|
+
with a package manager that does not, add it yourself.
|
|
81
|
+
|
|
82
|
+
## Several at once
|
|
83
|
+
|
|
84
|
+
Give as many names as you like. The packages are installed with one command, and a package that two names share is
|
|
85
|
+
installed once:
|
|
86
|
+
|
|
87
|
+
```text
|
|
88
|
+
$ npx @editora/cli add button modal toast --dry-run
|
|
89
|
+
Editora add targets: button, modal, toast
|
|
90
|
+
- button: UI component (button) from @editora/ui-react
|
|
91
|
+
- modal: Use Dialog from @editora/ui-react as modal primitive
|
|
92
|
+
- toast: Notification runtime
|
|
93
|
+
|
|
94
|
+
Installing with npm: npm install @editora/ui-react @editora/toast
|
|
95
|
+
|
|
96
|
+
Dry run enabled. No packages were installed.
|
|
57
97
|
```
|
|
58
98
|
|
|
59
|
-
|
|
99
|
+
## Choose the package manager
|
|
100
|
+
|
|
101
|
+
The CLI uses the package manager that started it: `npm_config_user_agent`, which npm, pnpm, yarn and bun set for the
|
|
102
|
+
commands they run. Run through `npx`, or on its own after `npm install -g`, that is npm. It does not read your lock
|
|
103
|
+
file, so in a project that uses pnpm, yarn or bun, start it with that tool (`pnpm dlx @editora/cli add editor`,
|
|
104
|
+
`yarn dlx`, `bunx`) or say which one you want:
|
|
60
105
|
|
|
61
106
|
```bash
|
|
62
|
-
npx @editora/cli add
|
|
63
|
-
|
|
107
|
+
npx @editora/cli add button --package-manager pnpm
|
|
108
|
+
npx @editora/cli add button --package-manager=yarn
|
|
109
|
+
npx @editora/cli add button --package-manager bun
|
|
64
110
|
```
|
|
65
111
|
|
|
66
|
-
|
|
112
|
+
<p align="center">
|
|
113
|
+
<img src="https://raw.githubusercontent.com/ajaykr089/Editora/main/packages/cli/docs/images/package-managers.png" alt="A terminal running add button --dry-run with each package manager: npm install, pnpm add, yarn add and bun add, followed by deno, which is refused with Unsupported package manager: deno" width="760">
|
|
114
|
+
</p>
|
|
67
115
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
116
|
+
## When something is wrong
|
|
117
|
+
|
|
118
|
+
A name it does not know prints what is supported and exits with status 1. A missing name, an unknown option or an unknown
|
|
119
|
+
command print the usage text and exit with status 1 too.
|
|
120
|
+
|
|
121
|
+
```text
|
|
122
|
+
$ npx @editora/cli add floating-ui
|
|
123
|
+
Unknown feature(s): floating-ui
|
|
124
|
+
Supported:
|
|
125
|
+
- all exported @editora/ui-react component names
|
|
126
|
+
- special: all, card, editor, light-code-editor, modal, react-icons, toast, ui-components, ui-react
|
|
71
127
|
```
|
|
72
128
|
|
|
73
|
-
|
|
129
|
+
An unsupported package manager does the same:
|
|
130
|
+
|
|
131
|
+
```text
|
|
132
|
+
$ npx @editora/cli add button --package-manager deno
|
|
133
|
+
Unsupported package manager: deno
|
|
134
|
+
```
|
|
74
135
|
|
|
75
|
-
|
|
136
|
+
If the package manager is not installed, the CLI says so and exits with status 1. If the install itself fails, the exit
|
|
137
|
+
status is the package manager's own, so a script or a CI job stops where the install did.
|
|
76
138
|
|
|
77
139
|
```bash
|
|
78
|
-
npx @editora/cli
|
|
79
|
-
npx @editora/cli
|
|
80
|
-
npx @editora/cli add datatable
|
|
81
|
-
npx @editora/cli add editor
|
|
82
|
-
npx @editora/cli add toast
|
|
83
|
-
npx @editora/cli add accordion
|
|
84
|
-
npx @editora/cli add ui-select
|
|
140
|
+
npx @editora/cli --help # the usage text
|
|
141
|
+
npx @editora/cli --version # the version of the CLI
|
|
85
142
|
```
|
|
86
143
|
|
|
87
|
-
##
|
|
144
|
+
## Use it from code
|
|
88
145
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
146
|
+
The helpers behind the command are exported, for a script that wants to know what a name installs. They are plain
|
|
147
|
+
JavaScript with no type declarations, for `require` and `import` alike.
|
|
148
|
+
|
|
149
|
+
```js
|
|
150
|
+
const { resolveTarget, installCommand } = require('@editora/cli');
|
|
151
|
+
|
|
152
|
+
const target = resolveTarget('data-table');
|
|
153
|
+
console.log(target.canonicalName, target.entry.packages);
|
|
154
|
+
console.log(installCommand('pnpm', target.entry.packages));
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
```text
|
|
158
|
+
data-table [ '@editora/ui-react' ]
|
|
159
|
+
[ 'pnpm', [ 'add', '@editora/ui-react' ] ]
|
|
97
160
|
```
|
|
98
161
|
|
|
99
|
-
|
|
162
|
+
`resolveTarget(name)` returns `null` for a name it does not know. The module also exports `run(argv)`, which does what
|
|
163
|
+
the command does and returns the exit status, `parseArgs`, `detectPackageManager`, `getVersion`, `formatHelpText`, the
|
|
164
|
+
list `uiReactComponents` and the table `specialRegistry`.
|
|
100
165
|
|
|
101
|
-
##
|
|
166
|
+
## License
|
|
102
167
|
|
|
103
|
-
|
|
104
|
-
- `--package-manager <npm|pnpm|yarn|bun>` forces the package manager.
|
|
105
|
-
- `--help` shows usage instructions.
|
|
106
|
-
- `--version` prints the CLI version.
|
|
168
|
+
MIT © [Ajay Kumar](https://github.com/ajaykr089)
|
package/bin/editora.js
CHANGED
|
@@ -32,6 +32,11 @@ const uiReactComponents = [
|
|
|
32
32
|
"alert",
|
|
33
33
|
"alert-dialog",
|
|
34
34
|
"alert-dialog-provider",
|
|
35
|
+
"anchor",
|
|
36
|
+
"animated-beam",
|
|
37
|
+
"animated-list",
|
|
38
|
+
"animated-number",
|
|
39
|
+
"animated-text",
|
|
35
40
|
"app-header",
|
|
36
41
|
"aspect-ratio",
|
|
37
42
|
"avatar",
|
|
@@ -41,62 +46,118 @@ const uiReactComponents = [
|
|
|
41
46
|
"breadcrumb",
|
|
42
47
|
"button",
|
|
43
48
|
"calendar",
|
|
49
|
+
"carousel",
|
|
44
50
|
"chart",
|
|
45
51
|
"checkbox",
|
|
52
|
+
"code-block",
|
|
53
|
+
"code-snippet",
|
|
46
54
|
"collapsible",
|
|
55
|
+
"collection",
|
|
47
56
|
"color-picker",
|
|
48
57
|
"combobox",
|
|
58
|
+
"command",
|
|
49
59
|
"command-palette",
|
|
60
|
+
"composite",
|
|
50
61
|
"container",
|
|
51
62
|
"context-menu",
|
|
63
|
+
"control-group",
|
|
64
|
+
"copy-button",
|
|
52
65
|
"data-table",
|
|
66
|
+
"data-view-toolbar",
|
|
67
|
+
"date-field",
|
|
53
68
|
"date-picker",
|
|
54
69
|
"date-range-picker",
|
|
55
70
|
"date-range-time-picker",
|
|
56
71
|
"date-time-picker",
|
|
72
|
+
"description",
|
|
57
73
|
"dialog",
|
|
58
74
|
"dialog-provider",
|
|
59
75
|
"direction-provider",
|
|
76
|
+
"dismissable-layer",
|
|
77
|
+
"dock",
|
|
60
78
|
"drawer",
|
|
61
79
|
"dropdown",
|
|
80
|
+
"dropzone",
|
|
62
81
|
"empty-state",
|
|
63
82
|
"field",
|
|
83
|
+
"file-upload",
|
|
84
|
+
"filters-bar",
|
|
64
85
|
"flex",
|
|
86
|
+
"floating-arrow",
|
|
87
|
+
"floating-delay-group",
|
|
88
|
+
"floating-focus-manager",
|
|
89
|
+
"floating-list",
|
|
90
|
+
"floating-overlay",
|
|
91
|
+
"floating-portal",
|
|
65
92
|
"floating-toolbar",
|
|
93
|
+
"floating-tree",
|
|
94
|
+
"focus-scope",
|
|
66
95
|
"form",
|
|
67
96
|
"gantt",
|
|
68
97
|
"grid",
|
|
69
98
|
"hover-card",
|
|
70
99
|
"icon",
|
|
100
|
+
"inline-edit",
|
|
71
101
|
"input",
|
|
102
|
+
"kbd",
|
|
72
103
|
"label",
|
|
73
104
|
"layout",
|
|
105
|
+
"listbox",
|
|
106
|
+
"marquee",
|
|
107
|
+
"masonry-grid",
|
|
74
108
|
"menu",
|
|
75
109
|
"menubar",
|
|
110
|
+
"meter",
|
|
111
|
+
"metric-card",
|
|
112
|
+
"multi-select",
|
|
76
113
|
"navigation-menu",
|
|
114
|
+
"number-field",
|
|
115
|
+
"number-ticker",
|
|
116
|
+
"orbiter",
|
|
117
|
+
"otp-input",
|
|
118
|
+
"page-header",
|
|
119
|
+
"page-toolbar",
|
|
77
120
|
"pagination",
|
|
121
|
+
"panel",
|
|
122
|
+
"panel-group",
|
|
123
|
+
"password-field",
|
|
124
|
+
"pin-input",
|
|
125
|
+
"placement-grid",
|
|
78
126
|
"plugin-panel",
|
|
79
127
|
"popover",
|
|
80
128
|
"portal",
|
|
129
|
+
"positioner",
|
|
81
130
|
"presence",
|
|
82
131
|
"progress",
|
|
83
132
|
"quick-actions",
|
|
133
|
+
"radio",
|
|
84
134
|
"radio-group",
|
|
135
|
+
"rating",
|
|
136
|
+
"record-header",
|
|
137
|
+
"roving-focus-group",
|
|
85
138
|
"scroll-area",
|
|
86
139
|
"section",
|
|
87
140
|
"select",
|
|
88
141
|
"selection-popup",
|
|
89
142
|
"separator",
|
|
143
|
+
"shortcut",
|
|
90
144
|
"sidebar",
|
|
91
145
|
"skeleton",
|
|
92
146
|
"slider",
|
|
93
147
|
"slot",
|
|
148
|
+
"sortable",
|
|
149
|
+
"spinning-text",
|
|
150
|
+
"split-button",
|
|
151
|
+
"splitter",
|
|
152
|
+
"stat",
|
|
94
153
|
"stepper",
|
|
95
154
|
"switch",
|
|
96
155
|
"table",
|
|
97
156
|
"tabs",
|
|
157
|
+
"tags-input",
|
|
98
158
|
"textarea",
|
|
99
159
|
"theme-provider",
|
|
160
|
+
"time-field",
|
|
100
161
|
"time-picker",
|
|
101
162
|
"timeline",
|
|
102
163
|
"toast",
|
|
@@ -105,6 +166,8 @@ const uiReactComponents = [
|
|
|
105
166
|
"toggle-group",
|
|
106
167
|
"toolbar",
|
|
107
168
|
"tooltip",
|
|
169
|
+
"transfer-list",
|
|
170
|
+
"tree",
|
|
108
171
|
"visually-hidden",
|
|
109
172
|
"wizard"
|
|
110
173
|
];
|
|
@@ -380,7 +443,17 @@ function run(argv) {
|
|
|
380
443
|
return 0;
|
|
381
444
|
}
|
|
382
445
|
|
|
383
|
-
|
|
446
|
+
// npm, pnpm and yarn are .cmd files on Windows, which only a shell can start. The arguments are package names from the
|
|
447
|
+
// registry above, never user input, so joining them into one command line is safe.
|
|
448
|
+
const result =
|
|
449
|
+
process.platform === "win32"
|
|
450
|
+
? spawnSync([cmd, ...cmdArgs].join(" "), { stdio: "inherit", shell: true })
|
|
451
|
+
: spawnSync(cmd, cmdArgs, { stdio: "inherit" });
|
|
452
|
+
if (result.error) {
|
|
453
|
+
console.error(`Could not run ${cmd}: ${result.error.message}`);
|
|
454
|
+
console.error(`Install ${cmd}, or pick another with --package-manager <npm|pnpm|yarn|bun>.`);
|
|
455
|
+
return 1;
|
|
456
|
+
}
|
|
384
457
|
return result.status == null ? 1 : result.status;
|
|
385
458
|
}
|
|
386
459
|
|
package/package.json
CHANGED