@metamask-previews/messenger 1.2.0-preview-e82188855 → 1.2.0-preview-ef063ff2d
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/CHANGELOG.md +6 -0
- package/dist/Messenger.cjs +24 -0
- package/dist/Messenger.cjs.map +1 -1
- package/dist/Messenger.d.cts +15 -0
- package/dist/Messenger.d.cts.map +1 -1
- package/dist/Messenger.d.mts +15 -0
- package/dist/Messenger.d.mts.map +1 -1
- package/dist/Messenger.mjs +24 -0
- package/dist/Messenger.mjs.map +1 -1
- package/package.json +2 -9
- package/dist/generate-action-types/check.cjs +0 -105
- package/dist/generate-action-types/check.cjs.map +0 -1
- package/dist/generate-action-types/check.d.cts +0 -11
- package/dist/generate-action-types/check.d.cts.map +0 -1
- package/dist/generate-action-types/check.d.mts +0 -11
- package/dist/generate-action-types/check.d.mts.map +0 -1
- package/dist/generate-action-types/check.mjs +0 -78
- package/dist/generate-action-types/check.mjs.map +0 -1
- package/dist/generate-action-types/cli.cjs +0 -108
- package/dist/generate-action-types/cli.cjs.map +0 -1
- package/dist/generate-action-types/cli.d.cts +0 -3
- package/dist/generate-action-types/cli.d.cts.map +0 -1
- package/dist/generate-action-types/cli.d.mts +0 -3
- package/dist/generate-action-types/cli.d.mts.map +0 -1
- package/dist/generate-action-types/cli.mjs +0 -103
- package/dist/generate-action-types/cli.mjs.map +0 -1
- package/dist/generate-action-types/fix.cjs +0 -63
- package/dist/generate-action-types/fix.cjs.map +0 -1
- package/dist/generate-action-types/fix.d.cts +0 -11
- package/dist/generate-action-types/fix.d.cts.map +0 -1
- package/dist/generate-action-types/fix.d.mts +0 -11
- package/dist/generate-action-types/fix.d.mts.map +0 -1
- package/dist/generate-action-types/fix.mjs +0 -36
- package/dist/generate-action-types/fix.mjs.map +0 -1
- package/dist/generate-action-types/generate-content.cjs +0 -69
- package/dist/generate-action-types/generate-content.cjs.map +0 -1
- package/dist/generate-action-types/generate-content.d.cts +0 -9
- package/dist/generate-action-types/generate-content.d.cts.map +0 -1
- package/dist/generate-action-types/generate-content.d.mts +0 -9
- package/dist/generate-action-types/generate-content.d.mts.map +0 -1
- package/dist/generate-action-types/generate-content.mjs +0 -42
- package/dist/generate-action-types/generate-content.mjs.map +0 -1
- package/dist/generate-action-types/parse-source.cjs +0 -324
- package/dist/generate-action-types/parse-source.cjs.map +0 -1
- package/dist/generate-action-types/parse-source.d.cts +0 -25
- package/dist/generate-action-types/parse-source.d.cts.map +0 -1
- package/dist/generate-action-types/parse-source.d.mts +0 -25
- package/dist/generate-action-types/parse-source.d.mts.map +0 -1
- package/dist/generate-action-types/parse-source.mjs +0 -297
- package/dist/generate-action-types/parse-source.mjs.map +0 -1
- package/dist/generate-action-types/types.cjs +0 -3
- package/dist/generate-action-types/types.cjs.map +0 -1
- package/dist/generate-action-types/types.d.cts +0 -6
- package/dist/generate-action-types/types.d.cts.map +0 -1
- package/dist/generate-action-types/types.d.mts +0 -6
- package/dist/generate-action-types/types.d.mts.map +0 -1
- package/dist/generate-action-types/types.mjs +0 -2
- package/dist/generate-action-types/types.mjs.map +0 -1
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
-
};
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const yargs_1 = __importDefault(require("yargs"));
|
|
8
|
-
const check_1 = require("./check.cjs");
|
|
9
|
-
const fix_1 = require("./fix.cjs");
|
|
10
|
-
const parse_source_1 = require("./parse-source.cjs");
|
|
11
|
-
/**
|
|
12
|
-
* Parses the given CLI arguments.
|
|
13
|
-
*
|
|
14
|
-
* @param args - The arguments to parse.
|
|
15
|
-
* @returns The parsed command line arguments.
|
|
16
|
-
*/
|
|
17
|
-
async function parseCommandLineArguments(args) {
|
|
18
|
-
const { check, fix, path: sourcePath, } = await (0, yargs_1.default)(args)
|
|
19
|
-
.command('$0 [path]', 'Generate method action types for controller and service messengers', (yargsInstance) => {
|
|
20
|
-
yargsInstance.positional('path', {
|
|
21
|
-
type: 'string',
|
|
22
|
-
description: 'Path to the folder where controllers/services are located',
|
|
23
|
-
default: 'src',
|
|
24
|
-
});
|
|
25
|
-
})
|
|
26
|
-
.option('check', {
|
|
27
|
-
type: 'boolean',
|
|
28
|
-
description: 'Check if generated action type files are up to date',
|
|
29
|
-
default: false,
|
|
30
|
-
})
|
|
31
|
-
.option('fix', {
|
|
32
|
-
type: 'boolean',
|
|
33
|
-
description: 'Generate/update action type files',
|
|
34
|
-
default: false,
|
|
35
|
-
})
|
|
36
|
-
.help()
|
|
37
|
-
.check((argv) => {
|
|
38
|
-
if (!argv.check && !argv.fix) {
|
|
39
|
-
throw new Error('Either --check or --fix must be provided.\n');
|
|
40
|
-
}
|
|
41
|
-
return true;
|
|
42
|
-
}).argv;
|
|
43
|
-
return {
|
|
44
|
-
check,
|
|
45
|
-
fix,
|
|
46
|
-
sourcePath: sourcePath,
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Attempt to load ESLint from the current project. Returns null if unavailable.
|
|
51
|
-
*
|
|
52
|
-
* @returns An ESLint object with instance and static methods, or null if unavailable.
|
|
53
|
-
*/
|
|
54
|
-
async function loadESLint() {
|
|
55
|
-
try {
|
|
56
|
-
const { ESLint: ESLintClass } = await import("eslint");
|
|
57
|
-
const instance = new ESLintClass({
|
|
58
|
-
fix: true,
|
|
59
|
-
errorOnUnmatchedPattern: false,
|
|
60
|
-
});
|
|
61
|
-
return {
|
|
62
|
-
instance,
|
|
63
|
-
eslintClass: ESLintClass,
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
catch {
|
|
67
|
-
console.warn('⚠️ ESLint could not be loaded. Generated files will not be formatted.');
|
|
68
|
-
return null;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Main entry point for the CLI.
|
|
73
|
-
*/
|
|
74
|
-
async function main() {
|
|
75
|
-
console.warn('⚠️ `messenger-generate-action-types` from @metamask/messenger is deprecated. Use `messenger-action-types` from @metamask/messenger-cli instead.');
|
|
76
|
-
const { fix, sourcePath } = await parseCommandLineArguments(globalThis.process.argv.slice(2));
|
|
77
|
-
console.log('🔍 Searching for controllers/services with MESSENGER_EXPOSED_METHODS...');
|
|
78
|
-
const sources = await (0, parse_source_1.findSourcesWithExposedMethods)(sourcePath);
|
|
79
|
-
if (sources.length === 0) {
|
|
80
|
-
console.log('⚠️ No controllers/services found with MESSENGER_EXPOSED_METHODS');
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
console.log(`📦 Found ${sources.length} controller(s)/service(s) with exposed methods`);
|
|
84
|
-
const eslint = await loadESLint();
|
|
85
|
-
if (fix) {
|
|
86
|
-
const success = await (0, fix_1.generateAllActionTypesFiles)(sources, eslint);
|
|
87
|
-
if (success) {
|
|
88
|
-
console.log('\n🎉 All action types generated successfully!');
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
// eslint-disable-next-line no-restricted-globals
|
|
92
|
-
process.exitCode = 1;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
const success = await (0, check_1.checkActionTypesFiles)(sources, eslint);
|
|
97
|
-
if (!success) {
|
|
98
|
-
// eslint-disable-next-line no-restricted-globals
|
|
99
|
-
process.exitCode = 1;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
main().catch((error) => {
|
|
104
|
-
console.error('❌ Script failed:', error);
|
|
105
|
-
// eslint-disable-next-line no-restricted-globals
|
|
106
|
-
process.exitCode = 1;
|
|
107
|
-
});
|
|
108
|
-
//# sourceMappingURL=cli.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli.cjs","sourceRoot":"","sources":["../../src/generate-action-types/cli.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iDAAiD;YACjD,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC;IACzC,iDAAiD;IACjD,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\n\nimport yargs from 'yargs';\n\nimport { checkActionTypesFiles } from './check';\nimport { generateAllActionTypesFiles } from './fix';\nimport { findSourcesWithExposedMethods } from './parse-source';\nimport type { ESLint } from './types';\n\ntype CommandLineArguments = {\n check: boolean;\n fix: boolean;\n sourcePath: string;\n};\n\n/**\n * Parses the given CLI arguments.\n *\n * @param args - The arguments to parse.\n * @returns The parsed command line arguments.\n */\nasync function parseCommandLineArguments(\n args: string[],\n): Promise<CommandLineArguments> {\n const {\n check,\n fix,\n path: sourcePath,\n } = await yargs(args)\n .command(\n '$0 [path]',\n 'Generate method action types for controller and service messengers',\n (yargsInstance) => {\n yargsInstance.positional('path', {\n type: 'string',\n description:\n 'Path to the folder where controllers/services are located',\n default: 'src',\n });\n },\n )\n .option('check', {\n type: 'boolean',\n description: 'Check if generated action type files are up to date',\n default: false,\n })\n .option('fix', {\n type: 'boolean',\n description: 'Generate/update action type files',\n default: false,\n })\n .help()\n .check((argv) => {\n if (!argv.check && !argv.fix) {\n throw new Error('Either --check or --fix must be provided.\\n');\n }\n return true;\n }).argv;\n\n return {\n check,\n fix,\n sourcePath: sourcePath as string,\n };\n}\n\n/**\n * Attempt to load ESLint from the current project. Returns null if unavailable.\n *\n * @returns An ESLint object with instance and static methods, or null if unavailable.\n */\nasync function loadESLint(): Promise<ESLint | null> {\n try {\n const { ESLint: ESLintClass } = await import('eslint');\n const instance = new ESLintClass({\n fix: true,\n errorOnUnmatchedPattern: false,\n });\n return {\n instance,\n eslintClass: ESLintClass,\n };\n } catch {\n console.warn(\n '⚠️ ESLint could not be loaded. Generated files will not be formatted.',\n );\n return null;\n }\n}\n\n/**\n * Main entry point for the CLI.\n */\nasync function main(): Promise<void> {\n console.warn(\n '⚠️ `messenger-generate-action-types` from @metamask/messenger is deprecated. Use `messenger-action-types` from @metamask/messenger-cli instead.',\n );\n\n const { fix, sourcePath } = await parseCommandLineArguments(\n globalThis.process.argv.slice(2),\n );\n\n console.log(\n '🔍 Searching for controllers/services with MESSENGER_EXPOSED_METHODS...',\n );\n\n const sources = await findSourcesWithExposedMethods(sourcePath);\n\n if (sources.length === 0) {\n console.log(\n '⚠️ No controllers/services found with MESSENGER_EXPOSED_METHODS',\n );\n return;\n }\n\n console.log(\n `📦 Found ${sources.length} controller(s)/service(s) with exposed methods`,\n );\n\n const eslint = await loadESLint();\n\n if (fix) {\n const success = await generateAllActionTypesFiles(sources, eslint);\n if (success) {\n console.log('\\n🎉 All action types generated successfully!');\n } else {\n // eslint-disable-next-line no-restricted-globals\n process.exitCode = 1;\n }\n } else {\n const success = await checkActionTypesFiles(sources, eslint);\n if (!success) {\n // eslint-disable-next-line no-restricted-globals\n process.exitCode = 1;\n }\n }\n}\n\nmain().catch((error) => {\n console.error('❌ Script failed:', error);\n // eslint-disable-next-line no-restricted-globals\n process.exitCode = 1;\n});\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.cts","sourceRoot":"","sources":["../../src/generate-action-types/cli.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.mts","sourceRoot":"","sources":["../../src/generate-action-types/cli.ts"],"names":[],"mappings":""}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import yargs from "yargs";
|
|
3
|
-
import { checkActionTypesFiles } from "./check.mjs";
|
|
4
|
-
import { generateAllActionTypesFiles } from "./fix.mjs";
|
|
5
|
-
import { findSourcesWithExposedMethods } from "./parse-source.mjs";
|
|
6
|
-
/**
|
|
7
|
-
* Parses the given CLI arguments.
|
|
8
|
-
*
|
|
9
|
-
* @param args - The arguments to parse.
|
|
10
|
-
* @returns The parsed command line arguments.
|
|
11
|
-
*/
|
|
12
|
-
async function parseCommandLineArguments(args) {
|
|
13
|
-
const { check, fix, path: sourcePath, } = await yargs(args)
|
|
14
|
-
.command('$0 [path]', 'Generate method action types for controller and service messengers', (yargsInstance) => {
|
|
15
|
-
yargsInstance.positional('path', {
|
|
16
|
-
type: 'string',
|
|
17
|
-
description: 'Path to the folder where controllers/services are located',
|
|
18
|
-
default: 'src',
|
|
19
|
-
});
|
|
20
|
-
})
|
|
21
|
-
.option('check', {
|
|
22
|
-
type: 'boolean',
|
|
23
|
-
description: 'Check if generated action type files are up to date',
|
|
24
|
-
default: false,
|
|
25
|
-
})
|
|
26
|
-
.option('fix', {
|
|
27
|
-
type: 'boolean',
|
|
28
|
-
description: 'Generate/update action type files',
|
|
29
|
-
default: false,
|
|
30
|
-
})
|
|
31
|
-
.help()
|
|
32
|
-
.check((argv) => {
|
|
33
|
-
if (!argv.check && !argv.fix) {
|
|
34
|
-
throw new Error('Either --check or --fix must be provided.\n');
|
|
35
|
-
}
|
|
36
|
-
return true;
|
|
37
|
-
}).argv;
|
|
38
|
-
return {
|
|
39
|
-
check,
|
|
40
|
-
fix,
|
|
41
|
-
sourcePath: sourcePath,
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Attempt to load ESLint from the current project. Returns null if unavailable.
|
|
46
|
-
*
|
|
47
|
-
* @returns An ESLint object with instance and static methods, or null if unavailable.
|
|
48
|
-
*/
|
|
49
|
-
async function loadESLint() {
|
|
50
|
-
try {
|
|
51
|
-
const { ESLint: ESLintClass } = await import("eslint");
|
|
52
|
-
const instance = new ESLintClass({
|
|
53
|
-
fix: true,
|
|
54
|
-
errorOnUnmatchedPattern: false,
|
|
55
|
-
});
|
|
56
|
-
return {
|
|
57
|
-
instance,
|
|
58
|
-
eslintClass: ESLintClass,
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
catch {
|
|
62
|
-
console.warn('⚠️ ESLint could not be loaded. Generated files will not be formatted.');
|
|
63
|
-
return null;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Main entry point for the CLI.
|
|
68
|
-
*/
|
|
69
|
-
async function main() {
|
|
70
|
-
console.warn('⚠️ `messenger-generate-action-types` from @metamask/messenger is deprecated. Use `messenger-action-types` from @metamask/messenger-cli instead.');
|
|
71
|
-
const { fix, sourcePath } = await parseCommandLineArguments(globalThis.process.argv.slice(2));
|
|
72
|
-
console.log('🔍 Searching for controllers/services with MESSENGER_EXPOSED_METHODS...');
|
|
73
|
-
const sources = await findSourcesWithExposedMethods(sourcePath);
|
|
74
|
-
if (sources.length === 0) {
|
|
75
|
-
console.log('⚠️ No controllers/services found with MESSENGER_EXPOSED_METHODS');
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
console.log(`📦 Found ${sources.length} controller(s)/service(s) with exposed methods`);
|
|
79
|
-
const eslint = await loadESLint();
|
|
80
|
-
if (fix) {
|
|
81
|
-
const success = await generateAllActionTypesFiles(sources, eslint);
|
|
82
|
-
if (success) {
|
|
83
|
-
console.log('\n🎉 All action types generated successfully!');
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
// eslint-disable-next-line no-restricted-globals
|
|
87
|
-
process.exitCode = 1;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
const success = await checkActionTypesFiles(sources, eslint);
|
|
92
|
-
if (!success) {
|
|
93
|
-
// eslint-disable-next-line no-restricted-globals
|
|
94
|
-
process.exitCode = 1;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
main().catch((error) => {
|
|
99
|
-
console.error('❌ Script failed:', error);
|
|
100
|
-
// eslint-disable-next-line no-restricted-globals
|
|
101
|
-
process.exitCode = 1;
|
|
102
|
-
});
|
|
103
|
-
//# sourceMappingURL=cli.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli.mjs","sourceRoot":"","sources":["../../src/generate-action-types/cli.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,cAAc;AAE1B,OAAO,EAAE,qBAAqB,EAAE,oBAAgB;AAChD,OAAO,EAAE,2BAA2B,EAAE,kBAAc;AACpD,OAAO,EAAE,6BAA6B,EAAE,2BAAuB;AAS/D;;;;;GAKG;AACH,KAAK,UAAU,yBAAyB,CACtC,IAAc;IAEd,MAAM,EACJ,KAAK,EACL,GAAG,EACH,IAAI,EAAE,UAAU,GACjB,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC;SAClB,OAAO,CACN,WAAW,EACX,oEAAoE,EACpE,CAAC,aAAa,EAAE,EAAE;QAChB,aAAa,CAAC,UAAU,CAAC,MAAM,EAAE;YAC/B,IAAI,EAAE,QAAQ;YACd,WAAW,EACT,2DAA2D;YAC7D,OAAO,EAAE,KAAK;SACf,CAAC,CAAC;IACL,CAAC,CACF;SACA,MAAM,CAAC,OAAO,EAAE;QACf,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,qDAAqD;QAClE,OAAO,EAAE,KAAK;KACf,CAAC;SACD,MAAM,CAAC,KAAK,EAAE;QACb,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,mCAAmC;QAChD,OAAO,EAAE,KAAK;KACf,CAAC;SACD,IAAI,EAAE;SACN,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE;QACd,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;QACjE,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC,IAAI,CAAC;IAEV,OAAO;QACL,KAAK;QACL,GAAG;QACH,UAAU,EAAE,U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AC;aAAM,CAAC;YACN,iDAAiD;YACjD,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;SAAM,CAAC;QACN,MAAM,OAAO,GAAG,MAAM,qBAAqB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC7D,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,iDAAiD;YACjD,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC;IACzC,iDAAiD;IACjD,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\n\nimport yargs from 'yargs';\n\nimport { checkActionTypesFiles } from './check';\nimport { generateAllActionTypesFiles } from './fix';\nimport { findSourcesWithExposedMethods } from './parse-source';\nimport type { ESLint } from './types';\n\ntype CommandLineArguments = {\n check: boolean;\n fix: boolean;\n sourcePath: string;\n};\n\n/**\n * Parses the given CLI arguments.\n *\n * @param args - The arguments to parse.\n * @returns The parsed command line arguments.\n */\nasync function parseCommandLineArguments(\n args: string[],\n): Promise<CommandLineArguments> {\n const {\n check,\n fix,\n path: sourcePath,\n } = await yargs(args)\n .command(\n '$0 [path]',\n 'Generate method action types for controller and service messengers',\n (yargsInstance) => {\n yargsInstance.positional('path', {\n type: 'string',\n description:\n 'Path to the folder where controllers/services are located',\n default: 'src',\n });\n },\n )\n .option('check', {\n type: 'boolean',\n description: 'Check if generated action type files are up to date',\n default: false,\n })\n .option('fix', {\n type: 'boolean',\n description: 'Generate/update action type files',\n default: false,\n })\n .help()\n .check((argv) => {\n if (!argv.check && !argv.fix) {\n throw new Error('Either --check or --fix must be provided.\\n');\n }\n return true;\n }).argv;\n\n return {\n check,\n fix,\n sourcePath: sourcePath as string,\n };\n}\n\n/**\n * Attempt to load ESLint from the current project. Returns null if unavailable.\n *\n * @returns An ESLint object with instance and static methods, or null if unavailable.\n */\nasync function loadESLint(): Promise<ESLint | null> {\n try {\n const { ESLint: ESLintClass } = await import('eslint');\n const instance = new ESLintClass({\n fix: true,\n errorOnUnmatchedPattern: false,\n });\n return {\n instance,\n eslintClass: ESLintClass,\n };\n } catch {\n console.warn(\n '⚠️ ESLint could not be loaded. Generated files will not be formatted.',\n );\n return null;\n }\n}\n\n/**\n * Main entry point for the CLI.\n */\nasync function main(): Promise<void> {\n console.warn(\n '⚠️ `messenger-generate-action-types` from @metamask/messenger is deprecated. Use `messenger-action-types` from @metamask/messenger-cli instead.',\n );\n\n const { fix, sourcePath } = await parseCommandLineArguments(\n globalThis.process.argv.slice(2),\n );\n\n console.log(\n '🔍 Searching for controllers/services with MESSENGER_EXPOSED_METHODS...',\n );\n\n const sources = await findSourcesWithExposedMethods(sourcePath);\n\n if (sources.length === 0) {\n console.log(\n '⚠️ No controllers/services found with MESSENGER_EXPOSED_METHODS',\n );\n return;\n }\n\n console.log(\n `📦 Found ${sources.length} controller(s)/service(s) with exposed methods`,\n );\n\n const eslint = await loadESLint();\n\n if (fix) {\n const success = await generateAllActionTypesFiles(sources, eslint);\n if (success) {\n console.log('\\n🎉 All action types generated successfully!');\n } else {\n // eslint-disable-next-line no-restricted-globals\n process.exitCode = 1;\n }\n } else {\n const success = await checkActionTypesFiles(sources, eslint);\n if (!success) {\n // eslint-disable-next-line no-restricted-globals\n process.exitCode = 1;\n }\n }\n}\n\nmain().catch((error) => {\n console.error('❌ Script failed:', error);\n // eslint-disable-next-line no-restricted-globals\n process.exitCode = 1;\n});\n"]}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.generateAllActionTypesFiles = void 0;
|
|
27
|
-
const fs = __importStar(require("node:fs"));
|
|
28
|
-
const path = __importStar(require("node:path"));
|
|
29
|
-
const generate_content_1 = require("./generate-content.cjs");
|
|
30
|
-
/**
|
|
31
|
-
* Generates action types files for all controllers/services.
|
|
32
|
-
*
|
|
33
|
-
* @param sources - Array of source information objects.
|
|
34
|
-
* @param eslint - Optional ESLint instance and static methods for formatting.
|
|
35
|
-
* @returns Whether all files were generated successfully.
|
|
36
|
-
*/
|
|
37
|
-
async function generateAllActionTypesFiles(sources, eslint) {
|
|
38
|
-
const outputFiles = [];
|
|
39
|
-
for (const source of sources) {
|
|
40
|
-
console.log(`\n🔧 Processing ${source.name}...`);
|
|
41
|
-
const outputDir = path.dirname(source.filePath);
|
|
42
|
-
const baseFileName = path.basename(source.filePath, '.ts');
|
|
43
|
-
const outputFile = path.join(outputDir, `${baseFileName}-method-action-types.ts`);
|
|
44
|
-
const generatedContent = (0, generate_content_1.generateActionTypesContent)(source);
|
|
45
|
-
await fs.promises.writeFile(outputFile, generatedContent, 'utf8');
|
|
46
|
-
outputFiles.push(outputFile);
|
|
47
|
-
console.log(`✅ Generated action types for ${source.name}`);
|
|
48
|
-
}
|
|
49
|
-
if (outputFiles.length > 0 && eslint) {
|
|
50
|
-
console.log('\n📝 Running ESLint on generated files...');
|
|
51
|
-
const results = await eslint.instance.lintFiles(outputFiles);
|
|
52
|
-
await eslint.eslintClass.outputFixes(results);
|
|
53
|
-
const errors = eslint.eslintClass.getErrorResults(results);
|
|
54
|
-
if (errors.length > 0) {
|
|
55
|
-
console.error('❌ ESLint errors:', errors);
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
console.log('✅ ESLint formatting applied');
|
|
59
|
-
}
|
|
60
|
-
return true;
|
|
61
|
-
}
|
|
62
|
-
exports.generateAllActionTypesFiles = generateAllActionTypesFiles;
|
|
63
|
-
//# sourceMappingURL=fix.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fix.cjs","sourceRoot":"","sources":["../../src/generate-action-types/fix.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAA8B;AAC9B,gDAAkC;AAElC,6DAAgE;AAIhE;;;;;;GAMG;AACI,KAAK,UAAU,2BAA2B,CAC/C,OAAqB,EACrB,MAAqB;IAErB,MAAM,WAAW,GAAa,EAAE,CAAC;IAEjC,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,OAAO,CAAC,GAAG,CAAC,mBAAmB,MAAM,CAAC,IAAI,KAAK,CAAC,CAAC;QACjD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAChD,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QAC3D,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAC1B,SAAS,EACT,GAAG,YAAY,yBAAyB,CACzC,CAAC;QAEF,MAAM,gBAAgB,GAAG,IAAA,6CAA0B,EAAC,MAAM,CAAC,CAAC;QAC5D,MAAM,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,UAAU,EAAE,gBAAgB,EAAE,MAAM,CAAC,CAAC;QAClE,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC7B,OAAO,CAAC,GAAG,CAAC,gCAAgC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IAC7D,CAAC;IAED,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,IAAI,MAAM,EAAE,CAAC;QACrC,OAAO,CAAC,GAAG,CAAC,2CAA2C,CAAC,CAAC;QAEzD,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;QAC7D,MAAM,MAAM,CAAC,WAAW,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QAC9C,MAAM,MAAM,GAAG,MAAM,CAAC,WAAW,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QAC3D,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtB,OAAO,CAAC,KAAK,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;YAC1C,OAAO,KAAK,CAAC;QACf,CAAC;QACD,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;IAC7C,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAnCD,kEAmCC","sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\n\nimport { generateActionTypesContent } from './generate-content';\nimport type { SourceInfo } from './parse-source';\nimport type { ESLint } from './types';\n\n/**\n * Generates action types files for all controllers/services.\n *\n * @param sources - Array of source information objects.\n * @param eslint - Optional ESLint instance and static methods for formatting.\n * @returns Whether all files were generated successfully.\n */\nexport async function generateAllActionTypesFiles(\n sources: SourceInfo[],\n eslint: ESLint | null,\n): Promise<boolean> {\n const outputFiles: string[] = [];\n\n for (const source of sources) {\n console.log(`\\n🔧 Processing ${source.name}...`);\n const outputDir = path.dirname(source.filePath);\n const baseFileName = path.basename(source.filePath, '.ts');\n const outputFile = path.join(\n outputDir,\n `${baseFileName}-method-action-types.ts`,\n );\n\n const generatedContent = generateActionTypesContent(source);\n await fs.promises.writeFile(outputFile, generatedContent, 'utf8');\n outputFiles.push(outputFile);\n console.log(`✅ Generated action types for ${source.name}`);\n }\n\n if (outputFiles.length > 0 && eslint) {\n console.log('\\n📝 Running ESLint on generated files...');\n\n const results = await eslint.instance.lintFiles(outputFiles);\n await eslint.eslintClass.outputFixes(results);\n const errors = eslint.eslintClass.getErrorResults(results);\n if (errors.length > 0) {\n console.error('❌ ESLint errors:', errors);\n return false;\n }\n console.log('✅ ESLint formatting applied');\n }\n\n return true;\n}\n"]}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { SourceInfo } from "./parse-source.cjs";
|
|
2
|
-
import type { ESLint } from "./types.cjs";
|
|
3
|
-
/**
|
|
4
|
-
* Generates action types files for all controllers/services.
|
|
5
|
-
*
|
|
6
|
-
* @param sources - Array of source information objects.
|
|
7
|
-
* @param eslint - Optional ESLint instance and static methods for formatting.
|
|
8
|
-
* @returns Whether all files were generated successfully.
|
|
9
|
-
*/
|
|
10
|
-
export declare function generateAllActionTypesFiles(sources: SourceInfo[], eslint: ESLint | null): Promise<boolean>;
|
|
11
|
-
//# sourceMappingURL=fix.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fix.d.cts","sourceRoot":"","sources":["../../src/generate-action-types/fix.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,2BAAuB;AACjD,OAAO,KAAK,EAAE,MAAM,EAAE,oBAAgB;AAEtC;;;;;;GAMG;AACH,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,UAAU,EAAE,EACrB,MAAM,EAAE,MAAM,GAAG,IAAI,GACpB,OAAO,CAAC,OAAO,CAAC,CAgClB"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { SourceInfo } from "./parse-source.mjs";
|
|
2
|
-
import type { ESLint } from "./types.mjs";
|
|
3
|
-
/**
|
|
4
|
-
* Generates action types files for all controllers/services.
|
|
5
|
-
*
|
|
6
|
-
* @param sources - Array of source information objects.
|
|
7
|
-
* @param eslint - Optional ESLint instance and static methods for formatting.
|
|
8
|
-
* @returns Whether all files were generated successfully.
|
|
9
|
-
*/
|
|
10
|
-
export declare function generateAllActionTypesFiles(sources: SourceInfo[], eslint: ESLint | null): Promise<boolean>;
|
|
11
|
-
//# sourceMappingURL=fix.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fix.d.mts","sourceRoot":"","sources":["../../src/generate-action-types/fix.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,2BAAuB;AACjD,OAAO,KAAK,EAAE,MAAM,EAAE,oBAAgB;AAEtC;;;;;;GAMG;AACH,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,UAAU,EAAE,EACrB,MAAM,EAAE,MAAM,GAAG,IAAI,GACpB,OAAO,CAAC,OAAO,CAAC,CAgClB"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import * as fs from "node:fs";
|
|
2
|
-
import * as path from "node:path";
|
|
3
|
-
import { generateActionTypesContent } from "./generate-content.mjs";
|
|
4
|
-
/**
|
|
5
|
-
* Generates action types files for all controllers/services.
|
|
6
|
-
*
|
|
7
|
-
* @param sources - Array of source information objects.
|
|
8
|
-
* @param eslint - Optional ESLint instance and static methods for formatting.
|
|
9
|
-
* @returns Whether all files were generated successfully.
|
|
10
|
-
*/
|
|
11
|
-
export async function generateAllActionTypesFiles(sources, eslint) {
|
|
12
|
-
const outputFiles = [];
|
|
13
|
-
for (const source of sources) {
|
|
14
|
-
console.log(`\n🔧 Processing ${source.name}...`);
|
|
15
|
-
const outputDir = path.dirname(source.filePath);
|
|
16
|
-
const baseFileName = path.basename(source.filePath, '.ts');
|
|
17
|
-
const outputFile = path.join(outputDir, `${baseFileName}-method-action-types.ts`);
|
|
18
|
-
const generatedContent = generateActionTypesContent(source);
|
|
19
|
-
await fs.promises.writeFile(outputFile, generatedContent, 'utf8');
|
|
20
|
-
outputFiles.push(outputFile);
|
|
21
|
-
console.log(`✅ Generated action types for ${source.name}`);
|
|
22
|
-
}
|
|
23
|
-
if (outputFiles.length > 0 && eslint) {
|
|
24
|
-
console.log('\n📝 Running ESLint on generated files...');
|
|
25
|
-
const results = await eslint.instance.lintFiles(outputFiles);
|
|
26
|
-
await eslint.eslintClass.outputFixes(results);
|
|
27
|
-
const errors = eslint.eslintClass.getErrorResults(results);
|
|
28
|
-
if (errors.length > 0) {
|
|
29
|
-
console.error('❌ ESLint errors:', errors);
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
|
-
console.log('✅ ESLint formatting applied');
|
|
33
|
-
}
|
|
34
|
-
return true;
|
|
35
|
-
}
|
|
36
|
-
//# sourceMappingURL=fix.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fix.mjs","sourceRoot":"","sources":["../../src/generate-action-types/fix.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB;AAC9B,OAAO,KAAK,IAAI,kBAAkB;AAElC,OAAO,EAAE,0BAA0B,EAAE,+BAA2B;AAIhE;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC/C,OAAqB,EACrB,MAAqB;IAErB,MAAM,WAAW,GAAa,EAAE,CAAC;IAEjC,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,OAAO,CAAC,GAAG,CAAC,mBAAmB,MAAM,CAAC,IAAI,KAAK,CAAC,CA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nimport type { SourceInfo } from './parse-source';\nimport type { ESLint } from './types';\n\n/**\n * Generates action types files for all controllers/services.\n *\n * @param sources - Array of source information objects.\n * @param eslint - Optional ESLint instance and static methods for formatting.\n * @returns Whether all files were generated successfully.\n */\nexport async function generateAllActionTypesFiles(\n sources: SourceInfo[],\n eslint: ESLint | null,\n): Promise<boolean> {\n const outputFiles: string[] = [];\n\n for (const source of sources) {\n console.log(`\\n🔧 Processing ${source.name}...`);\n const outputDir = path.dirname(source.filePath);\n const baseFileName = path.basename(source.filePath, '.ts');\n const outputFile = path.join(\n outputDir,\n `${baseFileName}-method-action-types.ts`,\n );\n\n const generatedContent = generateActionTypesContent(source);\n await fs.promises.writeFile(outputFile, generatedContent, 'utf8');\n outputFiles.push(outputFile);\n console.log(`✅ Generated action types for ${source.name}`);\n }\n\n if (outputFiles.length > 0 && eslint) {\n console.log('\\n📝 Running ESLint on generated files...');\n\n const results = await eslint.instance.lintFiles(outputFiles);\n await eslint.eslintClass.outputFixes(results);\n const errors = eslint.eslintClass.getErrorResults(results);\n if (errors.length > 0) {\n console.error('❌ ESLint errors:', errors);\n return false;\n }\n console.log('✅ ESLint formatting applied');\n }\n\n return true;\n}\n"]}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.generateActionTypesContent = void 0;
|
|
27
|
-
const path = __importStar(require("node:path"));
|
|
28
|
-
/**
|
|
29
|
-
* Generates the content for the action types file.
|
|
30
|
-
*
|
|
31
|
-
* @param source - The source information object (controller or service).
|
|
32
|
-
* @returns The content for the action types file.
|
|
33
|
-
*/
|
|
34
|
-
function generateActionTypesContent(source) {
|
|
35
|
-
const baseFileName = path.basename(source.filePath, '.ts');
|
|
36
|
-
const sourceImportPath = `./${baseFileName}`;
|
|
37
|
-
let content = `/**
|
|
38
|
-
* This file is auto generated.
|
|
39
|
-
* Do not edit manually.
|
|
40
|
-
*/
|
|
41
|
-
|
|
42
|
-
import type { ${source.name} } from '${sourceImportPath}';
|
|
43
|
-
|
|
44
|
-
`;
|
|
45
|
-
const actionTypeNames = [];
|
|
46
|
-
for (const method of source.methods) {
|
|
47
|
-
const capitalizedName = method.name.charAt(0).toUpperCase() + method.name.slice(1);
|
|
48
|
-
const actionTypeName = `${source.name}${capitalizedName}Action`;
|
|
49
|
-
const actionString = `${source.name}:${method.name}`;
|
|
50
|
-
actionTypeNames.push(actionTypeName);
|
|
51
|
-
if (method.jsDoc) {
|
|
52
|
-
content += `${method.jsDoc}\n`;
|
|
53
|
-
}
|
|
54
|
-
content += `export type ${actionTypeName} = {
|
|
55
|
-
type: \`${actionString}\`;
|
|
56
|
-
handler: ${source.name}['${method.name}'];
|
|
57
|
-
};\n\n`;
|
|
58
|
-
}
|
|
59
|
-
if (actionTypeNames.length > 0) {
|
|
60
|
-
const unionTypeName = `${source.name}MethodActions`;
|
|
61
|
-
content += `/**
|
|
62
|
-
* Union of all ${source.name} action types.
|
|
63
|
-
*/
|
|
64
|
-
export type ${unionTypeName} = ${actionTypeNames.join(' | ')};\n`;
|
|
65
|
-
}
|
|
66
|
-
return `${content.trimEnd()}\n`;
|
|
67
|
-
}
|
|
68
|
-
exports.generateActionTypesContent = generateActionTypesContent;
|
|
69
|
-
//# sourceMappingURL=generate-content.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generate-content.cjs","sourceRoot":"","sources":["../../src/generate-action-types/generate-content.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAkC;AAIlC;;;;;GAKG;AACH,SAAgB,0BAA0B,CAAC,MAAkB;IAC3D,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC3D,MAAM,gBAAgB,GAAG,KAAK,YAAY,EAAE,CAAC;IAE7C,IAAI,OAAO,GAAG;;;;;gBAKA,MAAM,CAAC,IAAI,YAAY,gBAAgB;;CAEtD,CAAC;IAEA,MAAM,eAAe,GAAa,EAAE,CAAC;IAErC,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACpC,MAAM,eAAe,GACnB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC7D,MAAM,cAAc,GAAG,GAAG,MAAM,CAAC,IAAI,GAAG,eAAe,QAAQ,CAAC;QAChE,MAAM,YAAY,GAAG,GAAG,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;QAErD,eAAe,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAErC,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;YACjB,OAAO,IAAI,GAAG,MAAM,CAAC,KAAK,IAAI,CAAC;QACjC,CAAC;QAED,OAAO,IAAI,eAAe,cAAc;YAChC,YAAY;aACX,MAAM,CAAC,IAAI,KAAK,MAAM,CAAC,IAAI;OACjC,CAAC;IACN,CAAC;IAED,IAAI,eAAe,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC/B,MAAM,aAAa,GAAG,GAAG,MAAM,CAAC,IAAI,eAAe,CAAC;QACpD,OAAO,IAAI;kBACG,MAAM,CAAC,IAAI;;cAEf,aAAa,MAAM,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;IAChE,CAAC;IAED,OAAO,GAAG,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC;AAClC,CAAC;AA1CD,gEA0CC","sourcesContent":["import * as path from 'node:path';\n\nimport type { SourceInfo } from './parse-source';\n\n/**\n * Generates the content for the action types file.\n *\n * @param source - The source information object (controller or service).\n * @returns The content for the action types file.\n */\nexport function generateActionTypesContent(source: SourceInfo): string {\n const baseFileName = path.basename(source.filePath, '.ts');\n const sourceImportPath = `./${baseFileName}`;\n\n let content = `/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { ${source.name} } from '${sourceImportPath}';\n\n`;\n\n const actionTypeNames: string[] = [];\n\n for (const method of source.methods) {\n const capitalizedName =\n method.name.charAt(0).toUpperCase() + method.name.slice(1);\n const actionTypeName = `${source.name}${capitalizedName}Action`;\n const actionString = `${source.name}:${method.name}`;\n\n actionTypeNames.push(actionTypeName);\n\n if (method.jsDoc) {\n content += `${method.jsDoc}\\n`;\n }\n\n content += `export type ${actionTypeName} = {\n type: \\`${actionString}\\`;\n handler: ${source.name}['${method.name}'];\n};\\n\\n`;\n }\n\n if (actionTypeNames.length > 0) {\n const unionTypeName = `${source.name}MethodActions`;\n content += `/**\n * Union of all ${source.name} action types.\n */\nexport type ${unionTypeName} = ${actionTypeNames.join(' | ')};\\n`;\n }\n\n return `${content.trimEnd()}\\n`;\n}\n"]}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { SourceInfo } from "./parse-source.cjs";
|
|
2
|
-
/**
|
|
3
|
-
* Generates the content for the action types file.
|
|
4
|
-
*
|
|
5
|
-
* @param source - The source information object (controller or service).
|
|
6
|
-
* @returns The content for the action types file.
|
|
7
|
-
*/
|
|
8
|
-
export declare function generateActionTypesContent(source: SourceInfo): string;
|
|
9
|
-
//# sourceMappingURL=generate-content.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generate-content.d.cts","sourceRoot":"","sources":["../../src/generate-action-types/generate-content.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,2BAAuB;AAEjD;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CA0CrE"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { SourceInfo } from "./parse-source.mjs";
|
|
2
|
-
/**
|
|
3
|
-
* Generates the content for the action types file.
|
|
4
|
-
*
|
|
5
|
-
* @param source - The source information object (controller or service).
|
|
6
|
-
* @returns The content for the action types file.
|
|
7
|
-
*/
|
|
8
|
-
export declare function generateActionTypesContent(source: SourceInfo): string;
|
|
9
|
-
//# sourceMappingURL=generate-content.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generate-content.d.mts","sourceRoot":"","sources":["../../src/generate-action-types/generate-content.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,2BAAuB;AAEjD;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CA0CrE"}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import * as path from "node:path";
|
|
2
|
-
/**
|
|
3
|
-
* Generates the content for the action types file.
|
|
4
|
-
*
|
|
5
|
-
* @param source - The source information object (controller or service).
|
|
6
|
-
* @returns The content for the action types file.
|
|
7
|
-
*/
|
|
8
|
-
export function generateActionTypesContent(source) {
|
|
9
|
-
const baseFileName = path.basename(source.filePath, '.ts');
|
|
10
|
-
const sourceImportPath = `./${baseFileName}`;
|
|
11
|
-
let content = `/**
|
|
12
|
-
* This file is auto generated.
|
|
13
|
-
* Do not edit manually.
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
import type { ${source.name} } from '${sourceImportPath}';
|
|
17
|
-
|
|
18
|
-
`;
|
|
19
|
-
const actionTypeNames = [];
|
|
20
|
-
for (const method of source.methods) {
|
|
21
|
-
const capitalizedName = method.name.charAt(0).toUpperCase() + method.name.slice(1);
|
|
22
|
-
const actionTypeName = `${source.name}${capitalizedName}Action`;
|
|
23
|
-
const actionString = `${source.name}:${method.name}`;
|
|
24
|
-
actionTypeNames.push(actionTypeName);
|
|
25
|
-
if (method.jsDoc) {
|
|
26
|
-
content += `${method.jsDoc}\n`;
|
|
27
|
-
}
|
|
28
|
-
content += `export type ${actionTypeName} = {
|
|
29
|
-
type: \`${actionString}\`;
|
|
30
|
-
handler: ${source.name}['${method.name}'];
|
|
31
|
-
};\n\n`;
|
|
32
|
-
}
|
|
33
|
-
if (actionTypeNames.length > 0) {
|
|
34
|
-
const unionTypeName = `${source.name}MethodActions`;
|
|
35
|
-
content += `/**
|
|
36
|
-
* Union of all ${source.name} action types.
|
|
37
|
-
*/
|
|
38
|
-
export type ${unionTypeName} = ${actionTypeNames.join(' | ')};\n`;
|
|
39
|
-
}
|
|
40
|
-
return `${content.trimEnd()}\n`;
|
|
41
|
-
}
|
|
42
|
-
//# sourceMappingURL=generate-content.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generate-content.mjs","sourceRoot":"","sources":["../../src/generate-action-types/generate-content.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,I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AAC,OAAO,EAAE,IAAI,CAAC;AAClC,CAAC","sourcesContent":["import * as path from 'node:path';\n\nimport type { SourceInfo } from './parse-source';\n\n/**\n * Generates the content for the action types file.\n *\n * @param source - The source information object (controller or service).\n * @returns The content for the action types file.\n */\nexport function generateActionTypesContent(source: SourceInfo): string {\n const baseFileName = path.basename(source.filePath, '.ts');\n const sourceImportPath = `./${baseFileName}`;\n\n let content = `/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { ${source.name} } from '${sourceImportPath}';\n\n`;\n\n const actionTypeNames: string[] = [];\n\n for (const method of source.methods) {\n const capitalizedName =\n method.name.charAt(0).toUpperCase() + method.name.slice(1);\n const actionTypeName = `${source.name}${capitalizedName}Action`;\n const actionString = `${source.name}:${method.name}`;\n\n actionTypeNames.push(actionTypeName);\n\n if (method.jsDoc) {\n content += `${method.jsDoc}\\n`;\n }\n\n content += `export type ${actionTypeName} = {\n type: \\`${actionString}\\`;\n handler: ${source.name}['${method.name}'];\n};\\n\\n`;\n }\n\n if (actionTypeNames.length > 0) {\n const unionTypeName = `${source.name}MethodActions`;\n content += `/**\n * Union of all ${source.name} action types.\n */\nexport type ${unionTypeName} = ${actionTypeNames.join(' | ')};\\n`;\n }\n\n return `${content.trimEnd()}\\n`;\n}\n"]}
|