|
1 | 1 | #!/usr/bin/env node
|
2 | 2 |
|
3 |
| -import { existsSync, readFileSync, readdirSync } from "fs"; |
4 |
| -import { join } from "path"; |
| 3 | +import { existsSync, readFileSync, readdirSync } from "node:fs"; |
| 4 | +import { join } from "node:path"; |
5 | 5 |
|
6 | 6 | const ROOT_DIR = process.cwd();
|
7 | 7 | const MANIFEST_FILE = join(ROOT_DIR, "manifest.json");
|
@@ -34,37 +34,40 @@ const validateStructure = () => {
|
34 | 34 |
|
35 | 35 | const errors = [];
|
36 | 36 |
|
37 |
| - folders.forEach((folder) => { |
| 37 | + for (const folder of folders) { |
38 | 38 | const pluginFile = join(PLUGINS_DIR, folder, PLUGIN_FILENAME);
|
39 | 39 | const viewFile = join(PLUGINS_DIR, folder, VIEW_FILENAME);
|
40 | 40 | const dataFile = join(PLUGINS_DIR, folder, DATA_FILENAME);
|
41 | 41 |
|
42 |
| - if (!existsSync(pluginFile)) |
| 42 | + if (!existsSync(pluginFile)) { |
43 | 43 | errors.push(`Missing ${PLUGIN_FILENAME} in "${folder}"`);
|
44 |
| - if (!existsSync(viewFile)) |
| 44 | + } |
| 45 | + if (!existsSync(viewFile)) { |
45 | 46 | errors.push(`Missing ${VIEW_FILENAME} in "${folder}"`);
|
46 |
| - if (!existsSync(dataFile)) |
| 47 | + } |
| 48 | + if (!existsSync(dataFile)) { |
47 | 49 | errors.push(`Missing ${DATA_FILENAME} in "${folder}"`);
|
| 50 | + } |
48 | 51 |
|
49 | 52 | const manifestEntry = manifest.find((entry) => entry.path === folder);
|
50 | 53 |
|
51 | 54 | if (!manifestEntry) {
|
52 | 55 | errors.push(`Folder "${folder}" is missing in manifest.json`);
|
53 |
| - } else { |
54 |
| - if ( |
55 |
| - !manifestEntry.title || |
56 |
| - !manifestEntry.description || |
57 |
| - typeof manifestEntry.private !== "boolean" |
58 |
| - ) { |
59 |
| - errors.push( |
60 |
| - `Invalid manifest entry for "${folder}". It must have a title, description, private flag, and path.`, |
61 |
| - ); |
62 |
| - } |
| 56 | + } else if ( |
| 57 | + !manifestEntry.title || |
| 58 | + !manifestEntry.description || |
| 59 | + typeof manifestEntry.private !== "boolean" |
| 60 | + ) { |
| 61 | + errors.push( |
| 62 | + `Invalid manifest entry for "${folder}". It must have a title, description, private flag, and path.`, |
| 63 | + ); |
63 | 64 | }
|
64 |
| - }); |
| 65 | + } |
65 | 66 |
|
66 | 67 | if (errors.length > 0) {
|
67 |
| - errors.forEach((error) => console.error(error)); |
| 68 | + for (const error of errors) { |
| 69 | + console.error(error); |
| 70 | + } |
68 | 71 | process.exit(1);
|
69 | 72 | }
|
70 | 73 |
|
|
0 commit comments