@event-driven-io/emmett 0.43.0-beta.13 → 0.43.0-beta.14
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/dist/cli.cjs +124 -179
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.d.cts +12 -9
- package/dist/cli.d.ts +12 -9
- package/dist/cli.js +115 -178
- package/dist/cli.js.map +1 -1
- package/dist/index-BXN5muYb.d.cts +73 -0
- package/dist/index-C0agmFA7.d.ts +73 -0
- package/dist/index.cjs +2307 -2916
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +672 -622
- package/dist/index.d.ts +672 -622
- package/dist/index.js +2088 -2844
- package/dist/index.js.map +1 -1
- package/dist/plugins-CUbnGFPp.js +131 -0
- package/dist/plugins-CUbnGFPp.js.map +1 -0
- package/dist/plugins-DB9xe8AV.cjs +272 -0
- package/dist/plugins-DB9xe8AV.cjs.map +1 -0
- package/package.json +4 -4
- package/dist/chunk-AZDDB5SF.js +0 -161
- package/dist/chunk-AZDDB5SF.js.map +0 -1
- package/dist/chunk-WND32L6P.cjs +0 -161
- package/dist/chunk-WND32L6P.cjs.map +0 -1
- package/dist/index-D13Bsibj.d.cts +0 -69
- package/dist/index-D13Bsibj.d.ts +0 -69
package/dist/cli.js
CHANGED
|
@@ -1,199 +1,136 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
EmmettError,
|
|
4
|
-
isPluginConfig
|
|
5
|
-
} from "./chunk-AZDDB5SF.js";
|
|
6
|
-
|
|
7
|
-
// src/cli.ts
|
|
2
|
+
import { i as EmmettError, t as isPluginConfig } from "./plugins-CUbnGFPp.js";
|
|
8
3
|
import { Command } from "commander";
|
|
9
|
-
|
|
10
|
-
// src/commandLine/config.ts
|
|
11
|
-
import { Command as CliCommand } from "commander";
|
|
12
|
-
import { writeFileSync } from "fs";
|
|
4
|
+
import { writeFileSync } from "node:fs";
|
|
13
5
|
import { exit } from "process";
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
6
|
+
import path from "path";
|
|
7
|
+
|
|
8
|
+
//#region src/commandLine/config.ts
|
|
9
|
+
const sampleConfig = (plugins = ["emmett-expressjs"]) => {
|
|
10
|
+
return `
|
|
19
11
|
export default {
|
|
20
|
-
plugins: ${
|
|
12
|
+
plugins: ${plugins.length > 0 ? `[\n${plugins.map((p) => `"${p}"`).join(",\n")} \n]` : "[]"},
|
|
21
13
|
};
|
|
22
14
|
`;
|
|
23
15
|
};
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
16
|
+
const generateConfigFile = (configPath, collectionNames) => {
|
|
17
|
+
try {
|
|
18
|
+
writeFileSync(configPath, sampleConfig(collectionNames), "utf8");
|
|
19
|
+
console.log(`Configuration file stored at: ${configPath}`);
|
|
20
|
+
} catch (error) {
|
|
21
|
+
console.error(`Error: Couldn't store config file: ${configPath}!`);
|
|
22
|
+
console.error(error);
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
33
25
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
)
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
"Error: Please provide either:\n--print param to print sample config or\n--generate to generate sample config file"
|
|
52
|
-
);
|
|
53
|
-
exit(1);
|
|
54
|
-
}
|
|
55
|
-
if ("print" in options) {
|
|
56
|
-
console.log(`${sampleConfig(plugins)}`);
|
|
57
|
-
} else if ("generate" in options) {
|
|
58
|
-
if (!options.file) {
|
|
59
|
-
console.error(
|
|
60
|
-
"Error: You need to provide a config file through a --file"
|
|
61
|
-
);
|
|
62
|
-
exit(1);
|
|
63
|
-
}
|
|
64
|
-
generateConfigFile(options.file, plugins);
|
|
65
|
-
}
|
|
26
|
+
const configCommand = new Command("config").description("Manage Pongo configuration");
|
|
27
|
+
configCommand.command("sample").description("Generate or print sample configuration").option("-plg, --plugins <name>", "Specify the plugin name", (value, previous) => {
|
|
28
|
+
return previous.concat([value]);
|
|
29
|
+
}, []).option("-f, --file <path>", "Path to configuration file with collection list").option("-g, --generate", "Generate sample config file").option("-p, --print", "Print sample config file").action((options) => {
|
|
30
|
+
const plugins = options.plugin.length > 0 ? options.plugin : ["@event-driven-io/emmett-expressjs"];
|
|
31
|
+
if (!("print" in options) && !("generate" in options)) {
|
|
32
|
+
console.error("Error: Please provide either:\n--print param to print sample config or\n--generate to generate sample config file");
|
|
33
|
+
exit(1);
|
|
34
|
+
}
|
|
35
|
+
if ("print" in options) console.log(`${sampleConfig(plugins)}`);
|
|
36
|
+
else if ("generate" in options) {
|
|
37
|
+
if (!options.file) {
|
|
38
|
+
console.error("Error: You need to provide a config file through a --file");
|
|
39
|
+
exit(1);
|
|
40
|
+
}
|
|
41
|
+
generateConfigFile(options.file, plugins);
|
|
42
|
+
}
|
|
66
43
|
});
|
|
67
44
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
missingPluginsPropertyExport: `Error: Config should contain default export with plugins array, e.g.
|
|
75
|
-
|
|
76
|
-
${sampleConfig()}`,
|
|
77
|
-
wrongPluginStructure: `Error: Plugin config should be either string with plugin name or object with plugin name, e.g. { name: 'emmett-expressjs' }`
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/commandLine/plugins.ts
|
|
47
|
+
const PluginsConfigImportError = {
|
|
48
|
+
missingDefaultExport: `Error: Config should contain default export, e.g.\n\n${sampleConfig()}`,
|
|
49
|
+
missingPluginsPropertyExport: `Error: Config should contain default export with plugins array, e.g.\n\n${sampleConfig()}`,
|
|
50
|
+
wrongPluginStructure: `Error: Plugin config should be either string with plugin name or object with plugin name, e.g. { name: 'emmett-expressjs' }`
|
|
78
51
|
};
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
if (!imported.default.plugins.every(isPluginConfig)) {
|
|
96
|
-
return new EmmettError(PluginsConfigImportError.wrongPluginStructure);
|
|
97
|
-
}
|
|
98
|
-
return { plugins: imported.default.plugins };
|
|
99
|
-
} catch (error) {
|
|
100
|
-
if (!options?.configPath) {
|
|
101
|
-
console.warn("Didn`t find config file: " + configPath, error);
|
|
102
|
-
return { plugins: [] };
|
|
103
|
-
}
|
|
104
|
-
return new EmmettError(
|
|
105
|
-
`Error: Couldn't load file:` + error.toString()
|
|
106
|
-
);
|
|
107
|
-
}
|
|
52
|
+
const importPluginsConfig = async (options) => {
|
|
53
|
+
const configPath = path.join(process.cwd(), options?.configPath ?? "./dist/emmett.config.js");
|
|
54
|
+
console.log("IMPORTING" + configPath);
|
|
55
|
+
try {
|
|
56
|
+
const imported = await import(configPath);
|
|
57
|
+
if (!imported.default) return new EmmettError(PluginsConfigImportError.missingDefaultExport);
|
|
58
|
+
if (!imported.default.plugins || !Array.isArray(imported.default.plugins)) return new EmmettError(PluginsConfigImportError.missingPluginsPropertyExport);
|
|
59
|
+
if (!imported.default.plugins.every(isPluginConfig)) return new EmmettError(PluginsConfigImportError.wrongPluginStructure);
|
|
60
|
+
return { plugins: imported.default.plugins };
|
|
61
|
+
} catch (error) {
|
|
62
|
+
if (!options?.configPath) {
|
|
63
|
+
console.warn("Didn`t find config file: " + configPath, error);
|
|
64
|
+
return { plugins: [] };
|
|
65
|
+
}
|
|
66
|
+
return new EmmettError(`Error: Couldn't load file:` + error.toString());
|
|
67
|
+
}
|
|
108
68
|
};
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
return void 0;
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
return (await Promise.all(pluginsPromises)).filter(
|
|
138
|
-
(plugin) => plugin !== void 0
|
|
139
|
-
);
|
|
140
|
-
} catch (error) {
|
|
141
|
-
console.error(`Failed to load config ${options?.configPath}:`, error);
|
|
142
|
-
return [];
|
|
143
|
-
}
|
|
69
|
+
const loadPlugins = async (options) => {
|
|
70
|
+
try {
|
|
71
|
+
const pluginsConfig = await importPluginsConfig({ configPath: options?.configPath });
|
|
72
|
+
if (pluginsConfig instanceof EmmettError) throw pluginsConfig;
|
|
73
|
+
if (pluginsConfig.plugins.length === 0) {
|
|
74
|
+
console.log(`No extensions specified in config ${options?.configPath}.`);
|
|
75
|
+
return [];
|
|
76
|
+
}
|
|
77
|
+
const pluginsPromises = filterPluginsByType(pluginsConfig.plugins, options?.pluginType).map(async (pluginConfig) => {
|
|
78
|
+
const importPath = getImportPath(pluginConfig, options?.pluginType);
|
|
79
|
+
try {
|
|
80
|
+
const plugin = await import(importPath);
|
|
81
|
+
console.info(`Loaded plugin: ${importPath}`);
|
|
82
|
+
if (!plugin.default) throw new Error(`Plugin: ${importPath} is missing default export`);
|
|
83
|
+
return plugin.default;
|
|
84
|
+
} catch (error) {
|
|
85
|
+
console.error(`Failed to load extension "${importPath}":`, error);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
return (await Promise.all(pluginsPromises)).filter((plugin) => plugin !== void 0);
|
|
90
|
+
} catch (error) {
|
|
91
|
+
console.error(`Failed to load config ${options?.configPath}:`, error);
|
|
92
|
+
return [];
|
|
93
|
+
}
|
|
144
94
|
};
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
result.push(plugin);
|
|
155
|
-
}
|
|
95
|
+
const registerCliPlugins = async (program, plugins) => {
|
|
96
|
+
const result = [];
|
|
97
|
+
for (const plugin of plugins) {
|
|
98
|
+
const pluginName = plugin.name;
|
|
99
|
+
if (!("registerCommands" in plugin)) console.warn(`No registerCommands function found in ${pluginName}`);
|
|
100
|
+
await plugin.registerCommands(program);
|
|
101
|
+
console.log(`Loaded extension: ${plugin.name}`);
|
|
102
|
+
result.push(plugin);
|
|
103
|
+
}
|
|
156
104
|
};
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
);
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
return pluginType ? `${pluginConfig}/${pluginType}` : pluginConfig;
|
|
163
|
-
}
|
|
164
|
-
const pluginSubpath = pluginConfig.register.find((r) => pluginType && r.pluginType === pluginType)?.path ?? pluginType;
|
|
165
|
-
return pluginSubpath ? `${pluginConfig.name}/${pluginSubpath}` : pluginConfig.name;
|
|
105
|
+
const filterPluginsByType = (plugins, pluginType) => plugins.filter((p) => typeof p === "string" || pluginType && (p.register === void 0 || p.register.some((r) => r.pluginType === pluginType)));
|
|
106
|
+
const getImportPath = (pluginConfig, pluginType) => {
|
|
107
|
+
if (typeof pluginConfig === "string") return pluginType ? `${pluginConfig}/${pluginType}` : pluginConfig;
|
|
108
|
+
const pluginSubpath = pluginConfig.register.find((r) => pluginType && r.pluginType === pluginType)?.path ?? pluginType;
|
|
109
|
+
return pluginSubpath ? `${pluginConfig.name}/${pluginSubpath}` : pluginConfig.name;
|
|
166
110
|
};
|
|
167
111
|
|
|
168
|
-
|
|
169
|
-
|
|
112
|
+
//#endregion
|
|
113
|
+
//#region src/cli.ts
|
|
114
|
+
const program = new Command();
|
|
170
115
|
program.name("emmett").description("CLI tool for Emmett").option("--config <path>", "Path to the configuration file");
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
}
|
|
116
|
+
const initCLI = async () => {
|
|
117
|
+
const configIndex = process.argv.indexOf("--config");
|
|
118
|
+
const configPath = configIndex !== -1 && process.argv.length > configIndex + 1 ? process.argv[configIndex + 1] : void 0;
|
|
119
|
+
try {
|
|
120
|
+
await registerCliPlugins(program, await loadPlugins({
|
|
121
|
+
pluginType: "cli",
|
|
122
|
+
configPath
|
|
123
|
+
}));
|
|
124
|
+
program.parse(process.argv);
|
|
125
|
+
} catch (err) {
|
|
126
|
+
console.error(`Failed to load config from ${configPath}:`, err);
|
|
127
|
+
}
|
|
184
128
|
};
|
|
185
129
|
initCLI().catch((err) => {
|
|
186
|
-
|
|
187
|
-
|
|
130
|
+
console.error(`CLI initialization failed:`);
|
|
131
|
+
console.error(err);
|
|
188
132
|
});
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
cli_default as default,
|
|
193
|
-
generateConfigFile,
|
|
194
|
-
importPluginsConfig,
|
|
195
|
-
loadPlugins,
|
|
196
|
-
registerCliPlugins,
|
|
197
|
-
sampleConfig
|
|
198
|
-
};
|
|
133
|
+
|
|
134
|
+
//#endregion
|
|
135
|
+
export { configCommand, program as default, generateConfigFile, importPluginsConfig, loadPlugins, registerCliPlugins, sampleConfig };
|
|
199
136
|
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cli.ts","../src/commandLine/config.ts","../src/commandLine/plugins.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { Command } from 'commander';\nimport { loadPlugins, registerCliPlugins } from './commandLine';\n\nconst program = new Command();\n\nprogram\n .name('emmett')\n .description('CLI tool for Emmett')\n .option('--config <path>', 'Path to the configuration file');\n\n// Load extensions and parse CLI arguments\nconst initCLI = async () => {\n const configIndex = process.argv.indexOf('--config');\n\n const configPath =\n configIndex !== -1 && process.argv.length > configIndex + 1\n ? process.argv[configIndex + 1]\n : undefined;\n\n try {\n const plugins = await loadPlugins({\n pluginType: 'cli',\n configPath: configPath,\n });\n await registerCliPlugins(program, plugins);\n\n // Parse the CLI arguments\n program.parse(process.argv);\n } catch (err) {\n console.error(`Failed to load config from ${configPath}:`, err);\n }\n};\n\n//Initialize CLI and handle errors\ninitCLI().catch((err) => {\n console.error(`CLI initialization failed:`);\n console.error(err);\n});\n\nexport default program;\nexport * from './commandLine';\n","import { Command as CliCommand } from 'commander';\n// eslint-disable-next-line no-restricted-imports\nimport { writeFileSync } from 'node:fs';\nimport { exit } from 'process';\n\nexport const sampleConfig = (plugins: string[] = ['emmett-expressjs']) => {\n const pluginsNames =\n plugins.length > 0\n ? `[\\n${plugins.map((p) => `\"${p}\"`).join(',\\n')} \\n]`\n : '[]';\n\n return `\nexport default {\n plugins: ${pluginsNames},\n};\n`;\n};\n\nexport const generateConfigFile = (\n configPath: string,\n collectionNames: string[],\n): void => {\n try {\n writeFileSync(configPath, sampleConfig(collectionNames), 'utf8');\n console.log(`Configuration file stored at: ${configPath}`);\n } catch (error) {\n console.error(`Error: Couldn't store config file: ${configPath}!`);\n console.error(error);\n process.exit(1);\n }\n};\n\nexport const configCommand = new CliCommand('config').description(\n 'Manage Pongo configuration',\n);\n\ntype SampleConfigOptions =\n | {\n plugin: string[];\n print?: boolean;\n }\n | {\n plugin: string[];\n generate?: boolean;\n file?: string;\n };\n\nconfigCommand\n .command('sample')\n .description('Generate or print sample configuration')\n .option(\n '-plg, --plugins <name>',\n 'Specify the plugin name',\n (value: string, previous: string[]) => {\n // Accumulate plugins names into an array (explicitly typing `previous` as `string[]`)\n return previous.concat([value]);\n },\n [] as string[],\n )\n .option(\n '-f, --file <path>',\n 'Path to configuration file with collection list',\n )\n .option('-g, --generate', 'Generate sample config file')\n .option('-p, --print', 'Print sample config file')\n .action((options: SampleConfigOptions) => {\n const plugins =\n options.plugin.length > 0\n ? options.plugin\n : ['@event-driven-io/emmett-expressjs'];\n\n if (!('print' in options) && !('generate' in options)) {\n console.error(\n 'Error: Please provide either:\\n--print param to print sample config or\\n--generate to generate sample config file',\n );\n exit(1);\n }\n\n if ('print' in options) {\n console.log(`${sampleConfig(plugins)}`);\n } else if ('generate' in options) {\n if (!options.file) {\n console.error(\n 'Error: You need to provide a config file through a --file',\n );\n exit(1);\n }\n\n generateConfigFile(options.file, plugins);\n }\n });\n","import type { Command as CliCommand } from 'commander';\nimport path from 'path';\nimport {\n isPluginConfig,\n type EmmettCliCommand,\n type EmmettCliPlugin,\n type EmmettPlugin,\n type EmmettPluginConfig,\n type EmmettPluginsConfig,\n type EmmettPluginType,\n} from '../config';\nimport { EmmettError } from '../errors';\nimport { sampleConfig } from './config';\n\nconst PluginsConfigImportError = {\n missingDefaultExport: `Error: Config should contain default export, e.g.\\n\\n${sampleConfig()}`,\n missingPluginsPropertyExport: `Error: Config should contain default export with plugins array, e.g.\\n\\n${sampleConfig()}`,\n wrongPluginStructure: `Error: Plugin config should be either string with plugin name or object with plugin name, e.g. { name: 'emmett-expressjs' }`,\n};\nexport const importPluginsConfig = async (options?: {\n configPath?: string | undefined;\n}): Promise<EmmettPluginsConfig | EmmettError> => {\n const configPath = path.join(\n process.cwd(),\n options?.configPath ?? './dist/emmett.config.js',\n );\n\n console.log('IMPORTING' + configPath);\n\n try {\n const imported = (await import(configPath)) as {\n default: Partial<EmmettPluginsConfig>;\n };\n\n if (!imported.default) {\n return new EmmettError(PluginsConfigImportError.missingDefaultExport);\n }\n\n if (!imported.default.plugins || !Array.isArray(imported.default.plugins)) {\n return new EmmettError(\n PluginsConfigImportError.missingPluginsPropertyExport,\n );\n }\n\n if (!imported.default.plugins.every(isPluginConfig)) {\n return new EmmettError(PluginsConfigImportError.wrongPluginStructure);\n }\n\n return { plugins: imported.default.plugins };\n } catch (error) {\n if (!options?.configPath) {\n console.warn('Didn`t find config file: ' + configPath, error);\n return { plugins: [] };\n }\n return new EmmettError(\n `Error: Couldn't load file:` + (error as Error).toString(),\n );\n }\n};\n\nexport const loadPlugins = async (options?: {\n pluginType?: EmmettPluginType;\n configPath?: string;\n}): Promise<EmmettPlugin[]> => {\n try {\n const pluginsConfig = await importPluginsConfig({\n configPath: options?.configPath,\n });\n\n if (pluginsConfig instanceof EmmettError) throw pluginsConfig;\n\n if (pluginsConfig.plugins.length === 0) {\n console.log(`No extensions specified in config ${options?.configPath}.`);\n return [];\n }\n\n const pluginsToLoad = filterPluginsByType(\n pluginsConfig.plugins,\n options?.pluginType,\n );\n\n const pluginsPromises = pluginsToLoad.map(async (pluginConfig) => {\n const importPath = getImportPath(pluginConfig, options?.pluginType);\n try {\n const plugin = (await import(importPath)) as { default: EmmettPlugin };\n\n console.info(`Loaded plugin: ${importPath}`);\n\n if (!plugin.default) {\n throw new Error(`Plugin: ${importPath} is missing default export`);\n }\n\n return plugin.default;\n } catch (error) {\n console.error(`Failed to load extension \"${importPath}\":`, error);\n return undefined;\n }\n });\n\n return (await Promise.all(pluginsPromises)).filter(\n (plugin) => plugin !== undefined,\n );\n } catch (error) {\n console.error(`Failed to load config ${options?.configPath}:`, error);\n return [];\n }\n};\n\nexport const registerCliPlugins = async (\n program: CliCommand,\n plugins: EmmettCliPlugin[],\n): Promise<void> => {\n const result: EmmettCliPlugin[] = [];\n\n for (const plugin of plugins) {\n const pluginName = plugin.name;\n\n if (!('registerCommands' in plugin)) {\n console.warn(`No registerCommands function found in ${pluginName}`);\n }\n await plugin.registerCommands(program as EmmettCliCommand);\n console.log(`Loaded extension: ${plugin.name}`);\n result.push(plugin);\n }\n};\n\nconst filterPluginsByType = (\n plugins: EmmettPluginConfig[],\n pluginType?: EmmettPluginType,\n): EmmettPluginConfig[] =>\n plugins.filter(\n (p) =>\n typeof p === 'string' ||\n (pluginType &&\n (p.register === undefined ||\n p.register.some((r) => r.pluginType === pluginType))),\n );\n\nconst getImportPath = (\n pluginConfig: EmmettPluginConfig,\n pluginType: EmmettPluginType | undefined,\n) => {\n if (typeof pluginConfig === 'string') {\n return pluginType ? `${pluginConfig}/${pluginType}` : pluginConfig;\n }\n\n const pluginSubpath =\n pluginConfig.register.find((r) => pluginType && r.pluginType === pluginType)\n ?.path ?? pluginType;\n\n return pluginSubpath\n ? `${pluginConfig.name}/${pluginSubpath}`\n : pluginConfig.name;\n};\n"],"mappings":";;;;;;;AACA,SAAS,eAAe;;;ACDxB,SAAS,WAAW,kBAAkB;AAEtC,SAAS,qBAAqB;AAC9B,SAAS,YAAY;AAEd,IAAM,eAAe,CAAC,UAAoB,CAAC,kBAAkB,MAAM;AACxE,QAAM,eACJ,QAAQ,SAAS,IACb;AAAA,EAAM,QAAQ,IAAI,CAAC,MAAM,IAAI,CAAC,GAAG,EAAE,KAAK,KAAK,CAAC;AAAA,KAC9C;AAEN,SAAO;AAAA;AAAA,aAEI,YAAY;AAAA;AAAA;AAGzB;AAEO,IAAM,qBAAqB,CAChC,YACA,oBACS;AACT,MAAI;AACF,kBAAc,YAAY,aAAa,eAAe,GAAG,MAAM;AAC/D,YAAQ,IAAI,iCAAiC,UAAU,EAAE;AAAA,EAC3D,SAAS,OAAO;AACd,YAAQ,MAAM,sCAAsC,UAAU,GAAG;AACjE,YAAQ,MAAM,KAAK;AACnB,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;AAEO,IAAM,gBAAgB,IAAI,WAAW,QAAQ,EAAE;AAAA,EACpD;AACF;AAaA,cACG,QAAQ,QAAQ,EAChB,YAAY,wCAAwC,EACpD;AAAA,EACC;AAAA,EACA;AAAA,EACA,CAAC,OAAe,aAAuB;AAErC,WAAO,SAAS,OAAO,CAAC,KAAK,CAAC;AAAA,EAChC;AAAA,EACA,CAA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AAG;AAAA,EAChE;AACF;AAGA,QAAQ,EAAE,MAAM,CAAC,QAAQ;AACvB,UAAQ,MAAM,4BAA4B;AAC1C,UAAQ,MAAM,GAAG;AACnB,CAAC;AAED,IAAO,cAAQ;","names":["program"]}
|
|
1
|
+
{"version":3,"file":"cli.js","names":["CliCommand"],"sources":["../src/commandLine/config.ts","../src/commandLine/plugins.ts","../src/cli.ts"],"sourcesContent":["import { Command as CliCommand } from 'commander';\n// eslint-disable-next-line no-restricted-imports\nimport { writeFileSync } from 'node:fs';\nimport { exit } from 'process';\n\nexport const sampleConfig = (plugins: string[] = ['emmett-expressjs']) => {\n const pluginsNames =\n plugins.length > 0\n ? `[\\n${plugins.map((p) => `\"${p}\"`).join(',\\n')} \\n]`\n : '[]';\n\n return `\nexport default {\n plugins: ${pluginsNames},\n};\n`;\n};\n\nexport const generateConfigFile = (\n configPath: string,\n collectionNames: string[],\n): void => {\n try {\n writeFileSync(configPath, sampleConfig(collectionNames), 'utf8');\n console.log(`Configuration file stored at: ${configPath}`);\n } catch (error) {\n console.error(`Error: Couldn't store config file: ${configPath}!`);\n console.error(error);\n process.exit(1);\n }\n};\n\nexport const configCommand = new CliCommand('config').description(\n 'Manage Pongo configuration',\n);\n\ntype SampleConfigOptions =\n | {\n plugin: string[];\n print?: boolean;\n }\n | {\n plugin: string[];\n generate?: boolean;\n file?: string;\n };\n\nconfigCommand\n .command('sample')\n .description('Generate or print sample configuration')\n .option(\n '-plg, --plugins <name>',\n 'Specify the plugin name',\n (value: string, previous: string[]) => {\n // Accumulate plugins names into an array (explicitly typing `previous` as `string[]`)\n return previous.concat([value]);\n },\n [] as string[],\n )\n .option(\n '-f, --file <path>',\n 'Path to configuration file with collection list',\n )\n .option('-g, --generate', 'Generate sample config file')\n .option('-p, --print', 'Print sample config file')\n .action((options: SampleConfigOptions) => {\n const plugins =\n options.plugin.length > 0\n ? options.plugin\n : ['@event-driven-io/emmett-expressjs'];\n\n if (!('print' in options) && !('generate' in options)) {\n console.error(\n 'Error: Please provide either:\\n--print param to print sample config or\\n--generate to generate sample config file',\n );\n exit(1);\n }\n\n if ('print' in options) {\n console.log(`${sampleConfig(plugins)}`);\n } else if ('generate' in options) {\n if (!options.file) {\n console.error(\n 'Error: You need to provide a config file through a --file',\n );\n exit(1);\n }\n\n generateConfigFile(options.file, plugins);\n }\n });\n","import type { Command as CliCommand } from 'commander';\nimport path from 'path';\nimport {\n isPluginConfig,\n type EmmettCliCommand,\n type EmmettCliPlugin,\n type EmmettPlugin,\n type EmmettPluginConfig,\n type EmmettPluginsConfig,\n type EmmettPluginType,\n} from '../config';\nimport { EmmettError } from '../errors';\nimport { sampleConfig } from './config';\n\nconst PluginsConfigImportError = {\n missingDefaultExport: `Error: Config should contain default export, e.g.\\n\\n${sampleConfig()}`,\n missingPluginsPropertyExport: `Error: Config should contain default export with plugins array, e.g.\\n\\n${sampleConfig()}`,\n wrongPluginStructure: `Error: Plugin config should be either string with plugin name or object with plugin name, e.g. { name: 'emmett-expressjs' }`,\n};\nexport const importPluginsConfig = async (options?: {\n configPath?: string | undefined;\n}): Promise<EmmettPluginsConfig | EmmettError> => {\n const configPath = path.join(\n process.cwd(),\n options?.configPath ?? './dist/emmett.config.js',\n );\n\n console.log('IMPORTING' + configPath);\n\n try {\n const imported = (await import(configPath)) as {\n default: Partial<EmmettPluginsConfig>;\n };\n\n if (!imported.default) {\n return new EmmettError(PluginsConfigImportError.missingDefaultExport);\n }\n\n if (!imported.default.plugins || !Array.isArray(imported.default.plugins)) {\n return new EmmettError(\n PluginsConfigImportError.missingPluginsPropertyExport,\n );\n }\n\n if (!imported.default.plugins.every(isPluginConfig)) {\n return new EmmettError(PluginsConfigImportError.wrongPluginStructure);\n }\n\n return { plugins: imported.default.plugins };\n } catch (error) {\n if (!options?.configPath) {\n console.warn('Didn`t find config file: ' + configPath, error);\n return { plugins: [] };\n }\n return new EmmettError(\n `Error: Couldn't load file:` + (error as Error).toString(),\n );\n }\n};\n\nexport const loadPlugins = async (options?: {\n pluginType?: EmmettPluginType;\n configPath?: string;\n}): Promise<EmmettPlugin[]> => {\n try {\n const pluginsConfig = await importPluginsConfig({\n configPath: options?.configPath,\n });\n\n if (pluginsConfig instanceof EmmettError) throw pluginsConfig;\n\n if (pluginsConfig.plugins.length === 0) {\n console.log(`No extensions specified in config ${options?.configPath}.`);\n return [];\n }\n\n const pluginsToLoad = filterPluginsByType(\n pluginsConfig.plugins,\n options?.pluginType,\n );\n\n const pluginsPromises = pluginsToLoad.map(async (pluginConfig) => {\n const importPath = getImportPath(pluginConfig, options?.pluginType);\n try {\n const plugin = (await import(importPath)) as { default: EmmettPlugin };\n\n console.info(`Loaded plugin: ${importPath}`);\n\n if (!plugin.default) {\n throw new Error(`Plugin: ${importPath} is missing default export`);\n }\n\n return plugin.default;\n } catch (error) {\n console.error(`Failed to load extension \"${importPath}\":`, error);\n return undefined;\n }\n });\n\n return (await Promise.all(pluginsPromises)).filter(\n (plugin) => plugin !== undefined,\n );\n } catch (error) {\n console.error(`Failed to load config ${options?.configPath}:`, error);\n return [];\n }\n};\n\nexport const registerCliPlugins = async (\n program: CliCommand,\n plugins: EmmettCliPlugin[],\n): Promise<void> => {\n const result: EmmettCliPlugin[] = [];\n\n for (const plugin of plugins) {\n const pluginName = plugin.name;\n\n if (!('registerCommands' in plugin)) {\n console.warn(`No registerCommands function found in ${pluginName}`);\n }\n await plugin.registerCommands(program as EmmettCliCommand);\n console.log(`Loaded extension: ${plugin.name}`);\n result.push(plugin);\n }\n};\n\nconst filterPluginsByType = (\n plugins: EmmettPluginConfig[],\n pluginType?: EmmettPluginType,\n): EmmettPluginConfig[] =>\n plugins.filter(\n (p) =>\n typeof p === 'string' ||\n (pluginType &&\n (p.register === undefined ||\n p.register.some((r) => r.pluginType === pluginType))),\n );\n\nconst getImportPath = (\n pluginConfig: EmmettPluginConfig,\n pluginType: EmmettPluginType | undefined,\n) => {\n if (typeof pluginConfig === 'string') {\n return pluginType ? `${pluginConfig}/${pluginType}` : pluginConfig;\n }\n\n const pluginSubpath =\n pluginConfig.register.find((r) => pluginType && r.pluginType === pluginType)\n ?.path ?? pluginType;\n\n return pluginSubpath\n ? `${pluginConfig.name}/${pluginSubpath}`\n : pluginConfig.name;\n};\n","#!/usr/bin/env node\nimport { Command } from 'commander';\nimport { loadPlugins, registerCliPlugins } from './commandLine';\n\nconst program = new Command();\n\nprogram\n .name('emmett')\n .description('CLI tool for Emmett')\n .option('--config <path>', 'Path to the configuration file');\n\n// Load extensions and parse CLI arguments\nconst initCLI = async () => {\n const configIndex = process.argv.indexOf('--config');\n\n const configPath =\n configIndex !== -1 && process.argv.length > configIndex + 1\n ? process.argv[configIndex + 1]\n : undefined;\n\n try {\n const plugins = await loadPlugins({\n pluginType: 'cli',\n configPath: configPath,\n });\n await registerCliPlugins(program, plugins);\n\n // Parse the CLI arguments\n program.parse(process.argv);\n } catch (err) {\n console.error(`Failed to load config from ${configPath}:`, err);\n }\n};\n\n//Initialize CLI and handle errors\ninitCLI().catch((err) => {\n console.error(`CLI initialization failed:`);\n console.error(err);\n});\n\nexport default program;\nexport * from './commandLine';\n"],"mappings":";;;;;;;;AAKA,MAAa,gBAAgB,UAAoB,CAAC,mBAAmB,KAAK;AAMxE,QAAO;;aAJL,QAAQ,SAAS,IACb,MAAM,QAAQ,KAAK,MAAM,IAAI,EAAE,GAAG,CAAC,KAAK,MAAM,CAAC,SAC/C,KAIkB;;;;AAK1B,MAAa,sBACX,YACA,oBACS;AACT,KAAI;AACF,gBAAc,YAAY,aAAa,gBAAgB,EAAE,OAAO;AAChE,UAAQ,IAAI,iCAAiC,aAAa;UACnD,OAAO;AACd,UAAQ,MAAM,sCAAsC,WAAW,GAAG;AAClE,UAAQ,MAAM,MAAM;AACpB,UAAQ,KAAK,EAAE;;;AAInB,MAAa,gBAAgB,IAAIA,QAAW,SAAS,CAAC,YACpD,6BACD;AAaD,cACG,QAAQ,SAAS,CACjB,YAAY,yCAAyC,CACrD,OACC,0BACA,4BACC,OAAe,aAAu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AAM,iBACJ,cACA,eACG;AACH,KAAI,OAAO,iBAAiB,SAC1B,QAAO,aAAa,GAAG,aAAa,GAAG,eAAe;CAGxD,MAAM,gBACJ,aAAa,SAAS,MAAM,MAAM,cAAc,EAAE,eAAe,WAAW,EACxE,QAAQ;AAEd,QAAO,gBACH,GAAG,aAAa,KAAK,GAAG,kBACxB,aAAa;;;;;ACpJnB,MAAM,UAAU,IAAI,SAAS;AAE7B,QACG,KAAK,SAAS,CACd,YAAY,sBAAsB,CAClC,OAAO,mBAAmB,iCAAiC;AAG9D,MAAM,UAAU,YAAY;CAC1B,MAAM,cAAc,QAAQ,KAAK,QAAQ,WAAW;CAEpD,MAAM,aACJ,gBAAgB,MAAM,QAAQ,KAAK,SAAS,cAAc,IACtD,QAAQ,KAAK,cAAc,KAC3B;AAEN,KAAI;AAKF,QAAM,mBAAmB,SAJT,MAAM,YAAY;GAChC,YAAY;GACA;GACb,CAAC,CACwC;AAG1C,UAAQ,MAAM,QAAQ,KAAK;UACpB,KAAK;AACZ,UAAQ,MAAM,8BAA8B,WAAW,IAAI,IAAI;;;AAKnE,SAAS,CAAC,OAAO,QAAQ;AACvB,SAAQ,MAAM,6BAA6B;AAC3C,SAAQ,MAAM,IAAI;EAClB"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
//#region src/config/plugins/index.d.ts
|
|
2
|
+
type EmmettPluginConfig = {
|
|
3
|
+
name: string;
|
|
4
|
+
register: EmmettPluginRegistration[];
|
|
5
|
+
} | string;
|
|
6
|
+
type EmmettPluginType = 'cli';
|
|
7
|
+
type EmmettCliPluginRegistration = {
|
|
8
|
+
pluginType: 'cli';
|
|
9
|
+
path?: string;
|
|
10
|
+
};
|
|
11
|
+
type EmmettPluginRegistration = EmmettCliPluginRegistration;
|
|
12
|
+
type EmmettCliCommand = {
|
|
13
|
+
addCommand<CliCommand>(command: CliCommand): CliCommand;
|
|
14
|
+
};
|
|
15
|
+
type EmmettCliPlugin = {
|
|
16
|
+
pluginType: 'cli';
|
|
17
|
+
name: string;
|
|
18
|
+
registerCommands: (program: EmmettCliCommand) => Promise<void> | void;
|
|
19
|
+
};
|
|
20
|
+
type EmmettPlugin = EmmettCliPlugin;
|
|
21
|
+
declare const isPluginConfig: (plugin: Partial<EmmettPluginConfig> | string | undefined) => plugin is EmmettPluginConfig;
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/config/index.d.ts
|
|
24
|
+
type EmmettPluginsConfig = {
|
|
25
|
+
plugins: EmmettPluginConfig[];
|
|
26
|
+
};
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/errors/index.d.ts
|
|
29
|
+
type ErrorConstructor<ErrorType extends Error> = new (...args: any[]) => ErrorType;
|
|
30
|
+
declare const isErrorConstructor: <ErrorType extends Error>(expect: Function) => expect is ErrorConstructor<ErrorType>;
|
|
31
|
+
declare class EmmettError extends Error {
|
|
32
|
+
static readonly Codes: {
|
|
33
|
+
ValidationError: number;
|
|
34
|
+
IllegalStateError: number;
|
|
35
|
+
NotFoundError: number;
|
|
36
|
+
ConcurrencyError: number;
|
|
37
|
+
InternalServerError: number;
|
|
38
|
+
};
|
|
39
|
+
errorCode: number;
|
|
40
|
+
constructor(options?: {
|
|
41
|
+
errorCode: number;
|
|
42
|
+
message?: string;
|
|
43
|
+
} | string | number);
|
|
44
|
+
static mapFrom(error: Error | {
|
|
45
|
+
message?: string;
|
|
46
|
+
errorCode?: number;
|
|
47
|
+
}): EmmettError;
|
|
48
|
+
static isInstanceOf<ErrorType extends EmmettError = EmmettError>(error: unknown, errorCode?: (typeof EmmettError.Codes)[keyof typeof EmmettError.Codes]): error is ErrorType;
|
|
49
|
+
}
|
|
50
|
+
declare class ConcurrencyError extends EmmettError {
|
|
51
|
+
current: string | undefined;
|
|
52
|
+
expected: string;
|
|
53
|
+
constructor(current: string | undefined, expected: string, message?: string);
|
|
54
|
+
}
|
|
55
|
+
declare class ConcurrencyInMemoryDatabaseError extends EmmettError {
|
|
56
|
+
constructor(message?: string);
|
|
57
|
+
}
|
|
58
|
+
declare class ValidationError extends EmmettError {
|
|
59
|
+
constructor(message?: string);
|
|
60
|
+
}
|
|
61
|
+
declare class IllegalStateError extends EmmettError {
|
|
62
|
+
constructor(message?: string);
|
|
63
|
+
}
|
|
64
|
+
declare class NotFoundError extends EmmettError {
|
|
65
|
+
constructor(options?: {
|
|
66
|
+
id: string;
|
|
67
|
+
type: string;
|
|
68
|
+
message?: string;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
export { isPluginConfig as _, IllegalStateError as a, isErrorConstructor as c, EmmettCliPlugin as d, EmmettCliPluginRegistration as f, EmmettPluginType as g, EmmettPluginRegistration as h, ErrorConstructor as i, EmmettPluginsConfig as l, EmmettPluginConfig as m, ConcurrencyInMemoryDatabaseError as n, NotFoundError as o, EmmettPlugin as p, EmmettError as r, ValidationError as s, ConcurrencyError as t, EmmettCliCommand as u };
|
|
73
|
+
//# sourceMappingURL=index-BXN5muYb.d.cts.map
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
//#region src/config/plugins/index.d.ts
|
|
2
|
+
type EmmettPluginConfig = {
|
|
3
|
+
name: string;
|
|
4
|
+
register: EmmettPluginRegistration[];
|
|
5
|
+
} | string;
|
|
6
|
+
type EmmettPluginType = 'cli';
|
|
7
|
+
type EmmettCliPluginRegistration = {
|
|
8
|
+
pluginType: 'cli';
|
|
9
|
+
path?: string;
|
|
10
|
+
};
|
|
11
|
+
type EmmettPluginRegistration = EmmettCliPluginRegistration;
|
|
12
|
+
type EmmettCliCommand = {
|
|
13
|
+
addCommand<CliCommand>(command: CliCommand): CliCommand;
|
|
14
|
+
};
|
|
15
|
+
type EmmettCliPlugin = {
|
|
16
|
+
pluginType: 'cli';
|
|
17
|
+
name: string;
|
|
18
|
+
registerCommands: (program: EmmettCliCommand) => Promise<void> | void;
|
|
19
|
+
};
|
|
20
|
+
type EmmettPlugin = EmmettCliPlugin;
|
|
21
|
+
declare const isPluginConfig: (plugin: Partial<EmmettPluginConfig> | string | undefined) => plugin is EmmettPluginConfig;
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/config/index.d.ts
|
|
24
|
+
type EmmettPluginsConfig = {
|
|
25
|
+
plugins: EmmettPluginConfig[];
|
|
26
|
+
};
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/errors/index.d.ts
|
|
29
|
+
type ErrorConstructor<ErrorType extends Error> = new (...args: any[]) => ErrorType;
|
|
30
|
+
declare const isErrorConstructor: <ErrorType extends Error>(expect: Function) => expect is ErrorConstructor<ErrorType>;
|
|
31
|
+
declare class EmmettError extends Error {
|
|
32
|
+
static readonly Codes: {
|
|
33
|
+
ValidationError: number;
|
|
34
|
+
IllegalStateError: number;
|
|
35
|
+
NotFoundError: number;
|
|
36
|
+
ConcurrencyError: number;
|
|
37
|
+
InternalServerError: number;
|
|
38
|
+
};
|
|
39
|
+
errorCode: number;
|
|
40
|
+
constructor(options?: {
|
|
41
|
+
errorCode: number;
|
|
42
|
+
message?: string;
|
|
43
|
+
} | string | number);
|
|
44
|
+
static mapFrom(error: Error | {
|
|
45
|
+
message?: string;
|
|
46
|
+
errorCode?: number;
|
|
47
|
+
}): EmmettError;
|
|
48
|
+
static isInstanceOf<ErrorType extends EmmettError = EmmettError>(error: unknown, errorCode?: (typeof EmmettError.Codes)[keyof typeof EmmettError.Codes]): error is ErrorType;
|
|
49
|
+
}
|
|
50
|
+
declare class ConcurrencyError extends EmmettError {
|
|
51
|
+
current: string | undefined;
|
|
52
|
+
expected: string;
|
|
53
|
+
constructor(current: string | undefined, expected: string, message?: string);
|
|
54
|
+
}
|
|
55
|
+
declare class ConcurrencyInMemoryDatabaseError extends EmmettError {
|
|
56
|
+
constructor(message?: string);
|
|
57
|
+
}
|
|
58
|
+
declare class ValidationError extends EmmettError {
|
|
59
|
+
constructor(message?: string);
|
|
60
|
+
}
|
|
61
|
+
declare class IllegalStateError extends EmmettError {
|
|
62
|
+
constructor(message?: string);
|
|
63
|
+
}
|
|
64
|
+
declare class NotFoundError extends EmmettError {
|
|
65
|
+
constructor(options?: {
|
|
66
|
+
id: string;
|
|
67
|
+
type: string;
|
|
68
|
+
message?: string;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
export { isPluginConfig as _, IllegalStateError as a, isErrorConstructor as c, EmmettCliPlugin as d, EmmettCliPluginRegistration as f, EmmettPluginType as g, EmmettPluginRegistration as h, ErrorConstructor as i, EmmettPluginsConfig as l, EmmettPluginConfig as m, ConcurrencyInMemoryDatabaseError as n, NotFoundError as o, EmmettPlugin as p, EmmettError as r, ValidationError as s, ConcurrencyError as t, EmmettCliCommand as u };
|
|
73
|
+
//# sourceMappingURL=index-C0agmFA7.d.ts.map
|