@object-ui/create-plugin 17.6.0 → 17.7.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/CHANGELOG.md CHANGED
@@ -1,5 +1,145 @@
1
1
  # @object-ui/create-plugin
2
2
 
3
+ ## 17.7.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 6cc48c4: Ask for the plugin's licence and ship the text it claims (objectui#8041, director
8
+ decision batch #91, 2026-09-08).
9
+
10
+ **The defect.** `buildPackageJson` wrote `license: 'MIT'` into every generated
11
+ manifest — unconditionally, and without ever asking — while `buildPluginFiles`
12
+ emitted nine files, none of them a LICENSE. The generated manifest declares no
13
+ `files` array, so `npm pack` takes npm's default set, which packs `LICENSE*`
14
+ whether or not anything lists it; the file simply was not on disk to pack. An
15
+ author who published a freshly scaffolded plugin therefore shipped a tarball that
16
+ **claimed a licence it did not carry**, on a choice made for them by this
17
+ generator.
18
+
19
+ **What changes, for a scaffolded package.**
20
+
21
+ - The scaffolder now asks `License:` as a chooser over `MIT`, `Apache-2.0`,
22
+ `BSD-3-Clause` and `ISC`, with **MIT preselected**. It is the fourth question,
23
+ after plugin name, description and author; the first three are unchanged.
24
+ - The emitted file set goes from **nine files to ten** — a `LICENSE` carrying the
25
+ full text of whatever was chosen, with the copyright line filled in from the
26
+ author and the current year. When the author prompt was left blank the holder
27
+ reads `the <package name> authors` rather than trailing off after the year.
28
+ - The manifest's `license`, the README's `## License` section and the licence
29
+ named in the four emitted source-file headers all follow the choice, instead of
30
+ four of them saying MIT while the fifth says something else.
31
+ - **A non-interactive run takes MIT and still writes the text.** A non-TTY stdin,
32
+ a cancelled prompt and any unrecognised value all resolve to MIT; there is no
33
+ input for which the generator emits a licence claim with no text beside it.
34
+
35
+ Omitting `license` instead was refused on the record: an unlicensed manifest reads
36
+ as all-rights-reserved on npm, which is the worse default for the author this
37
+ change is written for. The four licence texts are copied verbatim from canonical
38
+ copies rather than retyped — a paraphrased licence is not a licence, and a
39
+ transcription typo in one is invisible to every gate this repository has.
40
+
41
+ Nothing an already-generated plugin does changes; this moves what the next one is
42
+ born with.
43
+ - 7e247e2: Make the documented non-interactive run real, and stop a cancelled prompt from
44
+ crashing the generator (objectui#8786).
45
+
46
+ **The defect.** `prompts` hands back the answers given SO FAR when a question is
47
+ cancelled — the cancelled question and every question after it are simply absent
48
+ — and the generator read `answers.author` raw. Cancelling at `Plugin
49
+ description:` or `Author name:` therefore reached
50
+ `licenseCopyrightHolder(vars)`, dereferenced `undefined.trim()`, and died with a
51
+ `TypeError` and exit 1. It died *after* the target directory had been created,
52
+ so it left an empty `packages/plugin-NAME/` behind and the obvious retry failed
53
+ on "Directory already exists" instead. Cancelling at the fourth question
54
+ (`License:`) was unaffected, because nothing is left unanswered after it.
55
+
56
+ **The false claim.** The README promised that "a non-interactive run (no TTY, or
57
+ a cancelled prompt) takes MIT and still writes the text". `prompts` never
58
+ settles on a stdin that is not a TTY: no `submit`, no `abort`, the process ran
59
+ out of work and exited 0 having written nothing at all, in silence.
60
+
61
+ **One rule now covers both.** An answer that is not given takes the default its
62
+ prompt offered, and the complete ten-file set is still written — whether the run
63
+ was cancelled or never had a TTY to ask on. The plugin name keeps its own
64
+ behaviour, being the one answer with no default: a run that reaches the name
65
+ prompt with no TTY, or cancels it, now prints `Plugin name is required` and
66
+ exits 1 without creating anything (it used to exit 0 in silence). `--description`
67
+ and `--author` set the defaults such a run writes, so
68
+ `create-plugin my-plugin --author "Ada"` scaffolds correctly from a CI step.
69
+
70
+ Nothing an interactive, fully answered run produces changes, and neither does
71
+ what a cancel at `License:` produces: MIT and the same ten files. Templating now
72
+ also happens before anything is created on disk, so no failure inside
73
+ `buildPluginFiles` can leave a half-created directory behind.
74
+
75
+ ### Patch Changes
76
+
77
+ - 059bf1b: The generated plugin's `jsdom` devDependency is now `^29.1.1` instead of
78
+ `^30.0.1` (objectui#11366).
79
+
80
+ jsdom 30 declares `engines.node` as `^22.22.2 || ^24.15.0 || >=26.0.0`, so on
81
+ the Node 22 line a scaffolded plugin's test stack needed 22.22.2 or later, and
82
+ an install with `engine-strict=true` refused every earlier 22.x release. jsdom
83
+ 29.1.x declares `^20.19.0 || ^22.13.0 || >=24.0.0`, which brings that floor down
84
+ to 22.13. The generated `vite.config.ts` still runs the example test with
85
+ `environment: 'jsdom'`, and no other generated file changes.
86
+
87
+ The range is copied from this repository's root manifest, which is the anchor
88
+ `templates.test.ts` holds the scaffold to. The root moves to the same jsdom line
89
+ in this change, and its `engines.node` floor becomes `>=22.13`, the highest
90
+ lower bound the locked dependencies set on the 22 line. The root package is
91
+ private, so that half needs no changeset of its own.
92
+ - 80eb9ed: create-plugin: stop writing an "ObjectStack Inc." copyright header onto the plugin author's own source files
93
+
94
+ `buildIndexFile`, `buildImplFile`, `buildTypesFile` and `buildTestFile` — the
95
+ four builders that write source into the scaffolded package — each opened the
96
+ file they emit with `Copyright (c) <year>-present ObjectStack Inc.` under an
97
+ `ObjectUI` title line. Those four files are the author's own code: the package
98
+ entry, the component implementation, its schema types and its example test. The
99
+ notice named this project as the copyright holder of source the author had not
100
+ written yet, in a package they publish under their own name — a stronger claim
101
+ than the licence one objectui#8041 removed, which asserted a licence *choice*
102
+ rather than *ownership*.
103
+
104
+ Both lines are gone and **nothing replaces them**. A scaffolded `src/*` file now
105
+ carries no copyright line, no holder, no year and no SPDX id — not even the
106
+ author's own name, which would be this generator making a legal assertion about
107
+ the author's code just as the old line did.
108
+
109
+ What stays is the licence pointer, because it is true: `This source code is
110
+ licensed under the <id> license found in the LICENSE file in the root directory
111
+ of this source tree.` The id is the licence the author chose at the prompt
112
+ (objectui#8041), the LICENSE it points at really is emitted beside those files,
113
+ and `buildLicenseFile` refuses an id it has no text for (objectui#8892) — so it
114
+ cannot name a licence the package does not carry. It also remains one of the six
115
+ agreeing licence statements those two cards built, alongside the manifest and
116
+ the README.
117
+
118
+ No prompt, no manifest field and no other emitted file changes.
119
+ - 7a3ff77: create-plugin: refuse a licence id the generator has no text for, instead of scaffolding a plugin whose LICENSE contradicts its own manifest
120
+
121
+ `buildLicenseFile` used to answer an unoffered licence id with MIT's text. The id
122
+ reaches a scaffolded plugin through six statements and that was the only one
123
+ that resolved it — `package.json`, the README's `## License` line and four
124
+ source-file headers take it verbatim — so the substitution did not remove the
125
+ "a manifest claiming a licence with no text beside it" state its docblock
126
+ promised to remove. It authored a worse one: a plugin naming one licence five
127
+ times and carrying a different licence's text, which the author then publishes.
128
+
129
+ The unoffered id is refused now, with an error naming the offending id and the
130
+ ids that would be accepted. Nothing reachable changes: `resolveLicenseId` is
131
+ total onto the four offered ids and the CLI is the only caller, so no scaffold
132
+ that works today starts failing.
133
+ - e7e45d8: Type the `test:` block in the scaffolded `vite.config.ts`.
134
+
135
+ The emitted config passed a `test:` block to a `defineConfig` imported from
136
+ `vite`, whose `UserConfig` declares no `test` key — TS2769 in every editor a
137
+ freshly scaffolded plugin is opened in, on day one, for every plugin this
138
+ generator writes. The config now carries `/// <reference types="vitest/config" />`,
139
+ which pulls in vitest's `declare module "vite"` augmentation and supplies the
140
+ missing declaration at zero run-time cost. The `test:` block itself is unchanged
141
+ and stays: it is the only thing giving the scaffolded example test a DOM.
142
+
3
143
  ## 17.6.0
4
144
 
5
145
  ### Patch Changes
package/README.md CHANGED
@@ -30,6 +30,7 @@ packages/plugin-my-plugin/
30
30
  ├── tsconfig.json
31
31
  ├── vite.config.ts
32
32
  ├── vitest.setup.ts # Registers the jest-dom matchers
33
+ ├── LICENSE # Full text of the licence you chose
33
34
  └── README.md
34
35
  ```
35
36
 
@@ -41,6 +42,8 @@ packages/plugin-my-plugin/
41
42
  - ✅ Runnable Vitest setup — jsdom environment, Testing Library and the jest-dom
42
43
  matchers are all declared, so `pnpm test` is green on the first run
43
44
  - ✅ Proper package.json with workspace dependencies
45
+ - ✅ A LICENSE carrying the full text of the licence the manifest declares —
46
+ never a `license` field with nothing behind it
44
47
  - ✅ README template
45
48
  - ✅ Type definitions
46
49
 
@@ -56,6 +59,36 @@ You'll be prompted for:
56
59
  - Plugin name
57
60
  - Description
58
61
  - Author name
62
+ - License — `MIT` (default), `Apache-2.0`, `BSD-3-Clause` or `ISC`
63
+
64
+ The licence you pick is written to `package.json` and its **full text** is written
65
+ to `LICENSE`, so a published tarball never claims a licence it does not carry. A
66
+ non-interactive run (no TTY, or a cancelled prompt) takes MIT and still writes the
67
+ text.
68
+
69
+ ## Non-interactive Runs and Cancelling
70
+
71
+ One rule covers every answer you do not give: **it takes the default the prompt
72
+ offered, and the complete file set is still written.** There are two ways an
73
+ answer goes missing, and they behave the same way:
74
+
75
+ - **No TTY** — a pipe, a CI step, `create-plugin my-plugin < /dev/null`. Nothing
76
+ is asked; every prompt takes its default and the plugin is scaffolded.
77
+ - **Cancelling** — Ctrl-C at a prompt. The questions stop there; the cancelled
78
+ question and the ones after it take their defaults.
79
+
80
+ The **plugin name** is the one exception, because it is the one answer with no
81
+ default — a scaffolder cannot invent the package it is scaffolding. A run that
82
+ reaches the name prompt with no TTY, or cancels it, prints `Plugin name is
83
+ required` and exits `1` **without creating anything**. Pass the name as an
84
+ argument to scaffold non-interactively:
85
+
86
+ ```bash
87
+ create-plugin my-plugin --author "Your Name" < /dev/null
88
+ ```
89
+
90
+ `--description` and `--author` set the defaults their prompts start from, so they
91
+ are also what a non-interactive run writes.
59
92
 
60
93
  ## Options
61
94
 
package/dist/index.js CHANGED
@@ -7,13 +7,305 @@ import prompts from "prompts";
7
7
  import * as path from "path";
8
8
  import fs from "fs-extra";
9
9
 
10
+ // src/licenses.ts
11
+ var MIT = ({ year, holder }) => `MIT License
12
+
13
+ Copyright (c) ${year} ${holder}
14
+
15
+ Permission is hereby granted, free of charge, to any person obtaining a copy
16
+ of this software and associated documentation files (the "Software"), to deal
17
+ in the Software without restriction, including without limitation the rights
18
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
19
+ copies of the Software, and to permit persons to whom the Software is
20
+ furnished to do so, subject to the following conditions:
21
+
22
+ The above copyright notice and this permission notice shall be included in all
23
+ copies or substantial portions of the Software.
24
+
25
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
30
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31
+ SOFTWARE.
32
+ `;
33
+ var APACHE_2_0 = ({ year, holder }) => ` Apache License
34
+ Version 2.0, January 2004
35
+ http://www.apache.org/licenses/
36
+
37
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
38
+
39
+ 1. Definitions.
40
+
41
+ "License" shall mean the terms and conditions for use, reproduction,
42
+ and distribution as defined by Sections 1 through 9 of this document.
43
+
44
+ "Licensor" shall mean the copyright owner or entity authorized by
45
+ the copyright owner that is granting the License.
46
+
47
+ "Legal Entity" shall mean the union of the acting entity and all
48
+ other entities that control, are controlled by, or are under common
49
+ control with that entity. For the purposes of this definition,
50
+ "control" means (i) the power, direct or indirect, to cause the
51
+ direction or management of such entity, whether by contract or
52
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
53
+ outstanding shares, or (iii) beneficial ownership of such entity.
54
+
55
+ "You" (or "Your") shall mean an individual or Legal Entity
56
+ exercising permissions granted by this License.
57
+
58
+ "Source" form shall mean the preferred form for making modifications,
59
+ including but not limited to software source code, documentation
60
+ source, and configuration files.
61
+
62
+ "Object" form shall mean any form resulting from mechanical
63
+ transformation or translation of a Source form, including but
64
+ not limited to compiled object code, generated documentation,
65
+ and conversions to other media types.
66
+
67
+ "Work" shall mean the work of authorship, whether in Source or
68
+ Object form, made available under the License, as indicated by a
69
+ copyright notice that is included in or attached to the work
70
+ (an example is provided in the Appendix below).
71
+
72
+ "Derivative Works" shall mean any work, whether in Source or Object
73
+ form, that is based on (or derived from) the Work and for which the
74
+ editorial revisions, annotations, elaborations, or other modifications
75
+ represent, as a whole, an original work of authorship. For the purposes
76
+ of this License, Derivative Works shall not include works that remain
77
+ separable from, or merely link (or bind by name) to the interfaces of,
78
+ the Work and Derivative Works thereof.
79
+
80
+ "Contribution" shall mean any work of authorship, including
81
+ the original version of the Work and any modifications or additions
82
+ to that Work or Derivative Works thereof, that is intentionally
83
+ submitted to Licensor for inclusion in the Work by the copyright owner
84
+ or by an individual or Legal Entity authorized to submit on behalf of
85
+ the copyright owner. For the purposes of this definition, "submitted"
86
+ means any form of electronic, verbal, or written communication sent
87
+ to the Licensor or its representatives, including but not limited to
88
+ communication on electronic mailing lists, source code control systems,
89
+ and issue tracking systems that are managed by, or on behalf of, the
90
+ Licensor for the purpose of discussing and improving the Work, but
91
+ excluding communication that is conspicuously marked or otherwise
92
+ designated in writing by the copyright owner as "Not a Contribution."
93
+
94
+ "Contributor" shall mean Licensor and any individual or Legal Entity
95
+ on behalf of whom a Contribution has been received by Licensor and
96
+ subsequently incorporated within the Work.
97
+
98
+ 2. Grant of Copyright License. Subject to the terms and conditions of
99
+ this License, each Contributor hereby grants to You a perpetual,
100
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
101
+ copyright license to reproduce, prepare Derivative Works of,
102
+ publicly display, publicly perform, sublicense, and distribute the
103
+ Work and such Derivative Works in Source or Object form.
104
+
105
+ 3. Grant of Patent License. Subject to the terms and conditions of
106
+ this License, each Contributor hereby grants to You a perpetual,
107
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
108
+ (except as stated in this section) patent license to make, have made,
109
+ use, offer to sell, sell, import, and otherwise transfer the Work,
110
+ where such license applies only to those patent claims licensable
111
+ by such Contributor that are necessarily infringed by their
112
+ Contribution(s) alone or by combination of their Contribution(s)
113
+ with the Work to which such Contribution(s) was submitted. If You
114
+ institute patent litigation against any entity (including a
115
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
116
+ or a Contribution incorporated within the Work constitutes direct
117
+ or contributory patent infringement, then any patent licenses
118
+ granted to You under this License for that Work shall terminate
119
+ as of the date such litigation is filed.
120
+
121
+ 4. Redistribution. You may reproduce and distribute copies of the
122
+ Work or Derivative Works thereof in any medium, with or without
123
+ modifications, and in Source or Object form, provided that You
124
+ meet the following conditions:
125
+
126
+ (a) You must give any other recipients of the Work or
127
+ Derivative Works a copy of this License; and
128
+
129
+ (b) You must cause any modified files to carry prominent notices
130
+ stating that You changed the files; and
131
+
132
+ (c) You must retain, in the Source form of any Derivative Works
133
+ that You distribute, all copyright, patent, trademark, and
134
+ attribution notices from the Source form of the Work,
135
+ excluding those notices that do not pertain to any part of
136
+ the Derivative Works; and
137
+
138
+ (d) If the Work includes a "NOTICE" text file as part of its
139
+ distribution, then any Derivative Works that You distribute must
140
+ include a readable copy of the attribution notices contained
141
+ within such NOTICE file, excluding those notices that do not
142
+ pertain to any part of the Derivative Works, in at least one
143
+ of the following places: within a NOTICE text file distributed
144
+ as part of the Derivative Works; within the Source form or
145
+ documentation, if provided along with the Derivative Works; or,
146
+ within a display generated by the Derivative Works, if and
147
+ wherever such third-party notices normally appear. The contents
148
+ of the NOTICE file are for informational purposes only and
149
+ do not modify the License. You may add Your own attribution
150
+ notices within Derivative Works that You distribute, alongside
151
+ or as an addendum to the NOTICE text from the Work, provided
152
+ that such additional attribution notices cannot be construed
153
+ as modifying the License.
154
+
155
+ You may add Your own copyright statement to Your modifications and
156
+ may provide additional or different license terms and conditions
157
+ for use, reproduction, or distribution of Your modifications, or
158
+ for any such Derivative Works as a whole, provided Your use,
159
+ reproduction, and distribution of the Work otherwise complies with
160
+ the conditions stated in this License.
161
+
162
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
163
+ any Contribution intentionally submitted for inclusion in the Work
164
+ by You to the Licensor shall be under the terms and conditions of
165
+ this License, without any additional terms or conditions.
166
+ Notwithstanding the above, nothing herein shall supersede or modify
167
+ the terms of any separate license agreement you may have executed
168
+ with Licensor regarding such Contributions.
169
+
170
+ 6. Trademarks. This License does not grant permission to use the trade
171
+ names, trademarks, service marks, or product names of the Licensor,
172
+ except as required for reasonable and customary use in describing the
173
+ origin of the Work and reproducing the content of the NOTICE file.
174
+
175
+ 7. Disclaimer of Warranty. Unless required by applicable law or
176
+ agreed to in writing, Licensor provides the Work (and each
177
+ Contributor provides its Contributions) on an "AS IS" BASIS,
178
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
179
+ implied, including, without limitation, any warranties or conditions
180
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
181
+ PARTICULAR PURPOSE. You are solely responsible for determining the
182
+ appropriateness of using or redistributing the Work and assume any
183
+ risks associated with Your exercise of permissions under this License.
184
+
185
+ 8. Limitation of Liability. In no event and under no legal theory,
186
+ whether in tort (including negligence), contract, or otherwise,
187
+ unless required by applicable law (such as deliberate and grossly
188
+ negligent acts) or agreed to in writing, shall any Contributor be
189
+ liable to You for damages, including any direct, indirect, special,
190
+ incidental, or consequential damages of any character arising as a
191
+ result of this License or out of the use or inability to use the
192
+ Work (including but not limited to damages for loss of goodwill,
193
+ work stoppage, computer failure or malfunction, or any and all
194
+ other commercial damages or losses), even if such Contributor
195
+ has been advised of the possibility of such damages.
196
+
197
+ 9. Accepting Warranty or Additional Liability. While redistributing
198
+ the Work or Derivative Works thereof, You may choose to offer,
199
+ and charge a fee for, acceptance of support, warranty, indemnity,
200
+ or other liability obligations and/or rights consistent with this
201
+ License. However, in accepting such obligations, You may act only
202
+ on Your own behalf and on Your sole responsibility, not on behalf
203
+ of any other Contributor, and only if You agree to indemnify,
204
+ defend, and hold each Contributor harmless for any liability
205
+ incurred by, or claims asserted against, such Contributor by reason
206
+ of your accepting any such warranty or additional liability.
207
+
208
+ END OF TERMS AND CONDITIONS
209
+
210
+ APPENDIX: How to apply the Apache License to your work.
211
+
212
+ To apply the Apache License to your work, attach the following
213
+ boilerplate notice, with the fields enclosed by brackets "[]"
214
+ replaced with your own identifying information. (Don't include
215
+ the brackets!) The text should be enclosed in the appropriate
216
+ comment syntax for the file format. We also recommend that a
217
+ file or class name and description of purpose be included on the
218
+ same "printed page" as the copyright notice for easier
219
+ identification within third-party archives.
220
+
221
+ Copyright ${year} ${holder}
222
+
223
+ Licensed under the Apache License, Version 2.0 (the "License");
224
+ you may not use this file except in compliance with the License.
225
+ You may obtain a copy of the License at
226
+
227
+ http://www.apache.org/licenses/LICENSE-2.0
228
+
229
+ Unless required by applicable law or agreed to in writing, software
230
+ distributed under the License is distributed on an "AS IS" BASIS,
231
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
232
+ See the License for the specific language governing permissions and
233
+ limitations under the License.
234
+ `;
235
+ var BSD_3_CLAUSE = ({ year, holder }) => `BSD 3-Clause License
236
+
237
+ Copyright (c) ${year}, ${holder}
238
+ All rights reserved.
239
+
240
+ Redistribution and use in source and binary forms, with or without
241
+ modification, are permitted provided that the following conditions are met:
242
+
243
+ 1. Redistributions of source code must retain the above copyright notice, this
244
+ list of conditions and the following disclaimer.
245
+
246
+ 2. Redistributions in binary form must reproduce the above copyright notice,
247
+ this list of conditions and the following disclaimer in the documentation
248
+ and/or other materials provided with the distribution.
249
+
250
+ 3. Neither the name of the copyright holder nor the names of its
251
+ contributors may be used to endorse or promote products derived from
252
+ this software without specific prior written permission.
253
+
254
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
255
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
256
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
257
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
258
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
259
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
260
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
261
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
262
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
263
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
264
+ `;
265
+ var ISC = ({ year, holder }) => `ISC License
266
+
267
+ Copyright (c) ${year} ${holder}
268
+
269
+ Permission to use, copy, modify, and/or distribute this software for any purpose
270
+ with or without fee is hereby granted, provided that the above copyright notice
271
+ and this permission notice appear in all copies.
272
+
273
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
274
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
275
+ FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
276
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
277
+ OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
278
+ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
279
+ THIS SOFTWARE.
280
+ `;
281
+ var PLUGIN_LICENSES = [
282
+ { id: "MIT", name: "MIT License", text: MIT },
283
+ { id: "Apache-2.0", name: "Apache License 2.0", text: APACHE_2_0 },
284
+ { id: "BSD-3-Clause", name: "BSD 3-Clause License", text: BSD_3_CLAUSE },
285
+ { id: "ISC", name: "ISC License", text: ISC }
286
+ ];
287
+ var DEFAULT_LICENSE_ID = "MIT";
288
+ function findLicense(id) {
289
+ return PLUGIN_LICENSES.find((license) => license.id === id);
290
+ }
291
+ var LICENSE_PROMPT = {
292
+ type: "select",
293
+ name: "license",
294
+ message: "License:",
295
+ choices: PLUGIN_LICENSES.map((license) => ({ title: license.id, description: license.name, value: license.id })),
296
+ initial: PLUGIN_LICENSES.findIndex((license) => license.id === DEFAULT_LICENSE_ID)
297
+ };
298
+ function resolveLicenseId(answer) {
299
+ return typeof answer === "string" && findLicense(answer) !== void 0 ? answer : DEFAULT_LICENSE_ID;
300
+ }
301
+
10
302
  // src/templates.ts
11
303
  var VITEST_SETUP_FILE = "vitest.setup.ts";
12
304
  var DEV_DEPENDENCIES = {
13
305
  "@testing-library/jest-dom": "^7.0.1",
14
306
  "@testing-library/react": "^16.3.2",
15
307
  "@vitejs/plugin-react": "^6.0.5",
16
- jsdom: "^30.0.1",
308
+ jsdom: "^29.1.1",
17
309
  typescript: "^6.0.3",
18
310
  vite: "^8.2.1",
19
311
  "vite-plugin-dts": "^5.0.3",
@@ -30,7 +322,7 @@ function buildPackageJson(vars) {
30
322
  name: vars.packageName,
31
323
  version: vars.version,
32
324
  type: "module",
33
- license: "MIT",
325
+ license: vars.license,
34
326
  description: vars.description,
35
327
  main: "dist/index.umd.cjs",
36
328
  module: "dist/index.js",
@@ -69,7 +361,8 @@ function buildTsconfig() {
69
361
  };
70
362
  }
71
363
  function buildViteConfig(vars) {
72
- return `import { defineConfig } from 'vite';
364
+ return `/// <reference types="vitest/config" />
365
+ import { defineConfig } from 'vite';
73
366
  import react from '@vitejs/plugin-react';
74
367
  import dts from 'vite-plugin-dts';
75
368
  import * as path from 'path';
@@ -147,15 +440,12 @@ pnpm lint
147
440
 
148
441
  ## License
149
442
 
150
- MIT \xA9 ${vars.author}
443
+ ${vars.license} \xA9 ${vars.author}
151
444
  `;
152
445
  }
153
446
  function buildIndexFile(vars) {
154
447
  return `/**
155
- * ObjectUI
156
- * Copyright (c) ${vars.year}-present ObjectStack Inc.
157
- *
158
- * This source code is licensed under the MIT license found in the
448
+ * This source code is licensed under the ${vars.license} license found in the
159
449
  * LICENSE file in the root directory of this source tree.
160
450
  */
161
451
 
@@ -186,10 +476,7 @@ ComponentRegistry.register('${vars.pluginName}', ${vars.pascalName}Renderer, {
186
476
  }
187
477
  function buildImplFile(vars) {
188
478
  return `/**
189
- * ObjectUI
190
- * Copyright (c) ${vars.year}-present ObjectStack Inc.
191
- *
192
- * This source code is licensed under the MIT license found in the
479
+ * This source code is licensed under the ${vars.license} license found in the
193
480
  * LICENSE file in the root directory of this source tree.
194
481
  */
195
482
 
@@ -215,10 +502,7 @@ export const ${vars.pascalName}: React.FC<${vars.pascalName}Props> = ({ classNam
215
502
  }
216
503
  function buildTypesFile(vars) {
217
504
  return `/**
218
- * ObjectUI
219
- * Copyright (c) ${vars.year}-present ObjectStack Inc.
220
- *
221
- * This source code is licensed under the MIT license found in the
505
+ * This source code is licensed under the ${vars.license} license found in the
222
506
  * LICENSE file in the root directory of this source tree.
223
507
  */
224
508
 
@@ -238,10 +522,7 @@ export interface ${vars.pascalName}Schema extends BaseSchema {
238
522
  }
239
523
  function buildTestFile(vars) {
240
524
  return `/**
241
- * ObjectUI
242
- * Copyright (c) ${vars.year}-present ObjectStack Inc.
243
- *
244
- * This source code is licensed under the MIT license found in the
525
+ * This source code is licensed under the ${vars.license} license found in the
245
526
  * LICENSE file in the root directory of this source tree.
246
527
  */
247
528
 
@@ -258,12 +539,25 @@ describe('${vars.pascalName}', () => {
258
539
  });
259
540
  `;
260
541
  }
542
+ function licenseCopyrightHolder(vars) {
543
+ return vars.author.trim() || `the ${vars.packageName} authors`;
544
+ }
545
+ function buildLicenseFile(vars) {
546
+ const license = findLicense(vars.license);
547
+ if (!license) {
548
+ throw new Error(
549
+ `create-plugin has no text for licence "${vars.license}", so it will not scaffold a plugin whose manifest, README and source headers name a licence its LICENSE file does not carry. Offered ids: ${PLUGIN_LICENSES.map((offered) => offered.id).join(", ")}. Resolve the answer with resolveLicenseId() before building PluginTemplateVars.`
550
+ );
551
+ }
552
+ return license.text({ year: vars.year, holder: licenseCopyrightHolder(vars) });
553
+ }
261
554
  function buildPluginFiles(vars) {
262
555
  return {
263
556
  "package.json": `${JSON.stringify(buildPackageJson(vars), null, 2)}`,
264
557
  "tsconfig.json": `${JSON.stringify(buildTsconfig(), null, 2)}`,
265
558
  "vite.config.ts": buildViteConfig(vars),
266
559
  [VITEST_SETUP_FILE]: buildVitestSetup(),
560
+ LICENSE: buildLicenseFile(vars),
267
561
  "README.md": buildReadme(vars),
268
562
  "src/index.tsx": buildIndexFile(vars),
269
563
  [`src/${vars.pascalName}Impl.tsx`]: buildImplFile(vars),
@@ -274,25 +568,31 @@ function buildPluginFiles(vars) {
274
568
 
275
569
  // src/index.ts
276
570
  var program = new Command();
571
+ function hasInteractiveStdin() {
572
+ return process.stdin.isTTY === true;
573
+ }
277
574
  async function createPlugin(pluginName, options = {}) {
278
575
  console.log(chalk.blue("\n\u{1F680} ObjectUI Plugin Generator\n"));
576
+ const interactive = hasInteractiveStdin();
279
577
  if (!pluginName) {
280
- const response = await prompts({
281
- type: "text",
282
- name: "name",
283
- message: "Plugin name (without prefix):",
284
- validate: (value) => {
285
- if (value.length === 0) return "Plugin name is required";
286
- if (!/^[a-z0-9-]+$/.test(value)) {
287
- return "Plugin name must contain only lowercase letters, numbers, and hyphens";
578
+ if (interactive) {
579
+ const response = await prompts({
580
+ type: "text",
581
+ name: "name",
582
+ message: "Plugin name (without prefix):",
583
+ validate: (value) => {
584
+ if (value.length === 0) return "Plugin name is required";
585
+ if (!/^[a-z0-9-]+$/.test(value)) {
586
+ return "Plugin name must contain only lowercase letters, numbers, and hyphens";
587
+ }
588
+ if (value.includes("..") || value.includes("/") || value.includes("\\")) {
589
+ return 'Plugin name cannot contain path separators or ".."';
590
+ }
591
+ return true;
288
592
  }
289
- if (value.includes("..") || value.includes("/") || value.includes("\\")) {
290
- return 'Plugin name cannot contain path separators or ".."';
291
- }
292
- return true;
293
- }
294
- });
295
- pluginName = response.name;
593
+ });
594
+ pluginName = response.name;
595
+ }
296
596
  if (!pluginName) {
297
597
  console.log(chalk.red("\n\u274C Plugin name is required"));
298
598
  process.exit(1);
@@ -313,40 +613,74 @@ async function createPlugin(pluginName, options = {}) {
313
613
  }
314
614
  const fullPackageName = `plugin-${cleanName}`;
315
615
  const pascalCaseName = cleanName.split("-").filter((part) => part.length > 0).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
316
- const answers = await prompts([
616
+ const descriptionInitial = options.description || `${pascalCaseName} plugin for ObjectUI`;
617
+ const authorInitial = options.author || "";
618
+ const questions = [
317
619
  {
318
620
  type: "text",
319
621
  name: "description",
320
622
  message: "Plugin description:",
321
- initial: options.description || `${pascalCaseName} plugin for ObjectUI`
623
+ initial: descriptionInitial
322
624
  },
323
625
  {
324
626
  type: "text",
325
627
  name: "author",
326
628
  message: "Author name:",
327
- initial: options.author || ""
629
+ initial: authorInitial
630
+ },
631
+ // objectui#8041: the generator used to assert `"license": "MIT"` on an
632
+ // author's package without asking, and then ship no LICENSE text beside
633
+ // the claim. The prompt is the consent half; `buildLicenseFile` is the
634
+ // text half. Taken from `./licenses` rather than written out here so the
635
+ // published prompt contract can be asserted — this module calls
636
+ // `program.parse()` at import time and so cannot be imported by a test.
637
+ LICENSE_PROMPT
638
+ ];
639
+ let cancelled = false;
640
+ const answers = interactive ? await prompts(questions, {
641
+ // Recording the cancel is all this does. Returning nothing keeps
642
+ // `prompts`' own behaviour — stop asking, hand back what was answered
643
+ // — and the questions that never ran take their `initial` below.
644
+ onCancel: () => {
645
+ cancelled = true;
328
646
  }
329
- ]);
647
+ }) : {};
648
+ if (!interactive) {
649
+ console.log(chalk.yellow("\u2139\uFE0F No TTY on stdin \u2014 every prompt takes its default."));
650
+ } else if (cancelled) {
651
+ console.log(chalk.yellow("\n\u26A0\uFE0F Cancelled \u2014 the unanswered prompts take their defaults."));
652
+ }
330
653
  const targetDir = path.join(process.cwd(), "packages", fullPackageName);
331
654
  if (fs.existsSync(targetDir)) {
332
655
  console.log(chalk.red(`
333
656
  \u274C Directory already exists: ${targetDir}`));
334
657
  process.exit(1);
335
658
  }
336
- console.log(chalk.green(`
337
- \u2728 Creating plugin: ${fullPackageName}...
338
- `));
339
- fs.mkdirpSync(targetDir);
340
659
  const vars = {
341
660
  packageName: `@object-ui/${fullPackageName}`,
342
661
  pluginName: cleanName,
343
662
  pascalName: pascalCaseName,
344
- description: answers.description,
345
- author: answers.author,
663
+ // ⛔ Never `answers.description` / `answers.author` raw. Both are absent
664
+ // after a cancel and after a non-TTY run, and `licenseCopyrightHolder`
665
+ // dereferences the author — reading them raw is exactly what turned a
666
+ // cancel at the second or third question into `TypeError: Cannot read
667
+ // properties of undefined (reading 'trim')`, thrown AFTER the target
668
+ // directory had already been created (objectui#8786).
669
+ description: answers.description ?? descriptionInitial,
670
+ author: answers.author ?? authorInitial,
671
+ // Never `answers.license` directly: a non-TTY stdin or a cancelled prompt
672
+ // leaves it undefined, and the ruling says such a run takes MIT and still
673
+ // writes the text.
674
+ license: resolveLicenseId(answers.license),
346
675
  version: "0.1.0",
347
676
  year: (/* @__PURE__ */ new Date()).getFullYear()
348
677
  };
349
- for (const [relativePath, contents] of Object.entries(buildPluginFiles(vars))) {
678
+ const files = buildPluginFiles(vars);
679
+ console.log(chalk.green(`
680
+ \u2728 Creating plugin: ${fullPackageName}...
681
+ `));
682
+ fs.mkdirpSync(targetDir);
683
+ for (const [relativePath, contents] of Object.entries(files)) {
350
684
  const filePath = path.join(targetDir, relativePath);
351
685
  fs.mkdirpSync(path.dirname(filePath));
352
686
  fs.writeFileSync(filePath, contents);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@object-ui/create-plugin",
3
- "version": "17.6.0",
3
+ "version": "17.7.0",
4
4
  "description": "CLI tool to scaffold ObjectUI plugins",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -57,7 +57,7 @@
57
57
  "build": "tsup",
58
58
  "type-check": "tsc --noEmit && tsc -p tsconfig.test.json",
59
59
  "dev": "tsup --watch",
60
- "test": "vitest run",
60
+ "test": "vitest run --root ../.. packages/create-plugin/",
61
61
  "lint": "eslint ."
62
62
  }
63
63
  }