@isardsat/create-editorial 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 +21 -0
- package/bin/index.js +7 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +70 -0
- package/dist/utils/package-json.d.ts +1 -0
- package/dist/utils/package-json.js +17 -0
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +2 -0
- package/package.json +22 -0
- package/src/index.ts +88 -0
- package/src/utils/package-json.ts +16 -0
- package/src/utils.ts +0 -0
- package/tsconfig.json +10 -0
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
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function run(): Promise<void>;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.run = run;
|
|
4
|
+
const commander_1 = require("commander");
|
|
5
|
+
const node_fs_1 = require("node:fs");
|
|
6
|
+
const promises_1 = require("node:fs/promises");
|
|
7
|
+
const node_path_1 = require("node:path");
|
|
8
|
+
const package_json_1 = require("./utils/package-json");
|
|
9
|
+
const { version } = JSON.parse((0, node_fs_1.readFileSync)((0, node_path_1.join)(__dirname, "../package.json"), "utf8"));
|
|
10
|
+
const command = new commander_1.Command()
|
|
11
|
+
.version(version)
|
|
12
|
+
.arguments("[directory]")
|
|
13
|
+
.usage("[directory] [options]")
|
|
14
|
+
.description("Create a new Editorial application");
|
|
15
|
+
async function run() {
|
|
16
|
+
const options = command.parse(process.argv);
|
|
17
|
+
const directory = options.args[0];
|
|
18
|
+
console.log("Creating new Editorial application");
|
|
19
|
+
if (!directory) {
|
|
20
|
+
console.error("Directory is required");
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
await (0, promises_1.access)(directory);
|
|
25
|
+
console.error("Directory already exists");
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
// Directory doesn't exist, we can proceed
|
|
30
|
+
}
|
|
31
|
+
console.log("Creating directory structure...");
|
|
32
|
+
await (0, promises_1.mkdir)(directory, { recursive: true });
|
|
33
|
+
await (0, promises_1.mkdir)((0, node_path_1.join)(directory, "editorial"), { recursive: true });
|
|
34
|
+
console.log("Creating config.json...");
|
|
35
|
+
const configData = JSON.stringify({
|
|
36
|
+
name: "My Editorial Site",
|
|
37
|
+
publicUrl: "http://localhost:3001/",
|
|
38
|
+
previewUrl: "http://localhost:3001/preview/",
|
|
39
|
+
}, null, 2);
|
|
40
|
+
await (0, promises_1.writeFile)((0, node_path_1.join)(directory, "editorial", "config.json"), configData);
|
|
41
|
+
console.log("Creating schema.yaml...");
|
|
42
|
+
const schemaData = `# Editorial Schema
|
|
43
|
+
dummy:
|
|
44
|
+
displayName: Dummy Object
|
|
45
|
+
fields:
|
|
46
|
+
title:
|
|
47
|
+
type: string
|
|
48
|
+
displayName: Title
|
|
49
|
+
showInSummary: true
|
|
50
|
+
body:
|
|
51
|
+
type: markdown
|
|
52
|
+
displayName: Body
|
|
53
|
+
displayExtra: 'Write anything you want!'
|
|
54
|
+
`;
|
|
55
|
+
await (0, promises_1.writeFile)((0, node_path_1.join)(directory, "editorial", "schema.yaml"), schemaData);
|
|
56
|
+
console.log("Creating data.json...");
|
|
57
|
+
const dataJson = JSON.stringify({
|
|
58
|
+
dummy: {
|
|
59
|
+
"test-1": {
|
|
60
|
+
id: "test-1",
|
|
61
|
+
title: "Test Object",
|
|
62
|
+
body: "This is a **test** object",
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
}, null, 2);
|
|
66
|
+
await (0, promises_1.writeFile)((0, node_path_1.join)(directory, "editorial", "data.json"), dataJson);
|
|
67
|
+
console.log("Creating package.json...");
|
|
68
|
+
await (0, package_json_1.createPackageJSON)(directory, version);
|
|
69
|
+
console.log("Done!");
|
|
70
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createPackageJSON(directory: string, version: string): Promise<void>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createPackageJSON = createPackageJSON;
|
|
4
|
+
const promises_1 = require("node:fs/promises");
|
|
5
|
+
const node_path_1 = require("node:path");
|
|
6
|
+
async function createPackageJSON(directory, version) {
|
|
7
|
+
const packageJson = {
|
|
8
|
+
name: "example-editorial-app",
|
|
9
|
+
version: "0.0.1",
|
|
10
|
+
private: true,
|
|
11
|
+
dependencies: {
|
|
12
|
+
"@isardsat/editorial-cli": version,
|
|
13
|
+
},
|
|
14
|
+
devDependencies: {},
|
|
15
|
+
};
|
|
16
|
+
await (0, promises_1.writeFile)((0, node_path_1.join)(directory, "package.json"), JSON.stringify(packageJson, null, 2));
|
|
17
|
+
}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/utils.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@isardsat/create-editorial",
|
|
3
|
+
"version": "6.0.0-canary-001",
|
|
4
|
+
"description": "Create a new editorial project",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"commander": "^13.1.0"
|
|
8
|
+
},
|
|
9
|
+
"devDependencies": {
|
|
10
|
+
"@tsconfig/node22": "^22.0.0",
|
|
11
|
+
"@types/node": "22.13.1",
|
|
12
|
+
"prettier": "^3.4.2",
|
|
13
|
+
"typescript": "5.7.3"
|
|
14
|
+
},
|
|
15
|
+
"volta": {
|
|
16
|
+
"extends": "../../package.json"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"compile": "tsc",
|
|
20
|
+
"compile:watch": "tsc --watch"
|
|
21
|
+
}
|
|
22
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { access, mkdir, writeFile } from "node:fs/promises";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { createPackageJSON } from "./utils/package-json";
|
|
6
|
+
|
|
7
|
+
const { version } = JSON.parse(
|
|
8
|
+
readFileSync(join(__dirname, "../package.json"), "utf8")
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
const command = new Command()
|
|
12
|
+
.version(version)
|
|
13
|
+
.arguments("[directory]")
|
|
14
|
+
.usage("[directory] [options]")
|
|
15
|
+
.description("Create a new Editorial application");
|
|
16
|
+
|
|
17
|
+
export async function run() {
|
|
18
|
+
const options = command.parse(process.argv);
|
|
19
|
+
const directory = options.args[0];
|
|
20
|
+
|
|
21
|
+
console.log("Creating new Editorial application");
|
|
22
|
+
|
|
23
|
+
if (!directory) {
|
|
24
|
+
console.error("Directory is required");
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
try {
|
|
29
|
+
await access(directory);
|
|
30
|
+
console.error("Directory already exists");
|
|
31
|
+
process.exit(1);
|
|
32
|
+
} catch {
|
|
33
|
+
// Directory doesn't exist, we can proceed
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
console.log("Creating directory structure...");
|
|
37
|
+
await mkdir(directory, { recursive: true });
|
|
38
|
+
await mkdir(join(directory, "editorial"), { recursive: true });
|
|
39
|
+
|
|
40
|
+
console.log("Creating config.json...");
|
|
41
|
+
const configData = JSON.stringify(
|
|
42
|
+
{
|
|
43
|
+
name: "My Editorial Site",
|
|
44
|
+
publicUrl: "http://localhost:3001/",
|
|
45
|
+
previewUrl: "http://localhost:3001/preview/",
|
|
46
|
+
},
|
|
47
|
+
null,
|
|
48
|
+
2
|
|
49
|
+
);
|
|
50
|
+
await writeFile(join(directory, "editorial", "config.json"), configData);
|
|
51
|
+
|
|
52
|
+
console.log("Creating schema.yaml...");
|
|
53
|
+
const schemaData = `# Editorial Schema
|
|
54
|
+
dummy:
|
|
55
|
+
displayName: Dummy Object
|
|
56
|
+
fields:
|
|
57
|
+
title:
|
|
58
|
+
type: string
|
|
59
|
+
displayName: Title
|
|
60
|
+
showInSummary: true
|
|
61
|
+
body:
|
|
62
|
+
type: markdown
|
|
63
|
+
displayName: Body
|
|
64
|
+
displayExtra: 'Write anything you want!'
|
|
65
|
+
`;
|
|
66
|
+
await writeFile(join(directory, "editorial", "schema.yaml"), schemaData);
|
|
67
|
+
|
|
68
|
+
console.log("Creating data.json...");
|
|
69
|
+
const dataJson = JSON.stringify(
|
|
70
|
+
{
|
|
71
|
+
dummy: {
|
|
72
|
+
"test-1": {
|
|
73
|
+
id: "test-1",
|
|
74
|
+
title: "Test Object",
|
|
75
|
+
body: "This is a **test** object",
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
null,
|
|
80
|
+
2
|
|
81
|
+
);
|
|
82
|
+
await writeFile(join(directory, "editorial", "data.json"), dataJson);
|
|
83
|
+
|
|
84
|
+
console.log("Creating package.json...");
|
|
85
|
+
await createPackageJSON(directory, version);
|
|
86
|
+
|
|
87
|
+
console.log("Done!");
|
|
88
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { writeFile } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
|
|
4
|
+
export async function createPackageJSON(directory: string, version: string) {
|
|
5
|
+
const packageJson = {
|
|
6
|
+
name: "example-editorial-app",
|
|
7
|
+
version: "0.0.1",
|
|
8
|
+
private: true,
|
|
9
|
+
dependencies: {
|
|
10
|
+
"@isardsat/editorial-cli": version,
|
|
11
|
+
},
|
|
12
|
+
devDependencies: {},
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
await writeFile(join(directory, "package.json"), JSON.stringify(packageJson, null, 2));
|
|
16
|
+
}
|
package/src/utils.ts
ADDED
|
File without changes
|
package/tsconfig.json
ADDED