create-velora-plugin 0.9.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/LICENSE +202 -0
- package/README.md +20 -0
- package/dist/generate.d.ts +19 -0
- package/dist/generate.js +87 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +83 -0
- package/dist/names.d.ts +7 -0
- package/dist/names.js +29 -0
- package/package.json +37 -0
- package/templates/base/README.md +18 -0
- package/templates/base/_gitignore +2 -0
- package/templates/base/index.html +11 -0
- package/templates/base/package.json +32 -0
- package/templates/base/tsconfig.json +15 -0
- package/templates/base/vite.config.ts +40 -0
- package/templates/bundle/src/plugin.ts +30 -0
- package/templates/datatype/src/plugin.tsx +62 -0
- package/templates/datatype/src/views.tsx +51 -0
- package/templates/integration/src/plugin.tsx +31 -0
- package/templates/section/src/plugin.tsx +58 -0
- package/templates/section/src/views.tsx +9 -0
- package/templates/template/src/plugin.tsx +41 -0
- package/templates/theme/src/plugin.tsx +35 -0
- package/templates/utility/src/plugin.tsx +33 -0
- package/templates/utility/src/views.tsx +9 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# create-velora-plugin
|
|
2
|
+
|
|
3
|
+
Scaffolds a new Velora plugin from a type-aware template (`datatype`,
|
|
4
|
+
`section`, `template`, `theme`, `integration`, `utility`, or `bundle`),
|
|
5
|
+
generating a stub that matches the plugin type's allowed contributions and
|
|
6
|
+
the current `@velora-cms/plugin-sdk` contract.
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```sh
|
|
11
|
+
npm create velora-plugin@latest
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
npm create velora-plugin@latest -- --name my-plugin --type datatype
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Part of [Velora](https://github.com/velora-cms/velora). Apache-2.0.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type ScaffoldPluginType } from "./names.js";
|
|
2
|
+
export interface GeneratePluginOptions {
|
|
3
|
+
type: ScaffoldPluginType;
|
|
4
|
+
name: string;
|
|
5
|
+
id: string;
|
|
6
|
+
targetDir: string;
|
|
7
|
+
author?: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface GeneratedPlugin {
|
|
11
|
+
targetDir: string;
|
|
12
|
+
/** Target-relative, forward-slashed, sorted. */
|
|
13
|
+
files: string[];
|
|
14
|
+
}
|
|
15
|
+
/** Input/precondition failures the CLI reports as clean exit-1 messages. */
|
|
16
|
+
export declare class GeneratePluginError extends Error {
|
|
17
|
+
constructor(message: string);
|
|
18
|
+
}
|
|
19
|
+
export declare function generatePlugin(options: GeneratePluginOptions): GeneratedPlugin;
|
package/dist/generate.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { dirname, join, relative } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { PLUGIN_TYPES, isValidPluginId, kebabCase, remoteNameFromId, vendorFromId, } from "./names.js";
|
|
5
|
+
/** Input/precondition failures the CLI reports as clean exit-1 messages. */
|
|
6
|
+
export class GeneratePluginError extends Error {
|
|
7
|
+
constructor(message) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.name = "GeneratePluginError";
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
// templates/ sits at the package root; this file resolves it correctly
|
|
13
|
+
// from both src/ (tests import the source) and dist/ (the built CLI).
|
|
14
|
+
const TEMPLATES_ROOT = join(dirname(fileURLToPath(import.meta.url)), "..", "templates");
|
|
15
|
+
// _-prefixed template names dodge npm publish mangling (create-vite's
|
|
16
|
+
// convention) and are renamed on copy.
|
|
17
|
+
const RENAMES = { _gitignore: ".gitignore" };
|
|
18
|
+
// Templates splice name/author/description into single-quoted TS strings
|
|
19
|
+
// and JSX attributes verbatim (see replacements below); any of these
|
|
20
|
+
// characters would break out of that context and produce a project that
|
|
21
|
+
// fails to compile while the CLI still exits 0. Reject rather than escape —
|
|
22
|
+
// simpler at this project's scale and keeps generated source readable.
|
|
23
|
+
const UNSAFE_CHARS = /['"`\\\n]/;
|
|
24
|
+
function assertSafeField(fieldName, value) {
|
|
25
|
+
if (UNSAFE_CHARS.test(value)) {
|
|
26
|
+
throw new GeneratePluginError(`Plugin ${fieldName} must not contain quotes, backslashes, or newlines.`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export function generatePlugin(options) {
|
|
30
|
+
const { type, name, id, targetDir } = options;
|
|
31
|
+
if (!PLUGIN_TYPES.includes(type)) {
|
|
32
|
+
throw new GeneratePluginError(`Unknown plugin type "${type}". Valid types: ${PLUGIN_TYPES.join(", ")}.`);
|
|
33
|
+
}
|
|
34
|
+
if (kebabCase(name) === "") {
|
|
35
|
+
throw new GeneratePluginError("Plugin name must contain at least one letter or digit.");
|
|
36
|
+
}
|
|
37
|
+
if (!isValidPluginId(id)) {
|
|
38
|
+
throw new GeneratePluginError(`Plugin id "${id}" must be a reverse-domain id like com.vendor.plugin.`);
|
|
39
|
+
}
|
|
40
|
+
assertSafeField("name", name);
|
|
41
|
+
if (options.author !== undefined)
|
|
42
|
+
assertSafeField("author", options.author);
|
|
43
|
+
if (options.description !== undefined)
|
|
44
|
+
assertSafeField("description", options.description);
|
|
45
|
+
// All inputs are validated BEFORE any write — a rejected call never
|
|
46
|
+
// leaves a half-written project behind.
|
|
47
|
+
if (existsSync(targetDir)) {
|
|
48
|
+
if (!statSync(targetDir).isDirectory()) {
|
|
49
|
+
throw new GeneratePluginError(`Target "${targetDir}" exists and is not a directory.`);
|
|
50
|
+
}
|
|
51
|
+
if (readdirSync(targetDir).length > 0) {
|
|
52
|
+
throw new GeneratePluginError(`Target directory "${targetDir}" is not empty.`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const replacements = {
|
|
56
|
+
__PLUGIN_ID__: id,
|
|
57
|
+
__PLUGIN_NAME__: name.trim(),
|
|
58
|
+
__PLUGIN_TYPE__: type,
|
|
59
|
+
__PKG_NAME__: kebabCase(name),
|
|
60
|
+
__REMOTE_NAME__: remoteNameFromId(id),
|
|
61
|
+
__DATATYPE_ID__: `${id}.field`,
|
|
62
|
+
__AUTHOR__: options.author ?? vendorFromId(id),
|
|
63
|
+
__DESCRIPTION__: options.description ?? `A Velora ${type} plugin.`,
|
|
64
|
+
};
|
|
65
|
+
const files = [];
|
|
66
|
+
copyDir(join(TEMPLATES_ROOT, "base"), targetDir, targetDir, replacements, files);
|
|
67
|
+
copyDir(join(TEMPLATES_ROOT, type), targetDir, targetDir, replacements, files);
|
|
68
|
+
return { targetDir, files: files.sort() };
|
|
69
|
+
}
|
|
70
|
+
function copyDir(from, to, targetRoot, replacements, files) {
|
|
71
|
+
mkdirSync(to, { recursive: true });
|
|
72
|
+
for (const entry of readdirSync(from)) {
|
|
73
|
+
const source = join(from, entry);
|
|
74
|
+
const targetName = RENAMES[entry] ?? entry;
|
|
75
|
+
const target = join(to, targetName);
|
|
76
|
+
if (statSync(source).isDirectory()) {
|
|
77
|
+
copyDir(source, target, targetRoot, replacements, files);
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
let content = readFileSync(source, "utf8");
|
|
81
|
+
for (const [token, value] of Object.entries(replacements)) {
|
|
82
|
+
content = content.replaceAll(token, value);
|
|
83
|
+
}
|
|
84
|
+
writeFileSync(target, content);
|
|
85
|
+
files.push(relative(targetRoot, target).replaceAll("\\", "/"));
|
|
86
|
+
}
|
|
87
|
+
}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { parseArgs } from "node:util";
|
|
3
|
+
import * as p from "@clack/prompts";
|
|
4
|
+
import { GeneratePluginError, generatePlugin } from "./generate.js";
|
|
5
|
+
import { PLUGIN_TYPES, isValidPluginId, kebabCase } from "./names.js";
|
|
6
|
+
// Thin interactive front-end over generatePlugin(): every prompt has a
|
|
7
|
+
// flag equivalent so the CLI runs fully non-interactively (tests and the
|
|
8
|
+
// e2e verification drive it that way). Prompts re-ask on invalid input;
|
|
9
|
+
// flag values hit generatePlugin's own guards and exit 1 with the same
|
|
10
|
+
// message.
|
|
11
|
+
function exitCancelled() {
|
|
12
|
+
p.cancel("Cancelled — nothing was written.");
|
|
13
|
+
process.exit(1);
|
|
14
|
+
}
|
|
15
|
+
async function textPrompt(message, initialValue, validate) {
|
|
16
|
+
const answer = await p.text({ message, initialValue, validate });
|
|
17
|
+
if (p.isCancel(answer))
|
|
18
|
+
exitCancelled();
|
|
19
|
+
return answer;
|
|
20
|
+
}
|
|
21
|
+
async function main() {
|
|
22
|
+
const { values, positionals } = parseArgs({
|
|
23
|
+
allowPositionals: true,
|
|
24
|
+
options: {
|
|
25
|
+
name: { type: "string" },
|
|
26
|
+
type: { type: "string" },
|
|
27
|
+
id: { type: "string" },
|
|
28
|
+
author: { type: "string" },
|
|
29
|
+
description: { type: "string" },
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
p.intro("create-velora-plugin");
|
|
33
|
+
const name = values.name ??
|
|
34
|
+
(await textPrompt("Plugin name", "", (value) => {
|
|
35
|
+
if (kebabCase(value) === "")
|
|
36
|
+
return "Name must contain at least one letter or digit.";
|
|
37
|
+
if (/['"`\\\n]/.test(value))
|
|
38
|
+
return "Name must not contain quotes, backslashes, or newlines.";
|
|
39
|
+
return undefined;
|
|
40
|
+
}));
|
|
41
|
+
let type = values.type;
|
|
42
|
+
if (type === undefined) {
|
|
43
|
+
const answer = await p.select({
|
|
44
|
+
message: "Plugin type",
|
|
45
|
+
options: PLUGIN_TYPES.map((pluginType) => ({ value: pluginType, label: pluginType })),
|
|
46
|
+
});
|
|
47
|
+
if (p.isCancel(answer))
|
|
48
|
+
exitCancelled();
|
|
49
|
+
type = answer;
|
|
50
|
+
}
|
|
51
|
+
const id = values.id ??
|
|
52
|
+
(await textPrompt("Plugin id (reverse-domain)", `com.example.${kebabCase(name)}`, (value) => isValidPluginId(value) ? undefined : "Must be a reverse-domain id like com.vendor.plugin."));
|
|
53
|
+
const targetDir = positionals[0] ?? kebabCase(name);
|
|
54
|
+
try {
|
|
55
|
+
const result = generatePlugin({
|
|
56
|
+
type,
|
|
57
|
+
name,
|
|
58
|
+
id,
|
|
59
|
+
targetDir,
|
|
60
|
+
author: values.author,
|
|
61
|
+
description: values.description,
|
|
62
|
+
});
|
|
63
|
+
p.outro([
|
|
64
|
+
`Scaffolded ${result.files.length} files in ${result.targetDir}`,
|
|
65
|
+
"",
|
|
66
|
+
"Next steps:",
|
|
67
|
+
` cd ${result.targetDir}`,
|
|
68
|
+
" npm install",
|
|
69
|
+
" npm run build",
|
|
70
|
+
].join("\n"));
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
if (error instanceof GeneratePluginError) {
|
|
74
|
+
p.cancel(error.message);
|
|
75
|
+
process.exit(1);
|
|
76
|
+
}
|
|
77
|
+
throw error;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
main().catch((error) => {
|
|
81
|
+
console.error(error);
|
|
82
|
+
process.exit(1);
|
|
83
|
+
});
|
package/dist/names.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const PLUGIN_TYPES: readonly ["datatype", "section", "template", "theme", "integration", "utility", "bundle"];
|
|
2
|
+
export type ScaffoldPluginType = (typeof PLUGIN_TYPES)[number];
|
|
3
|
+
export declare const PLUGIN_ID_REGEX: RegExp;
|
|
4
|
+
export declare function isValidPluginId(id: string): boolean;
|
|
5
|
+
export declare function kebabCase(name: string): string;
|
|
6
|
+
export declare function remoteNameFromId(id: string): string;
|
|
7
|
+
export declare function vendorFromId(id: string): string;
|
package/dist/names.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// Pure naming/validation helpers shared by the generator (generate.ts)
|
|
2
|
+
// and the interactive CLI (index.ts).
|
|
3
|
+
export const PLUGIN_TYPES = ["datatype", "section", "template", "theme", "integration", "utility", "bundle"];
|
|
4
|
+
// The EXACT regex manifest-schema.ts's pluginIdSchema uses — an id this
|
|
5
|
+
// accepts is an id validatePluginManifest accepts, so an invalid id can
|
|
6
|
+
// never reach a generated manifest.
|
|
7
|
+
export const PLUGIN_ID_REGEX = /^[a-z0-9-]+(\.[a-z0-9-]+)+$/i;
|
|
8
|
+
export function isValidPluginId(id) {
|
|
9
|
+
return PLUGIN_ID_REGEX.test(id);
|
|
10
|
+
}
|
|
11
|
+
export function kebabCase(name) {
|
|
12
|
+
return name
|
|
13
|
+
.trim()
|
|
14
|
+
.replace(/([a-z0-9])([A-Z])/g, "$1-$2")
|
|
15
|
+
.toLowerCase()
|
|
16
|
+
.replace(/[^a-z0-9]+/g, "-")
|
|
17
|
+
.replace(/^-+|-+$/g, "");
|
|
18
|
+
}
|
|
19
|
+
// Module Federation remote names must be valid JS identifiers.
|
|
20
|
+
export function remoteNameFromId(id) {
|
|
21
|
+
const name = id.replace(/[^a-zA-Z0-9]/g, "_");
|
|
22
|
+
return /^[0-9]/.test(name) ? `plugin_${name}` : name;
|
|
23
|
+
}
|
|
24
|
+
// Default manifest author: the vendor segment of the reverse-domain id
|
|
25
|
+
// (com.example.x → "example"; two-segment example.thing → "example").
|
|
26
|
+
export function vendorFromId(id) {
|
|
27
|
+
const segments = id.split(".");
|
|
28
|
+
return segments.length >= 3 ? segments[1] : segments[0];
|
|
29
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-velora-plugin",
|
|
3
|
+
"version": "0.9.0",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"create-velora-plugin": "dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"main": "dist/generate.js",
|
|
10
|
+
"types": "dist/generate.d.ts",
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"templates"
|
|
14
|
+
],
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/velora-cms/velora.git",
|
|
18
|
+
"directory": "packages/create-velora-plugin"
|
|
19
|
+
},
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@clack/prompts": "0.11.0"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/node": "20.19.43",
|
|
28
|
+
"@types/react": "19.2.17",
|
|
29
|
+
"react": "19.2.7",
|
|
30
|
+
"react-dom": "19.2.7",
|
|
31
|
+
"@velora-cms/plugin-sdk": "0.9.0"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "tsc -p .",
|
|
35
|
+
"test": "vitest run"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# __PLUGIN_NAME__
|
|
2
|
+
|
|
3
|
+
A Velora __PLUGIN_TYPE__ plugin (`__PLUGIN_ID__`), scaffolded with
|
|
4
|
+
`npm create velora-plugin`.
|
|
5
|
+
|
|
6
|
+
## Commands
|
|
7
|
+
|
|
8
|
+
- `npm run dev` — Vite dev server (the `velora-dev` sandbox's hot-reload
|
|
9
|
+
target)
|
|
10
|
+
- `npm run build` — typecheck, then produce `dist/remoteEntry.js`
|
|
11
|
+
- `npm run preview` — serve the built remote for sideload testing
|
|
12
|
+
|
|
13
|
+
## Where to go from here
|
|
14
|
+
|
|
15
|
+
- `src/plugin.tsx` is your plugin's manifest — the default export a
|
|
16
|
+
Velora host installs. Edit the example contribution to make it yours.
|
|
17
|
+
- Keep `react`, `react-dom` and `@velora-cms/plugin-sdk` in vite.config.ts's
|
|
18
|
+
`shared` block: your views run against the HOST's copies at runtime.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<title>__PKG_NAME__</title>
|
|
6
|
+
</head>
|
|
7
|
+
<body>
|
|
8
|
+
<!-- This package exists to serve remoteEntry.js; there is no app here. -->
|
|
9
|
+
<p>__PLUGIN_NAME__ — a Velora __PLUGIN_TYPE__ plugin. The useful artifact is <code>remoteEntry.js</code>.</p>
|
|
10
|
+
</body>
|
|
11
|
+
</html>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "__PKG_NAME__",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "vite",
|
|
8
|
+
"build": "tsc -p . && vite build",
|
|
9
|
+
"preview": "vite preview",
|
|
10
|
+
"test": "vitest run"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@velora-cms/plugin-sdk": "^0.1.0"
|
|
14
|
+
},
|
|
15
|
+
"peerDependencies": {
|
|
16
|
+
"react": "^19.0.0",
|
|
17
|
+
"react-dom": "^19.0.0"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@module-federation/vite": "1.16.12",
|
|
21
|
+
"@types/react": "19.2.17",
|
|
22
|
+
"@types/react-dom": "19.2.3",
|
|
23
|
+
"@vitejs/plugin-react": "4.7.0",
|
|
24
|
+
"react": "19.2.7",
|
|
25
|
+
"react-dom": "19.2.7",
|
|
26
|
+
"typescript": "6.0.3",
|
|
27
|
+
"velora-dev": "^0.1.0",
|
|
28
|
+
"velora-plugin": "^0.1.0",
|
|
29
|
+
"vite": "6.4.3",
|
|
30
|
+
"vitest": "3.2.6"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"moduleResolution": "Bundler",
|
|
7
|
+
"jsx": "react-jsx",
|
|
8
|
+
"strict": true,
|
|
9
|
+
"noEmit": true,
|
|
10
|
+
"isolatedModules": true,
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"forceConsistentCasingInFileNames": true
|
|
13
|
+
},
|
|
14
|
+
"include": ["src", "vite.config.ts"]
|
|
15
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { defineConfig } from 'vite'
|
|
2
|
+
import react from '@vitejs/plugin-react'
|
|
3
|
+
import { federation } from '@module-federation/vite'
|
|
4
|
+
|
|
5
|
+
export default defineConfig({
|
|
6
|
+
plugins: [
|
|
7
|
+
react(),
|
|
8
|
+
federation({
|
|
9
|
+
name: '__REMOTE_NAME__',
|
|
10
|
+
filename: 'remoteEntry.js',
|
|
11
|
+
exposes: {
|
|
12
|
+
'./plugin': './src/plugin.tsx',
|
|
13
|
+
},
|
|
14
|
+
// Mirror of the Velora admin host's singletons: at runtime the
|
|
15
|
+
// plugin's react/SDK imports resolve to the HOST's copies — same
|
|
16
|
+
// registry, same context hooks. Never remove these.
|
|
17
|
+
shared: {
|
|
18
|
+
react: { singleton: true },
|
|
19
|
+
'react-dom': { singleton: true },
|
|
20
|
+
'@velora-cms/plugin-sdk': { singleton: true, requiredVersion: '*' },
|
|
21
|
+
},
|
|
22
|
+
}),
|
|
23
|
+
],
|
|
24
|
+
build: {
|
|
25
|
+
target: 'chrome89',
|
|
26
|
+
},
|
|
27
|
+
server: {
|
|
28
|
+
// velora-dev's dev-mode hot reload (Session 79) fetches
|
|
29
|
+
// remoteEntry.js cross-origin from this dev server — needs its own
|
|
30
|
+
// CORS flag, same reason preview.cors exists below for the
|
|
31
|
+
// build+preview path.
|
|
32
|
+
cors: true,
|
|
33
|
+
},
|
|
34
|
+
preview: {
|
|
35
|
+
port: 5175,
|
|
36
|
+
// The Velora admin fetches remoteEntry.js cross-origin — Vite 6's
|
|
37
|
+
// tightened default CORS would block it.
|
|
38
|
+
cors: true,
|
|
39
|
+
},
|
|
40
|
+
})
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type BundlePluginManifest } from '@velora-cms/plugin-sdk'
|
|
2
|
+
|
|
3
|
+
const plugin: BundlePluginManifest = {
|
|
4
|
+
id: '__PLUGIN_ID__',
|
|
5
|
+
name: '__PLUGIN_NAME__',
|
|
6
|
+
version: '0.1.0',
|
|
7
|
+
type: 'bundle',
|
|
8
|
+
description: '__DESCRIPTION__',
|
|
9
|
+
author: '__AUTHOR__',
|
|
10
|
+
license: 'MIT',
|
|
11
|
+
cmsVersion: '^0.1.0',
|
|
12
|
+
databaseCompatibility: {
|
|
13
|
+
storageType: 'simple',
|
|
14
|
+
supported: ['postgresql', 'mysql', 'sqlite'],
|
|
15
|
+
},
|
|
16
|
+
permissions: {
|
|
17
|
+
needsStructuredData: false,
|
|
18
|
+
needsExternalNetwork: false,
|
|
19
|
+
needsFileSystemAccess: false,
|
|
20
|
+
},
|
|
21
|
+
contributions: {
|
|
22
|
+
// The listings this bundle installs together. Every id must be a
|
|
23
|
+
// published marketplace listing; paid bundles may only reference
|
|
24
|
+
// FREE members (the Month 13 monetization rule) — enforced at
|
|
25
|
+
// submission, not here.
|
|
26
|
+
bundledPlugins: ['com.example.some-plugin'],
|
|
27
|
+
},
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default plugin
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { definePlugin, type DataTypePluginManifest } from '@velora-cms/plugin-sdk'
|
|
2
|
+
import { InputView, ReadOnlyView, SettingsView } from './views'
|
|
3
|
+
|
|
4
|
+
// The field type this plugin contributes. Its id is deliberately distinct
|
|
5
|
+
// from the plugin's own id — a plugin can ship several field types.
|
|
6
|
+
export const exampleField = definePlugin({
|
|
7
|
+
id: '__DATATYPE_ID__',
|
|
8
|
+
name: '__PLUGIN_NAME__',
|
|
9
|
+
icon: 'puzzle',
|
|
10
|
+
version: '0.1.0',
|
|
11
|
+
type: 'datatype',
|
|
12
|
+
schema: {
|
|
13
|
+
type: 'object',
|
|
14
|
+
properties: {
|
|
15
|
+
text: { type: 'string' },
|
|
16
|
+
},
|
|
17
|
+
additionalProperties: false,
|
|
18
|
+
},
|
|
19
|
+
settingsSchema: {
|
|
20
|
+
type: 'object',
|
|
21
|
+
properties: {
|
|
22
|
+
placeholder: { type: 'string' },
|
|
23
|
+
},
|
|
24
|
+
additionalProperties: false,
|
|
25
|
+
},
|
|
26
|
+
defaultSettings: {},
|
|
27
|
+
views: {
|
|
28
|
+
input: InputView,
|
|
29
|
+
readOnly: ReadOnlyView,
|
|
30
|
+
settings: SettingsView,
|
|
31
|
+
},
|
|
32
|
+
serialize: (value) => value,
|
|
33
|
+
deserialize: (raw) => raw,
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
// The full manifest a Velora host installs — the default export.
|
|
37
|
+
const plugin: DataTypePluginManifest = {
|
|
38
|
+
id: '__PLUGIN_ID__',
|
|
39
|
+
name: '__PLUGIN_NAME__',
|
|
40
|
+
version: '0.1.0',
|
|
41
|
+
type: 'datatype',
|
|
42
|
+
description: '__DESCRIPTION__',
|
|
43
|
+
author: '__AUTHOR__',
|
|
44
|
+
license: 'MIT',
|
|
45
|
+
cmsVersion: '^0.1.0',
|
|
46
|
+
databaseCompatibility: {
|
|
47
|
+
// 'simple' JSON key-value storage suits most datatype plugins and
|
|
48
|
+
// works on every database. 'structured' requires marketplace review.
|
|
49
|
+
storageType: 'simple',
|
|
50
|
+
supported: ['postgresql', 'mysql', 'sqlite'],
|
|
51
|
+
},
|
|
52
|
+
permissions: {
|
|
53
|
+
needsStructuredData: false,
|
|
54
|
+
needsExternalNetwork: false,
|
|
55
|
+
needsFileSystemAccess: false,
|
|
56
|
+
},
|
|
57
|
+
contributions: {
|
|
58
|
+
dataTypes: [exampleField],
|
|
59
|
+
},
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export default plugin
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Input, PropertyField, usePluginSettings, usePluginSettingsValue, usePluginValue } from '@velora-cms/plugin-sdk'
|
|
2
|
+
|
|
3
|
+
// Example stored value — replace with your own shape, and keep
|
|
4
|
+
// src/plugin.tsx's `schema` in sync with it.
|
|
5
|
+
interface ExampleValue {
|
|
6
|
+
text?: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// Example settings — replace, keeping src/plugin.tsx's `settingsSchema`
|
|
10
|
+
// in sync. Admins set these per Data Type config in Velora's admin.
|
|
11
|
+
interface ExampleSettings {
|
|
12
|
+
[key: string]: unknown
|
|
13
|
+
placeholder?: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function InputView() {
|
|
17
|
+
const { value, onChange } = usePluginValue<ExampleValue | null>()
|
|
18
|
+
const settings = usePluginSettings<ExampleSettings>()
|
|
19
|
+
return (
|
|
20
|
+
<PropertyField label="__PLUGIN_NAME__" htmlFor="__PKG_NAME__-text">
|
|
21
|
+
<Input
|
|
22
|
+
id="__PKG_NAME__-text"
|
|
23
|
+
value={value?.text ?? ''}
|
|
24
|
+
placeholder={settings.placeholder ?? ''}
|
|
25
|
+
onChange={(e) => onChange({ ...value, text: e.target.value })}
|
|
26
|
+
/>
|
|
27
|
+
</PropertyField>
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function ReadOnlyView() {
|
|
32
|
+
const { value } = usePluginValue<ExampleValue | null>()
|
|
33
|
+
return <p>{value?.text ?? ''}</p>
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function SettingsView() {
|
|
37
|
+
const { value: settings, onChange } = usePluginSettingsValue<ExampleSettings>()
|
|
38
|
+
return (
|
|
39
|
+
<PropertyField
|
|
40
|
+
label="Placeholder text"
|
|
41
|
+
htmlFor="__PKG_NAME__-placeholder"
|
|
42
|
+
helpText="Shown in the empty input."
|
|
43
|
+
>
|
|
44
|
+
<Input
|
|
45
|
+
id="__PKG_NAME__-placeholder"
|
|
46
|
+
value={settings.placeholder ?? ''}
|
|
47
|
+
onChange={(e) => onChange({ ...settings, placeholder: e.target.value })}
|
|
48
|
+
/>
|
|
49
|
+
</PropertyField>
|
|
50
|
+
)
|
|
51
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type IntegrationPluginManifest } from '@velora-cms/plugin-sdk'
|
|
2
|
+
|
|
3
|
+
const plugin: IntegrationPluginManifest = {
|
|
4
|
+
id: '__PLUGIN_ID__',
|
|
5
|
+
name: '__PLUGIN_NAME__',
|
|
6
|
+
version: '0.1.0',
|
|
7
|
+
type: 'integration',
|
|
8
|
+
description: '__DESCRIPTION__',
|
|
9
|
+
author: '__AUTHOR__',
|
|
10
|
+
license: 'MIT',
|
|
11
|
+
cmsVersion: '^0.1.0',
|
|
12
|
+
databaseCompatibility: {
|
|
13
|
+
storageType: 'simple',
|
|
14
|
+
supported: ['postgresql', 'mysql', 'sqlite'],
|
|
15
|
+
},
|
|
16
|
+
permissions: {
|
|
17
|
+
needsStructuredData: false,
|
|
18
|
+
needsExternalNetwork: false,
|
|
19
|
+
needsFileSystemAccess: false,
|
|
20
|
+
},
|
|
21
|
+
contributions: {
|
|
22
|
+
hooks: {
|
|
23
|
+
'content:afterSave': () => {
|
|
24
|
+
// Called after any content save — replace with your
|
|
25
|
+
// integration's sync/notify logic.
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export default plugin
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { type SectionPluginManifest } from '@velora-cms/plugin-sdk'
|
|
2
|
+
import { SectionView } from './views'
|
|
3
|
+
|
|
4
|
+
const plugin: SectionPluginManifest = {
|
|
5
|
+
id: '__PLUGIN_ID__',
|
|
6
|
+
name: '__PLUGIN_NAME__',
|
|
7
|
+
version: '0.1.0',
|
|
8
|
+
type: 'section',
|
|
9
|
+
description: '__DESCRIPTION__',
|
|
10
|
+
author: '__AUTHOR__',
|
|
11
|
+
license: 'MIT',
|
|
12
|
+
cmsVersion: '^0.1.0',
|
|
13
|
+
databaseCompatibility: {
|
|
14
|
+
storageType: 'simple',
|
|
15
|
+
supported: ['postgresql', 'mysql', 'sqlite'],
|
|
16
|
+
},
|
|
17
|
+
permissions: {
|
|
18
|
+
needsStructuredData: false,
|
|
19
|
+
needsExternalNetwork: false,
|
|
20
|
+
needsFileSystemAccess: false,
|
|
21
|
+
},
|
|
22
|
+
contributions: {
|
|
23
|
+
adminSections: [
|
|
24
|
+
{
|
|
25
|
+
id: '__PKG_NAME__',
|
|
26
|
+
name: '__PLUGIN_NAME__',
|
|
27
|
+
icon: 'layout-grid',
|
|
28
|
+
view: SectionView,
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
apiRoutes: [
|
|
32
|
+
{
|
|
33
|
+
method: 'GET',
|
|
34
|
+
// Mounted under /api/plugins/__PLUGIN_ID__/… by the host, so two
|
|
35
|
+
// plugins can never collide on a path.
|
|
36
|
+
path: '/status',
|
|
37
|
+
handler: () => ({ ok: true }),
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
// Document types this plugin provisions at install (the server mints
|
|
41
|
+
// ids) — only 'section' and 'template' plugins may declare this
|
|
42
|
+
// contribution. Remove this array entirely if your plugin doesn't
|
|
43
|
+
// need one. The datatypeId below is the built-in Text data type's id
|
|
44
|
+
// (packages/api-schemas/src/data-type-config.schema.ts).
|
|
45
|
+
documentTypes: [
|
|
46
|
+
{
|
|
47
|
+
name: 'Example Item',
|
|
48
|
+
icon: 'file',
|
|
49
|
+
kind: 'page',
|
|
50
|
+
fields: [{ id: 'title', name: 'Title', datatypeId: 'b1e00000-0000-4000-8000-000000000001' }],
|
|
51
|
+
tabs: [],
|
|
52
|
+
treeRules: { allowedAtRoot: true, allowedParentTypes: [], allowedChildTypes: [] },
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
},
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export default plugin
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type TemplatePluginManifest } from '@velora-cms/plugin-sdk'
|
|
2
|
+
|
|
3
|
+
const plugin: TemplatePluginManifest = {
|
|
4
|
+
id: '__PLUGIN_ID__',
|
|
5
|
+
name: '__PLUGIN_NAME__',
|
|
6
|
+
version: '0.1.0',
|
|
7
|
+
type: 'template',
|
|
8
|
+
description: '__DESCRIPTION__',
|
|
9
|
+
author: '__AUTHOR__',
|
|
10
|
+
license: 'MIT',
|
|
11
|
+
cmsVersion: '^0.1.0',
|
|
12
|
+
databaseCompatibility: {
|
|
13
|
+
storageType: 'simple',
|
|
14
|
+
supported: ['postgresql', 'mysql', 'sqlite'],
|
|
15
|
+
},
|
|
16
|
+
permissions: {
|
|
17
|
+
needsStructuredData: false,
|
|
18
|
+
needsExternalNetwork: false,
|
|
19
|
+
needsFileSystemAccess: false,
|
|
20
|
+
},
|
|
21
|
+
contributions: {
|
|
22
|
+
// Document types this template provisions at install — the same
|
|
23
|
+
// creation shape the admin's Document Type builder uses.
|
|
24
|
+
documentTypes: [
|
|
25
|
+
{
|
|
26
|
+
name: '__PLUGIN_NAME__ Page',
|
|
27
|
+
icon: 'file-text',
|
|
28
|
+
kind: 'page',
|
|
29
|
+
tabs: [],
|
|
30
|
+
fields: [],
|
|
31
|
+
treeRules: {
|
|
32
|
+
allowedAtRoot: true,
|
|
33
|
+
allowedParentTypes: [],
|
|
34
|
+
allowedChildTypes: [],
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export default plugin
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type ThemePluginManifest } from '@velora-cms/plugin-sdk'
|
|
2
|
+
|
|
3
|
+
const plugin: ThemePluginManifest = {
|
|
4
|
+
id: '__PLUGIN_ID__',
|
|
5
|
+
name: '__PLUGIN_NAME__',
|
|
6
|
+
version: '0.1.0',
|
|
7
|
+
type: 'theme',
|
|
8
|
+
description: '__DESCRIPTION__',
|
|
9
|
+
author: '__AUTHOR__',
|
|
10
|
+
license: 'MIT',
|
|
11
|
+
cmsVersion: '^0.1.0',
|
|
12
|
+
databaseCompatibility: {
|
|
13
|
+
storageType: 'simple',
|
|
14
|
+
supported: ['postgresql', 'mysql', 'sqlite'],
|
|
15
|
+
},
|
|
16
|
+
permissions: {
|
|
17
|
+
needsStructuredData: false,
|
|
18
|
+
needsExternalNetwork: false,
|
|
19
|
+
needsFileSystemAccess: false,
|
|
20
|
+
},
|
|
21
|
+
contributions: {
|
|
22
|
+
// Themes override design TOKENS only (color scales + radius) — never
|
|
23
|
+
// components. Applying the theme re-skins the whole admin, including
|
|
24
|
+
// other plugins' UIs, via CSS variables.
|
|
25
|
+
themeTokens: {
|
|
26
|
+
color: {
|
|
27
|
+
primary: {
|
|
28
|
+
'500': '#6366F1',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export default plugin
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type UtilityPluginManifest } from '@velora-cms/plugin-sdk'
|
|
2
|
+
import { WidgetView } from './views'
|
|
3
|
+
|
|
4
|
+
const plugin: UtilityPluginManifest = {
|
|
5
|
+
id: '__PLUGIN_ID__',
|
|
6
|
+
name: '__PLUGIN_NAME__',
|
|
7
|
+
version: '0.1.0',
|
|
8
|
+
type: 'utility',
|
|
9
|
+
description: '__DESCRIPTION__',
|
|
10
|
+
author: '__AUTHOR__',
|
|
11
|
+
license: 'MIT',
|
|
12
|
+
cmsVersion: '^0.1.0',
|
|
13
|
+
databaseCompatibility: {
|
|
14
|
+
storageType: 'simple',
|
|
15
|
+
supported: ['postgresql', 'mysql', 'sqlite'],
|
|
16
|
+
},
|
|
17
|
+
permissions: {
|
|
18
|
+
needsStructuredData: false,
|
|
19
|
+
needsExternalNetwork: false,
|
|
20
|
+
needsFileSystemAccess: false,
|
|
21
|
+
},
|
|
22
|
+
contributions: {
|
|
23
|
+
dashboardWidgets: [
|
|
24
|
+
{
|
|
25
|
+
id: '__PKG_NAME__',
|
|
26
|
+
name: '__PLUGIN_NAME__',
|
|
27
|
+
view: WidgetView,
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default plugin
|