@isardsat/editorial-cli 6.0.0-canary-001

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Lobelia Earth
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/bin/index.js ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node
2
+
3
+ 'use strict';
4
+
5
+ import { editorialCli } from '../dist/index.js';
6
+
7
+ editorialCli.parse();
@@ -0,0 +1,2 @@
1
+ import { Command } from "@commander-js/extra-typings";
2
+ export declare const initCommand: Command<[], {}, {}>;
@@ -0,0 +1,56 @@
1
+ import { Command } from "@commander-js/extra-typings";
2
+ import { mkdir, writeFile } from "fs/promises";
3
+ import * as path from "path";
4
+ export const initCommand = new Command()
5
+ .name("init")
6
+ .description("initialize files required for Editorial to function")
7
+ .action(async () => {
8
+ console.log("Initializing editorial...");
9
+ try {
10
+ await mkdir("./editorial", { recursive: true });
11
+ console.log("Created Editorial directory");
12
+ // Create config.json with basic configuration
13
+ const configData = JSON.stringify({
14
+ name: "WEkEO",
15
+ publicUrl: "http://localhost:3001/",
16
+ previewUrl: "http://localhost:3001/preview/",
17
+ }, null, 2);
18
+ await writeFile(path.join("editorial", "config.json"), configData);
19
+ console.log("Created config.json");
20
+ // Create schema.yaml with a dummy schema
21
+ const schemaData = `# Editorial Schema
22
+ dummy:
23
+ displayName: Dummy Object
24
+ fields:
25
+ title:
26
+ type: string
27
+ displayName: Title
28
+ showInSummary: true
29
+ body:
30
+ type: markdown
31
+ displayName: Body
32
+ displayExtra: 'Write anything you want!'
33
+ `;
34
+ await writeFile(path.join("editorial", "schema.yaml"), schemaData);
35
+ console.log("Created schema.yaml");
36
+ // Create data.json with test object
37
+ const dataJson = JSON.stringify({
38
+ dummy: {
39
+ "test-1": {
40
+ id: "test-1",
41
+ title: "Test Object",
42
+ body: "This is a **test** object",
43
+ },
44
+ },
45
+ }, null, 2);
46
+ await writeFile(path.join("editorial", "data.json"), dataJson);
47
+ console.log("Created data.json");
48
+ await mkdir(path.join("public"), { recursive: true });
49
+ console.log("Created files directory");
50
+ console.log("Editorial initialized successfully!");
51
+ }
52
+ catch (error) {
53
+ console.error("Failed to initialize Editorial:", error);
54
+ process.exit(1);
55
+ }
56
+ });
@@ -0,0 +1,9 @@
1
+ import { Command } from "@commander-js/extra-typings";
2
+ export declare const startCommand: Command<[], {
3
+ port: number;
4
+ server?: string | undefined;
5
+ uploads: string;
6
+ largeFiles: string;
7
+ cmsHelpers: string;
8
+ otherLocaleDirs: string | true | [];
9
+ }, {}>;
@@ -0,0 +1,30 @@
1
+ import { Command } from "@commander-js/extra-typings";
2
+ import { serve } from "@hono/node-server";
3
+ import { createEditorialServer } from "@isardsat/editorial-server";
4
+ import { version } from "../version.js";
5
+ const SRC = "editorial";
6
+ const DEFAULT_PORT = 3001;
7
+ const DEFAULT_UPLOAD_FOLDER = "/static/files";
8
+ const DEFAULT_LARGE_FILES = "editorial/largeFiles";
9
+ const DEFAULT_CMS_HELPERS = "editorial/cmsHelpers";
10
+ export const startCommand = new Command()
11
+ .name("start")
12
+ .description("start the editorial API server")
13
+ .option("-p, --port <port>", "port number to use", Number, DEFAULT_PORT)
14
+ .option("--server <path>", "server module")
15
+ .option("--uploads <path>", "upload folder", DEFAULT_UPLOAD_FOLDER)
16
+ .option("--large-files <path>", "large-files module", DEFAULT_LARGE_FILES)
17
+ .option("--cms-helpers <path>", "CMS helpers module", DEFAULT_CMS_HELPERS)
18
+ .option("--other-locale-dirs [...dirs]", "comma-separated relative paths to other Mady locale folders (e.g. libs)", [])
19
+ .action(async ({ port }) => {
20
+ const editorialServer = await createEditorialServer({});
21
+ console.log(` Editorial ${version}`);
22
+ console.log(` - Local: http://localhost:${port}`);
23
+ console.log(` - Swagger UI: http://localhost:${port}/doc/ui\n`);
24
+ console.log("Starting api...");
25
+ serve({
26
+ fetch: editorialServer.app.fetch,
27
+ port,
28
+ });
29
+ console.log("Ready");
30
+ });
@@ -0,0 +1 @@
1
+ export declare const editorialCli: import("@commander-js/extra-typings").Command<[], {}, {}>;
package/dist/index.js ADDED
@@ -0,0 +1,9 @@
1
+ import { program } from "@commander-js/extra-typings";
2
+ import { initCommand } from "./commands/init.js";
3
+ import { startCommand } from "./commands/start.js";
4
+ import { version } from "./version.js";
5
+ export const editorialCli = program
6
+ .name("Editorial")
7
+ .version(version)
8
+ .addCommand(initCommand)
9
+ .addCommand(startCommand, { isDefault: true });
@@ -0,0 +1 @@
1
+ export declare const version: any;
@@ -0,0 +1,3 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ export const { version } = JSON.parse(readFileSync(join(import.meta.dirname, '..', 'package.json'), 'utf-8'));
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@isardsat/editorial-cli",
3
+ "version": "6.0.0-canary-001",
4
+ "type": "module",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "bin": {
8
+ "editorial": "bin/index.js"
9
+ },
10
+ "files": [
11
+ "dist"
12
+ ],
13
+ "dependencies": {
14
+ "@commander-js/extra-typings": "^13.0.0",
15
+ "@hono/node-server": "^1.13.8",
16
+ "commander": "^13.1.0",
17
+ "@isardsat/editorial-server": "^6.0.0-canary-001"
18
+ },
19
+ "devDependencies": {
20
+ "@tsconfig/node22": "^22.0.0",
21
+ "@types/node": "22.13.1",
22
+ "typescript": "^5.7.3"
23
+ },
24
+ "volta": {
25
+ "extends": "../../package.json"
26
+ },
27
+ "scripts": {
28
+ "compile": "tsc",
29
+ "compile:watch": "tsc --watch"
30
+ }
31
+ }