create-coffer-plugin 1.1.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/bin/index.mjs +36 -0
- package/package.json +12 -0
- package/templates/README.md.tpl +5 -0
- package/templates/_gitignore +3 -0
- package/templates/package.json.tpl +17 -0
- package/templates/src/index.css.tpl +1 -0
- package/templates/src/index.ts.tpl +28 -0
- package/templates/src/ui.tsx.tpl +9 -0
- package/templates/tsconfig.build.json.tpl +15 -0
package/bin/index.mjs
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/** create-coffer-plugin — scaffold standalone schema-плагіна. Usage: npm create coffer-plugin <name> */
|
|
3
|
+
import { mkdirSync, writeFileSync, readFileSync, readdirSync, statSync } from 'node:fs';
|
|
4
|
+
import { join, dirname, relative } from 'node:path';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
|
|
7
|
+
const raw = process.argv[2];
|
|
8
|
+
if (!raw) {
|
|
9
|
+
console.error('usage: npm create coffer-plugin <name>');
|
|
10
|
+
process.exit(1);
|
|
11
|
+
}
|
|
12
|
+
const name = raw.replace(/^coffer-plugin-/, '');
|
|
13
|
+
const pkgName = `coffer-plugin-${name}`;
|
|
14
|
+
const dest = join(process.cwd(), pkgName);
|
|
15
|
+
const tplDir = join(dirname(fileURLToPath(import.meta.url)), '..', 'templates');
|
|
16
|
+
|
|
17
|
+
/** Рекурсивний обхід темплейтів (без залежності від readdirSync recursive). */
|
|
18
|
+
function walk(dir) {
|
|
19
|
+
const out = [];
|
|
20
|
+
for (const e of readdirSync(dir)) {
|
|
21
|
+
const p = join(dir, e);
|
|
22
|
+
if (statSync(p).isDirectory()) out.push(...walk(p));
|
|
23
|
+
else out.push(p);
|
|
24
|
+
}
|
|
25
|
+
return out;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
for (const abs of walk(tplDir)) {
|
|
29
|
+
const rel = relative(tplDir, abs);
|
|
30
|
+
const outRel = rel.replace(/\.tpl$/, '').replace(/(^|\/)_/g, '$1.');
|
|
31
|
+
const out = join(dest, outRel);
|
|
32
|
+
const body = readFileSync(abs, 'utf8').replaceAll('__NAME__', name).replaceAll('__PKG__', pkgName);
|
|
33
|
+
mkdirSync(dirname(out), { recursive: true });
|
|
34
|
+
writeFileSync(out, body);
|
|
35
|
+
}
|
|
36
|
+
console.log(`✓ ${pkgName} створено. Далі:\n cd ${pkgName} && npm install && npm run build`);
|
package/package.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "__PKG__",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"files": ["dist"],
|
|
6
|
+
"coffer": { "schema": "dist/index.js", "web": "dist/web.js", "css": "dist/web.css" },
|
|
7
|
+
"exports": { ".": "./src/index.ts" },
|
|
8
|
+
"distExports": { ".": { "types": "./dist/index.d.ts", "default": "./dist/index.js" } },
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "coffer-plugin build",
|
|
11
|
+
"prepack": "coffer-plugin prepack",
|
|
12
|
+
"postpack": "coffer-plugin postpack"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": { "@coffer-org/sdk": "^1.0.0" },
|
|
15
|
+
"peerDependencies": { "@coffer-org/web-sdk": "^1.0.0", "react": ">=19" },
|
|
16
|
+
"devDependencies": { "@coffer-org/devkit": "^1.0.0", "@coffer-org/web-sdk": "^1.0.0", "react": "^19", "typescript": "^5" }
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import 'tailwindcss';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { defineModule, defineVault, field } from '@coffer-org/sdk';
|
|
2
|
+
import type { PluginManifest } from '@coffer-org/sdk/plugin';
|
|
3
|
+
|
|
4
|
+
/** Приклад модуля. Заміни на свій домен. */
|
|
5
|
+
const note = defineModule({
|
|
6
|
+
module: 'note',
|
|
7
|
+
vault: '__NAME__',
|
|
8
|
+
label: '__NAME__.note.label',
|
|
9
|
+
views: { table: ['body'] },
|
|
10
|
+
fields: [
|
|
11
|
+
field.title({ key: 'name', label: 'core.fields.name' }),
|
|
12
|
+
field.text({ key: 'body', label: '__NAME__.note.fields.body', max: 2000 }),
|
|
13
|
+
],
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
const manifest: PluginManifest = {
|
|
17
|
+
id: '__NAME__',
|
|
18
|
+
version: '0.1.0',
|
|
19
|
+
dependsOn: [],
|
|
20
|
+
vaults: [
|
|
21
|
+
{
|
|
22
|
+
meta: defineVault({ id: '__NAME__', label: '__NAME__.vault.label', icon: 'lucide:puzzle' }),
|
|
23
|
+
modules: [note],
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export default manifest;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { defineModuleUI } from '@coffer-org/web-sdk';
|
|
2
|
+
import './index.css'; // Tailwind entry → emitted as dist/web.css (host injects it)
|
|
3
|
+
|
|
4
|
+
// The plugin's web bundle default-exports its ModuleUIBundle (or an array).
|
|
5
|
+
// The host federation loader registers RecordView / renderers / translations.
|
|
6
|
+
// Signature: defineModuleUI(vault, module, { RecordView?, renderers?, translations? }).
|
|
7
|
+
export default defineModuleUI('__NAME__', 'note', {
|
|
8
|
+
translations: { en: { '__NAME__.hello': 'Hello from __NAME__' } },
|
|
9
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "NodeNext",
|
|
5
|
+
"moduleResolution": "NodeNext",
|
|
6
|
+
"declaration": true,
|
|
7
|
+
"strict": true,
|
|
8
|
+
"outDir": "dist",
|
|
9
|
+
"rootDir": "src",
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"verbatimModuleSyntax": false
|
|
12
|
+
},
|
|
13
|
+
"include": ["src"],
|
|
14
|
+
"exclude": ["src/**/*.test.ts", "src/**/*.test.tsx", "src/**/ui.tsx", "src/**/actions.ts"]
|
|
15
|
+
}
|