expo-type-information 0.0.0 → 0.0.1
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/README.md +31 -0
- package/bin/cli.js +2 -0
- package/build/cli.d.ts +1 -0
- package/build/cli.js +35 -0
- package/build/cli.js.map +1 -0
- package/build/commands/commandUtils.d.ts +46 -0
- package/build/commands/commandUtils.js +274 -0
- package/build/commands/commandUtils.js.map +1 -0
- package/build/commands/generateJSXIntrinsicsCommand.d.ts +2 -0
- package/build/commands/generateJSXIntrinsicsCommand.js +28 -0
- package/build/commands/generateJSXIntrinsicsCommand.js.map +1 -0
- package/build/commands/generateMocksForFileCommand.d.ts +2 -0
- package/build/commands/generateMocksForFileCommand.js +22 -0
- package/build/commands/generateMocksForFileCommand.js.map +1 -0
- package/build/commands/generateModuleTypesCommand.d.ts +2 -0
- package/build/commands/generateModuleTypesCommand.js +32 -0
- package/build/commands/generateModuleTypesCommand.js.map +1 -0
- package/build/commands/generateViewTypesCommand.d.ts +2 -0
- package/build/commands/generateViewTypesCommand.js +28 -0
- package/build/commands/generateViewTypesCommand.js.map +1 -0
- package/build/commands/inlineModulesInterfaceCommand.d.ts +2 -0
- package/build/commands/inlineModulesInterfaceCommand.js +129 -0
- package/build/commands/inlineModulesInterfaceCommand.js.map +1 -0
- package/build/commands/moduleInterfaceCommand.d.ts +2 -0
- package/build/commands/moduleInterfaceCommand.js +46 -0
- package/build/commands/moduleInterfaceCommand.js.map +1 -0
- package/build/commands/shortModuleInterfaceCommand.d.ts +2 -0
- package/build/commands/shortModuleInterfaceCommand.js +17 -0
- package/build/commands/shortModuleInterfaceCommand.js.map +1 -0
- package/build/commands/typeInformationCommand.d.ts +2 -0
- package/build/commands/typeInformationCommand.js +24 -0
- package/build/commands/typeInformationCommand.js.map +1 -0
- package/build/index.d.ts +3 -0
- package/build/index.js +28 -0
- package/build/index.js.map +1 -0
- package/build/mockgen.d.ts +4 -0
- package/build/mockgen.js +204 -0
- package/build/mockgen.js.map +1 -0
- package/build/swift/sourcekittenTypeInformation.d.ts +6 -0
- package/build/swift/sourcekittenTypeInformation.js +875 -0
- package/build/swift/sourcekittenTypeInformation.js.map +1 -0
- package/build/typeInformation.d.ts +209 -0
- package/build/typeInformation.js +157 -0
- package/build/typeInformation.js.map +1 -0
- package/build/types.d.ts +59 -0
- package/build/types.js +3 -0
- package/build/types.js.map +1 -0
- package/build/typescriptGeneration.d.ts +61 -0
- package/build/typescriptGeneration.js +696 -0
- package/build/typescriptGeneration.js.map +1 -0
- package/build/utils.d.ts +6 -0
- package/build/utils.js +44 -0
- package/build/utils.js.map +1 -0
- package/jest.config.js +6 -0
- package/package.json +46 -5
- package/src/cli.ts +38 -0
- package/src/commands/commandUtils.ts +352 -0
- package/src/commands/generateJSXIntrinsicsCommand.ts +38 -0
- package/src/commands/generateMocksForFileCommand.ts +30 -0
- package/src/commands/generateModuleTypesCommand.ts +39 -0
- package/src/commands/generateViewTypesCommand.ts +39 -0
- package/src/commands/inlineModulesInterfaceCommand.ts +175 -0
- package/src/commands/moduleInterfaceCommand.ts +56 -0
- package/src/commands/shortModuleInterfaceCommand.ts +26 -0
- package/src/commands/typeInformationCommand.ts +35 -0
- package/src/index.ts +9 -0
- package/src/mockgen.ts +338 -0
- package/src/swift/sourcekittenTypeInformation.ts +1173 -0
- package/src/typeInformation.ts +326 -0
- package/src/types.ts +68 -0
- package/src/typescriptGeneration.ts +1179 -0
- package/src/utils.ts +44 -0
- package/tests/TestModule.swift +175 -0
- package/tests/__snapshots__/typeInformation.test.ts.snap +1578 -0
- package/tests/typeInformation.test.ts +134 -0
- package/tsconfig.json +11 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2015-present 650 Industries, Inc. (aka Expo)
|
|
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/README.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# expo-type-information
|
|
2
|
+
|
|
3
|
+
> [!WARNING]
|
|
4
|
+
> This package only works on macOS.
|
|
5
|
+
|
|
6
|
+
This package provides a CLI tool and exports functions which can:
|
|
7
|
+
|
|
8
|
+
- Parse Swift expo modules and retrieve type information from them
|
|
9
|
+
- Emit typescript code (types, wrapper functions, mocks)
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
First, add the package to your npm dependencies:
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
npm install expo-type-information
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
To use this package, you need to have `sourcekitten` installed. You can install it using Homebrew:
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
brew install sourcekitten
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
With `sourcekitten` installed you can run the CLI tool and see the available commands:
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
npx expo-type-information
|
|
31
|
+
```
|
package/bin/cli.js
ADDED
package/build/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/build/cli.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const commander_1 = require("commander");
|
|
4
|
+
const commandUtils_1 = require("./commands/commandUtils");
|
|
5
|
+
const generateJSXIntrinsicsCommand_1 = require("./commands/generateJSXIntrinsicsCommand");
|
|
6
|
+
const generateMocksForFileCommand_1 = require("./commands/generateMocksForFileCommand");
|
|
7
|
+
const generateModuleTypesCommand_1 = require("./commands/generateModuleTypesCommand");
|
|
8
|
+
const generateViewTypesCommand_1 = require("./commands/generateViewTypesCommand");
|
|
9
|
+
const inlineModulesInterfaceCommand_1 = require("./commands/inlineModulesInterfaceCommand");
|
|
10
|
+
const moduleInterfaceCommand_1 = require("./commands/moduleInterfaceCommand");
|
|
11
|
+
const shortModuleInterfaceCommand_1 = require("./commands/shortModuleInterfaceCommand");
|
|
12
|
+
const typeInformationCommand_1 = require("./commands/typeInformationCommand");
|
|
13
|
+
async function main(args) {
|
|
14
|
+
if (!(0, commandUtils_1.isSourceKittenInstalled)()) {
|
|
15
|
+
console.error('Sourcekitten not found! Install it like so: brew install sourcekitten');
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const cli = new commander_1.Command();
|
|
19
|
+
cli
|
|
20
|
+
.name('expo-type-information')
|
|
21
|
+
.version(require('../package.json').version)
|
|
22
|
+
.description('Retrieve type information from Swift Expo modules to generate TypeScript.');
|
|
23
|
+
(0, moduleInterfaceCommand_1.moduleInterfaceCommand)(cli);
|
|
24
|
+
(0, inlineModulesInterfaceCommand_1.inlineModulesInterfaceCommand)(cli);
|
|
25
|
+
(0, shortModuleInterfaceCommand_1.shortModuleInterfaceCommand)(cli);
|
|
26
|
+
(0, generateMocksForFileCommand_1.generateMocksForFileCommand)(cli);
|
|
27
|
+
const otherCommands = cli.command('other').description('internal or very specific commands');
|
|
28
|
+
(0, typeInformationCommand_1.typeInformationCommand)(otherCommands);
|
|
29
|
+
(0, generateModuleTypesCommand_1.generateModuleTypesCommand)(otherCommands);
|
|
30
|
+
(0, generateViewTypesCommand_1.generateViewTypesCommand)(otherCommands);
|
|
31
|
+
(0, generateJSXIntrinsicsCommand_1.generateJsxIntrinsics)(otherCommands);
|
|
32
|
+
await cli.parseAsync(args, { from: 'user' });
|
|
33
|
+
}
|
|
34
|
+
main(process.argv.slice(2));
|
|
35
|
+
//# sourceMappingURL=cli.js.map
|
package/build/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;AAAA,yCAAoC;AAEpC,0DAAkE;AAClE,0FAAgF;AAChF,wFAAqF;AACrF,sFAAmF;AACnF,kFAA+E;AAC/E,4FAAyF;AACzF,8EAA2E;AAC3E,wFAAqF;AACrF,8EAA2E;AAE3E,KAAK,UAAU,IAAI,CAAC,IAAc;IAChC,IAAI,CAAC,IAAA,sCAAuB,GAAE,EAAE,CAAC;QAC/B,OAAO,CAAC,KAAK,CAAC,uEAAuE,CAAC,CAAC;QACvF,OAAO;IACT,CAAC;IACD,MAAM,GAAG,GAAG,IAAI,mBAAO,EAAE,CAAC;IAC1B,GAAG;SACA,IAAI,CAAC,uBAAuB,CAAC;SAC7B,OAAO,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC;SAC3C,WAAW,CAAC,2EAA2E,CAAC,CAAC;IAE5F,IAAA,+CAAsB,EAAC,GAAG,CAAC,CAAC;IAC5B,IAAA,6DAA6B,EAAC,GAAG,CAAC,CAAC;IACnC,IAAA,yDAA2B,EAAC,GAAG,CAAC,CAAC;IACjC,IAAA,yDAA2B,EAAC,GAAG,CAAC,CAAC;IAEjC,MAAM,aAAa,GAAG,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,oCAAoC,CAAC,CAAC;IAC7F,IAAA,+CAAsB,EAAC,aAAa,CAAC,CAAC;IACtC,IAAA,uDAA0B,EAAC,aAAa,CAAC,CAAC;IAC1C,IAAA,mDAAwB,EAAC,aAAa,CAAC,CAAC;IACxC,IAAA,oDAAqB,EAAC,aAAa,CAAC,CAAC;IAErC,MAAM,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;AAC/C,CAAC;AAED,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import commander from 'commander';
|
|
2
|
+
import { FileTypeInformation, TypeInferenceOption } from '../typeInformation';
|
|
3
|
+
export type TypeInformationCommandCommonAllArguments = {
|
|
4
|
+
inputPaths?: string[];
|
|
5
|
+
modulePath?: string;
|
|
6
|
+
outputPath?: string;
|
|
7
|
+
typeInference?: 'NO_INFERENCE' | 'SIMPLE_INFERENCE' | 'PREPROCESS_AND_INFERENCE';
|
|
8
|
+
watcher?: boolean;
|
|
9
|
+
appJson?: string;
|
|
10
|
+
};
|
|
11
|
+
export declare function isSourceKittenInstalled(): boolean;
|
|
12
|
+
export interface ParsedArguments {
|
|
13
|
+
realInputPaths: string[];
|
|
14
|
+
realOutputPath?: string;
|
|
15
|
+
typeInference: TypeInferenceOption;
|
|
16
|
+
watcher: boolean;
|
|
17
|
+
appJsonPath?: string;
|
|
18
|
+
}
|
|
19
|
+
export declare function addCommonOptions(command: commander.Command): commander.Command;
|
|
20
|
+
/**
|
|
21
|
+
* Debounce a function to only run once after a period of inactivity
|
|
22
|
+
* If called while waiting, it will reset the timer
|
|
23
|
+
*/
|
|
24
|
+
export declare function debounce<T extends (...args: any[]) => any>(fn: T, timeout?: number): (...args: Parameters<T>) => void;
|
|
25
|
+
export declare function runCommandOnWatch(parsedArgs: ParsedArguments, command: () => Promise<void>): Promise<void>;
|
|
26
|
+
export declare function getFilesForGlobPattern(globPattern: string): string[] | null;
|
|
27
|
+
export declare function sanitizeAndValidateOutputPath(rawPath: string, isFilePath?: boolean): string | null;
|
|
28
|
+
export declare function parseInferenceOption(option?: string): TypeInferenceOption | null;
|
|
29
|
+
export declare function getPodspecFilePath(modulePath: string): string | null;
|
|
30
|
+
export declare function getSourceFilesGlobFromPodspecFile(podspecPath: string): string | null;
|
|
31
|
+
export declare function getModuleFilePathsFromPodspec(modulePath: string): string[] | null;
|
|
32
|
+
export declare function uniqueStrings(strings: string[]): string[];
|
|
33
|
+
export declare function parseCommandArguments(options: TypeInformationCommandCommonAllArguments, isOutputFile?: boolean): ParsedArguments | null;
|
|
34
|
+
export declare function getFileTypeInformationFromArgs({ realInputPaths, typeInference, }: {
|
|
35
|
+
realInputPaths: string[];
|
|
36
|
+
typeInference: TypeInferenceOption;
|
|
37
|
+
}): Promise<FileTypeInformation | null>;
|
|
38
|
+
export declare function writeStringToFileOrPrintToConsole(text: string, realOutputPath: string | undefined): void;
|
|
39
|
+
export declare function getContentHash(content: string): string;
|
|
40
|
+
export declare function contentHasChanged(fileContent: string): boolean;
|
|
41
|
+
export declare function insertFileHashComment(fileContent: string): string;
|
|
42
|
+
export declare function writeToStableFile({ filePath, content, }: {
|
|
43
|
+
filePath: string;
|
|
44
|
+
content: string;
|
|
45
|
+
}): Promise<void>;
|
|
46
|
+
export declare function generateConciseTsFiles(parsedArgs: ParsedArguments): Promise<void>;
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.isSourceKittenInstalled = isSourceKittenInstalled;
|
|
7
|
+
exports.addCommonOptions = addCommonOptions;
|
|
8
|
+
exports.debounce = debounce;
|
|
9
|
+
exports.runCommandOnWatch = runCommandOnWatch;
|
|
10
|
+
exports.getFilesForGlobPattern = getFilesForGlobPattern;
|
|
11
|
+
exports.sanitizeAndValidateOutputPath = sanitizeAndValidateOutputPath;
|
|
12
|
+
exports.parseInferenceOption = parseInferenceOption;
|
|
13
|
+
exports.getPodspecFilePath = getPodspecFilePath;
|
|
14
|
+
exports.getSourceFilesGlobFromPodspecFile = getSourceFilesGlobFromPodspecFile;
|
|
15
|
+
exports.getModuleFilePathsFromPodspec = getModuleFilePathsFromPodspec;
|
|
16
|
+
exports.uniqueStrings = uniqueStrings;
|
|
17
|
+
exports.parseCommandArguments = parseCommandArguments;
|
|
18
|
+
exports.getFileTypeInformationFromArgs = getFileTypeInformationFromArgs;
|
|
19
|
+
exports.writeStringToFileOrPrintToConsole = writeStringToFileOrPrintToConsole;
|
|
20
|
+
exports.getContentHash = getContentHash;
|
|
21
|
+
exports.contentHasChanged = contentHasChanged;
|
|
22
|
+
exports.insertFileHashComment = insertFileHashComment;
|
|
23
|
+
exports.writeToStableFile = writeToStableFile;
|
|
24
|
+
exports.generateConciseTsFiles = generateConciseTsFiles;
|
|
25
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
26
|
+
const child_process_1 = require("child_process");
|
|
27
|
+
const crypto_1 = require("crypto");
|
|
28
|
+
const fs_1 = __importDefault(require("fs"));
|
|
29
|
+
const path_1 = __importDefault(require("path"));
|
|
30
|
+
const typeInformation_1 = require("../typeInformation");
|
|
31
|
+
const typescriptGeneration_1 = require("../typescriptGeneration");
|
|
32
|
+
const utils_1 = require("../utils");
|
|
33
|
+
let sourcekittenInstalled;
|
|
34
|
+
function isSourceKittenInstalled() {
|
|
35
|
+
if (sourcekittenInstalled !== undefined) {
|
|
36
|
+
return sourcekittenInstalled;
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
(0, child_process_1.execSync)('which sourcekitten', { stdio: 'ignore' });
|
|
40
|
+
sourcekittenInstalled = true;
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
sourcekittenInstalled = false;
|
|
44
|
+
}
|
|
45
|
+
return sourcekittenInstalled;
|
|
46
|
+
}
|
|
47
|
+
function addCommonOptions(command) {
|
|
48
|
+
return command
|
|
49
|
+
.option('-i, --input-paths <filePaths...>', 'Paths to Swift files for some module, glob patterns are allowed.')
|
|
50
|
+
.option('-m --module-path <modulePath>', 'Path to expo module root directory.')
|
|
51
|
+
.option('-o, --output-path <filePath>', 'Path to save the generated output. If this option is not provided the generated output is printed to console.')
|
|
52
|
+
.option('-t, --type-inference <typeInference>',
|
|
53
|
+
// TODO(@HubertBer) Fix the PREPROCESS_AND_INFERENCE option.
|
|
54
|
+
'Level of type inference: NO_INFERENCE, SIMPLE_INFERENCE, or PREPROCESS_AND_INFERENCE. Note that the last option rarely fails for some modules, use the 2nd or 1st in that case.', 'SIMPLE_INFERENCE')
|
|
55
|
+
.option('-w --watcher', 'Starts a watcher that checks for changes in input-path file.');
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Debounce a function to only run once after a period of inactivity
|
|
59
|
+
* If called while waiting, it will reset the timer
|
|
60
|
+
*/
|
|
61
|
+
function debounce(fn, timeout = 500) {
|
|
62
|
+
let timer;
|
|
63
|
+
return (...args) => {
|
|
64
|
+
clearTimeout(timer);
|
|
65
|
+
timer = setTimeout(() => {
|
|
66
|
+
fn(...args);
|
|
67
|
+
}, timeout);
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
async function runCommandOnWatch(parsedArgs, command) {
|
|
71
|
+
const debounced_command = debounce(command, 1000);
|
|
72
|
+
debounced_command();
|
|
73
|
+
if (!parsedArgs.watcher) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
await (0, utils_1.taskAll)(parsedArgs.realInputPaths, async (realInputPath) => {
|
|
77
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
78
|
+
for await (const _ of fs_1.default.promises.watch(realInputPath)) {
|
|
79
|
+
if (!fs_1.default.existsSync(realInputPath)) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
debounced_command();
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
function getFilesForGlobPattern(globPattern) {
|
|
87
|
+
try {
|
|
88
|
+
const normalizedPattern = globPattern.replace(/\\/g, '/');
|
|
89
|
+
const matches = fs_1.default.globSync(normalizedPattern, {
|
|
90
|
+
withFileTypes: true,
|
|
91
|
+
});
|
|
92
|
+
const resolvedPaths = matches
|
|
93
|
+
.filter((entry) => entry.isFile())
|
|
94
|
+
.map((entry) => path_1.default.resolve(entry.parentPath, entry.name));
|
|
95
|
+
return resolvedPaths.length > 0 ? resolvedPaths : null;
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
function sanitizeAndValidateOutputPath(rawPath, isFilePath = true) {
|
|
102
|
+
try {
|
|
103
|
+
const resolvedPath = path_1.default.resolve(rawPath);
|
|
104
|
+
if (fs_1.default.existsSync(resolvedPath)) {
|
|
105
|
+
const pathStat = fs_1.default.statSync(resolvedPath);
|
|
106
|
+
const isValid = isFilePath ? pathStat.isFile() : pathStat.isDirectory();
|
|
107
|
+
return isValid ? resolvedPath : null;
|
|
108
|
+
}
|
|
109
|
+
if (isFilePath && fs_1.default.existsSync(path_1.default.dirname(resolvedPath))) {
|
|
110
|
+
return resolvedPath;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
catch { }
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
function parseInferenceOption(option) {
|
|
117
|
+
if (!option)
|
|
118
|
+
return typeInformation_1.TypeInferenceOption.PREPROCESS_AND_INFERENCE;
|
|
119
|
+
switch (option) {
|
|
120
|
+
case 'NO_INFERENCE':
|
|
121
|
+
return typeInformation_1.TypeInferenceOption.NO_INFERENCE;
|
|
122
|
+
case 'SIMPLE_INFERENCE':
|
|
123
|
+
return typeInformation_1.TypeInferenceOption.SIMPLE_INFERENCE;
|
|
124
|
+
case 'PREPROCESS_AND_INFERENCE':
|
|
125
|
+
return typeInformation_1.TypeInferenceOption.PREPROCESS_AND_INFERENCE;
|
|
126
|
+
}
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
function getPodspecFilePath(modulePath) {
|
|
130
|
+
const normalizedModulePath = fs_1.default.realpathSync(modulePath).replace(/\\/g, '/');
|
|
131
|
+
const podspecFiles = [...fs_1.default.globSync(`${normalizedModulePath}/ios/*.podspec`)];
|
|
132
|
+
const podspecFile = podspecFiles[0];
|
|
133
|
+
return podspecFile ?? null;
|
|
134
|
+
}
|
|
135
|
+
function getSourceFilesGlobFromPodspecFile(podspecPath) {
|
|
136
|
+
const podspecContent = fs_1.default.readFileSync(podspecPath, 'utf8');
|
|
137
|
+
const sourceFilesRegex = /\.source_files\s*=\s*(["'])(.*?)\1/;
|
|
138
|
+
const match = podspecContent.match(sourceFilesRegex);
|
|
139
|
+
return match?.[2] ?? null;
|
|
140
|
+
}
|
|
141
|
+
function getModuleFilePathsFromPodspec(modulePath) {
|
|
142
|
+
const podspecPath = getPodspecFilePath(modulePath);
|
|
143
|
+
if (!podspecPath) {
|
|
144
|
+
console.warn(`No .podspec found in ${modulePath}`);
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
const extractedGlob = getSourceFilesGlobFromPodspecFile(podspecPath);
|
|
148
|
+
if (!extractedGlob) {
|
|
149
|
+
console.warn(`Could not extract source_files glob from ${podspecPath}`);
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
const podspecDir = path_1.default.dirname(podspecPath);
|
|
153
|
+
const absoluteGlobPattern = path_1.default.posix.join(podspecDir.replace(/\\/g, '/'), extractedGlob);
|
|
154
|
+
return getFilesForGlobPattern(absoluteGlobPattern)?.filter((f) => f.endsWith('.swift')) ?? null;
|
|
155
|
+
}
|
|
156
|
+
function uniqueStrings(strings) {
|
|
157
|
+
return [...new Set(strings)];
|
|
158
|
+
}
|
|
159
|
+
function parseCommandArguments(options, isOutputFile = true) {
|
|
160
|
+
const appJsonPath = options.appJson ?? undefined;
|
|
161
|
+
let realInputPaths = (options.inputPaths ?? [])
|
|
162
|
+
.flatMap(getFilesForGlobPattern)
|
|
163
|
+
.filter((p) => p != null);
|
|
164
|
+
if (options.modulePath) {
|
|
165
|
+
const modulePaths = getModuleFilePathsFromPodspec(options.modulePath) ?? [];
|
|
166
|
+
realInputPaths.push(...modulePaths);
|
|
167
|
+
}
|
|
168
|
+
realInputPaths = uniqueStrings(realInputPaths);
|
|
169
|
+
if ((!realInputPaths || realInputPaths.length === 0) && !appJsonPath) {
|
|
170
|
+
console.error(`Provide valid globs to existing files or a path to a module with valid podspec.`);
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
let realOutputPath = undefined;
|
|
174
|
+
if (options.outputPath) {
|
|
175
|
+
const validatedOutPath = sanitizeAndValidateOutputPath(options.outputPath, isOutputFile);
|
|
176
|
+
if (!validatedOutPath) {
|
|
177
|
+
console.error(`Output path ${options.outputPath} is not valid. ${isOutputFile ? 'Provide a path to an existing file, or to a file in an existing parent directory.' : 'Provide a path to an existing directory.'}`);
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
realOutputPath = validatedOutPath;
|
|
181
|
+
}
|
|
182
|
+
else if (options.modulePath) {
|
|
183
|
+
// if path to module directory is provided, we can generate ts types under src directory
|
|
184
|
+
realOutputPath =
|
|
185
|
+
sanitizeAndValidateOutputPath(path_1.default.join(options.modulePath, 'src'), false) ?? undefined;
|
|
186
|
+
}
|
|
187
|
+
const typeInference = parseInferenceOption(options.typeInference);
|
|
188
|
+
if (typeInference === null) {
|
|
189
|
+
console.error(`Invalid typeInference option. ${options.typeInference}`);
|
|
190
|
+
return null;
|
|
191
|
+
}
|
|
192
|
+
const watcher = options.watcher ?? false;
|
|
193
|
+
return { realInputPaths, realOutputPath, typeInference, watcher, appJsonPath };
|
|
194
|
+
}
|
|
195
|
+
async function getFileTypeInformationFromArgs({ realInputPaths, typeInference, }) {
|
|
196
|
+
const typeInfo = await (0, typeInformation_1.getFileTypeInformation)({
|
|
197
|
+
input: { type: 'file', inputFileAbsolutePaths: realInputPaths },
|
|
198
|
+
typeInference,
|
|
199
|
+
});
|
|
200
|
+
if (!typeInfo) {
|
|
201
|
+
console.error(chalk_1.default.red(`Provided files: ${realInputPaths} couldn't be parsed for type information!`));
|
|
202
|
+
return null;
|
|
203
|
+
}
|
|
204
|
+
return typeInfo;
|
|
205
|
+
}
|
|
206
|
+
function writeStringToFileOrPrintToConsole(text, realOutputPath) {
|
|
207
|
+
if (realOutputPath) {
|
|
208
|
+
fs_1.default.writeFileSync(realOutputPath, text, { flag: 'w', encoding: 'utf-8' });
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
console.log(text);
|
|
212
|
+
}
|
|
213
|
+
function getContentHash(content) {
|
|
214
|
+
return (0, crypto_1.createHash)('sha256').update(content).digest('hex');
|
|
215
|
+
}
|
|
216
|
+
function contentHasChanged(fileContent) {
|
|
217
|
+
const hashRegex = /^\/\/ File hash: ([a-f0-9]{64})\r?\n/;
|
|
218
|
+
const match = fileContent.match(hashRegex);
|
|
219
|
+
if (!match) {
|
|
220
|
+
return true;
|
|
221
|
+
}
|
|
222
|
+
const storedHash = match[1];
|
|
223
|
+
const originalContent = fileContent.slice(match[0].length);
|
|
224
|
+
const calculatedHash = getContentHash(originalContent);
|
|
225
|
+
return storedHash !== calculatedHash;
|
|
226
|
+
}
|
|
227
|
+
function insertFileHashComment(fileContent) {
|
|
228
|
+
const hashString = getContentHash(fileContent);
|
|
229
|
+
return `// File hash: ${hashString}
|
|
230
|
+
${fileContent}`;
|
|
231
|
+
}
|
|
232
|
+
async function writeToStableFile({ filePath, content, }) {
|
|
233
|
+
let flag = 'wx';
|
|
234
|
+
if (fs_1.default.existsSync(filePath) &&
|
|
235
|
+
!contentHasChanged(await fs_1.default.promises.readFile(filePath, 'utf-8'))) {
|
|
236
|
+
// Overwrite the file if it wasn't changed since the last generation
|
|
237
|
+
flag = 'w';
|
|
238
|
+
}
|
|
239
|
+
try {
|
|
240
|
+
await fs_1.default.promises.writeFile(filePath, insertFileHashComment(content), {
|
|
241
|
+
flag,
|
|
242
|
+
encoding: 'utf-8',
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
catch (e) {
|
|
246
|
+
console.error('Error writing to a file.', e);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
async function generateConciseTsFiles(parsedArgs) {
|
|
250
|
+
const { realInputPaths, realOutputPath } = parsedArgs;
|
|
251
|
+
const typeInfo = await getFileTypeInformationFromArgs(parsedArgs);
|
|
252
|
+
if (!typeInfo) {
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
const { volatileGeneratedFileContent, moduleTypescriptInterfaceFileContent } = await (0, typescriptGeneration_1.generateConciseTsInterface)(typeInfo);
|
|
256
|
+
const moduleName = typeInfo.moduleClasses[0]?.name ?? 'UnknownModuleName';
|
|
257
|
+
const dirName = realOutputPath ?? path_1.default.dirname(realInputPaths[0]);
|
|
258
|
+
try {
|
|
259
|
+
await Promise.all([
|
|
260
|
+
fs_1.default.promises.writeFile(path_1.default.resolve(dirName, `${moduleName}.generated.ts`), volatileGeneratedFileContent, {
|
|
261
|
+
flag: 'w',
|
|
262
|
+
encoding: 'utf-8',
|
|
263
|
+
}),
|
|
264
|
+
writeToStableFile({
|
|
265
|
+
filePath: path_1.default.resolve(dirName, `${moduleName}.tsx`),
|
|
266
|
+
content: moduleTypescriptInterfaceFileContent,
|
|
267
|
+
}),
|
|
268
|
+
]);
|
|
269
|
+
}
|
|
270
|
+
catch (e) {
|
|
271
|
+
console.error(`Error writing to a file.`, e);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
//# sourceMappingURL=commandUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commandUtils.js","sourceRoot":"","sources":["../../src/commands/commandUtils.ts"],"names":[],"mappings":";;;;;AAyBA,0DAWC;AAUD,4CAkBC;AAMD,4BAWC;AAED,8CAgBC;AAED,wDAgBC;AAED,sEAmBC;AAED,oDAWC;AAED,gDAMC;AAED,8EAKC;AAED,sEAiBC;AAED,sCAEC;AAED,sDA8CC;AAED,wEAmBC;AAED,8EASC;AAED,wCAEC;AAED,8CAYC;AAED,sDAIC;AAED,8CAuBC;AAED,wDA+BC;AA/VD,kDAA0B;AAC1B,iDAAyC;AAEzC,mCAAoC;AACpC,4CAAoB;AACpB,gDAAwB;AAExB,wDAI4B;AAC5B,kEAAqE;AACrE,oCAAmC;AAWnC,IAAI,qBAA8B,CAAC;AACnC,SAAgB,uBAAuB;IACrC,IAAI,qBAAqB,KAAK,SAAS,EAAE,CAAC;QACxC,OAAO,qBAAqB,CAAC;IAC/B,CAAC;IACD,IAAI,CAAC;QACH,IAAA,wBAAQ,EAAC,oBAAoB,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;QACpD,qBAAqB,GAAG,IAAI,CAAC;IAC/B,CAAC;IAAC,MAAM,CAAC;QACP,qBAAqB,GAAG,KAAK,CAAC;IAChC,CAAC;IACD,OAAO,qBAAqB,CAAC;AAC/B,CAAC;AAUD,SAAgB,gBAAgB,CAAC,OAA0B;IACzD,OAAO,OAAO;SACX,MAAM,CACL,kCAAkC,EAClC,kEAAkE,CACnE;SACA,MAAM,CAAC,+BAA+B,EAAE,qCAAqC,CAAC;SAC9E,MAAM,CACL,8BAA8B,EAC9B,+GAA+G,CAChH;SACA,MAAM,CACL,sCAAsC;IACtC,4DAA4D;IAC5D,iLAAiL,EACjL,kBAAkB,CACnB;SACA,MAAM,CAAC,cAAc,EAAE,8DA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D,4BAA4B,EAC5B;gBACE,IAAI,EAAE,GAAG;gBACT,QAAQ,EAAE,OAAO;aAClB,CACF;YACD,iBAAiB,CAAC;gBAChB,QAAQ,EAAE,cAAI,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,UAAU,MAAM,CAAC;gBACpD,OAAO,EAAE,oCAAoC;aAC9C,CAAC;SACH,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CAAC,0BAA0B,EAAE,CAAC,CAAC,CAAC;IAC/C,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateJsxIntrinsics = generateJsxIntrinsics;
|
|
4
|
+
const commandUtils_1 = require("./commandUtils");
|
|
5
|
+
const typescriptGeneration_1 = require("../typescriptGeneration");
|
|
6
|
+
function generateJsxIntrinsics(cli) {
|
|
7
|
+
return (0, commandUtils_1.addCommonOptions)(cli.command('generate-jsx-intrinsics')).action(async (options) => {
|
|
8
|
+
const parsedArgs = await (0, commandUtils_1.parseCommandArguments)(options);
|
|
9
|
+
if (!parsedArgs) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const { realOutputPath } = parsedArgs;
|
|
13
|
+
const command = async () => {
|
|
14
|
+
const typeInfo = await (0, commandUtils_1.getFileTypeInformationFromArgs)(parsedArgs);
|
|
15
|
+
if (!typeInfo) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const jsxIntrinsicViewFileContent = await (0, typescriptGeneration_1.generateJSXIntrinsicsFileContent)(typeInfo);
|
|
19
|
+
if (!jsxIntrinsicViewFileContent) {
|
|
20
|
+
console.error("Couldn't generate view types!");
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
(0, commandUtils_1.writeStringToFileOrPrintToConsole)(jsxIntrinsicViewFileContent, realOutputPath);
|
|
24
|
+
};
|
|
25
|
+
(0, commandUtils_1.runCommandOnWatch)(parsedArgs, command);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=generateJSXIntrinsicsCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateJSXIntrinsicsCommand.js","sourceRoot":"","sources":["../../src/commands/generateJSXIntrinsicsCommand.ts"],"names":[],"mappings":";;AAYA,sDAyBC;AAnCD,iDAOwB;AACxB,kEAA2E;AAE3E,SAAgB,qBAAqB,CAAC,GAAsB;IAC1D,OAAO,IAAA,+BAAgB,EAAC,GAAG,CAAC,OAAO,CAAC,yBAAyB,CAAC,CAAC,CAAC,MAAM,CACpE,KAAK,EAAE,OAAiD,EAAE,EAAE;QAC1D,MAAM,UAAU,GAAG,MAAM,IAAA,oCAAqB,EAAC,OAAO,CAAC,CAAC;QACxD,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,OAAO;QACT,CAAC;QACD,MAAM,EAAE,cAAc,EAAE,GAAG,UAAU,CAAC;QAEtC,MAAM,OAAO,GAAG,KAAK,IAAI,EAAE;YACzB,MAAM,QAAQ,GAAG,MAAM,IAAA,6CAA8B,EAAC,UAAU,CAAC,CAAC;YAClE,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACd,OAAO;YACT,CAAC;YAED,MAAM,2BAA2B,GAAG,MAAM,IAAA,uDAAgC,EAAC,QAAQ,CAAC,CAAC;YACrF,IAAI,CAAC,2BAA2B,EAAE,CAAC;gBACjC,OAAO,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;gBAC/C,OAAO;YACT,CAAC;YACD,IAAA,gDAAiC,EAAC,2BAA2B,EAAE,cAAc,CAAC,CAAC;QACjF,CAAC,CAAC;QACF,IAAA,gCAAiB,EAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IACzC,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateMocksForFileCommand = generateMocksForFileCommand;
|
|
4
|
+
const commandUtils_1 = require("./commandUtils");
|
|
5
|
+
const mockgen_1 = require("../mockgen");
|
|
6
|
+
function generateMocksForFileCommand(cli) {
|
|
7
|
+
return (0, commandUtils_1.addCommonOptions)(cli.command('generate-mocks-for-file')).action(async (options) => {
|
|
8
|
+
const parsedArgs = await (0, commandUtils_1.parseCommandArguments)(options);
|
|
9
|
+
if (!parsedArgs) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const command = async () => {
|
|
13
|
+
const typeInfo = await (0, commandUtils_1.getFileTypeInformationFromArgs)(parsedArgs);
|
|
14
|
+
if (!typeInfo) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
(0, mockgen_1.generateMocks)([typeInfo], 'typescript');
|
|
18
|
+
};
|
|
19
|
+
(0, commandUtils_1.runCommandOnWatch)(parsedArgs, command);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=generateMocksForFileCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateMocksForFileCommand.js","sourceRoot":"","sources":["../../src/commands/generateMocksForFileCommand.ts"],"names":[],"mappings":";;AAWA,kEAkBC;AA3BD,iDAMwB;AACxB,wCAA2C;AAE3C,SAAgB,2BAA2B,CAAC,GAAsB;IAChE,OAAO,IAAA,+BAAgB,EAAC,GAAG,CAAC,OAAO,CAAC,yBAAyB,CAAC,CAAC,CAAC,MAAM,CACpE,KAAK,EAAE,OAAiD,EAAE,EAAE;QAC1D,MAAM,UAAU,GAAG,MAAM,IAAA,oCAAqB,EAAC,OAAO,CAAC,CAAC;QACxD,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,OAAO;QACT,CAAC;QAED,MAAM,OAAO,GAAG,KAAK,IAAI,EAAE;YACzB,MAAM,QAAQ,GAAG,MAAM,IAAA,6CAA8B,EAAC,UAAU,CAAC,CAAC;YAClE,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACd,OAAO;YACT,CAAC;YACD,IAAA,uBAAa,EAAC,CAAC,QAAQ,CAAC,EAAE,YAAY,CAAC,CAAC;QAC1C,CAAC,CAAC;QACF,IAAA,gCAAiB,EAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IACzC,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.generateModuleTypesCommand = generateModuleTypesCommand;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const commandUtils_1 = require("./commandUtils");
|
|
9
|
+
const typescriptGeneration_1 = require("../typescriptGeneration");
|
|
10
|
+
function generateModuleTypesCommand(cli) {
|
|
11
|
+
return (0, commandUtils_1.addCommonOptions)(cli.command('generate-module-types')).action(async (options) => {
|
|
12
|
+
const parsedArgs = await (0, commandUtils_1.parseCommandArguments)(options);
|
|
13
|
+
if (!parsedArgs) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const { realOutputPath } = parsedArgs;
|
|
17
|
+
const command = async () => {
|
|
18
|
+
const typeInfo = await (0, commandUtils_1.getFileTypeInformationFromArgs)(parsedArgs);
|
|
19
|
+
if (!typeInfo) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const moduleTypesFileContent = await (0, typescriptGeneration_1.generateModuleTypesFileContent)(typeInfo);
|
|
23
|
+
if (!moduleTypesFileContent) {
|
|
24
|
+
console.error(chalk_1.default.red(`Couldn't generate module types file content!`));
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
(0, commandUtils_1.writeStringToFileOrPrintToConsole)(moduleTypesFileContent, realOutputPath);
|
|
28
|
+
};
|
|
29
|
+
(0, commandUtils_1.runCommandOnWatch)(parsedArgs, command);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=generateModuleTypesCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateModuleTypesCommand.js","sourceRoot":"","sources":["../../src/commands/generateModuleTypesCommand.ts"],"names":[],"mappings":";;;;;AAaA,gEAyBC;AAtCD,kDAA0B;AAG1B,iDAOwB;AACxB,kEAAyE;AAEzE,SAAgB,0BAA0B,CAAC,GAAsB;IAC/D,OAAO,IAAA,+BAAgB,EAAC,GAAG,CAAC,OAAO,CAAC,uBAAuB,CAAC,CAAC,CAAC,MAAM,CAClE,KAAK,EAAE,OAAiD,EAAE,EAAE;QAC1D,MAAM,UAAU,GAAG,MAAM,IAAA,oCAAqB,EAAC,OAAO,CAAC,CAAC;QACxD,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,OAAO;QACT,CAAC;QACD,MAAM,EAAE,cAAc,EAAE,GAAG,UAAU,CAAC;QAEtC,MAAM,OAAO,GAAG,KAAK,IAAI,EAAE;YACzB,MAAM,QAAQ,GAAG,MAAM,IAAA,6CAA8B,EAAC,UAAU,CAAC,CAAC;YAClE,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACd,OAAO;YACT,CAAC;YAED,MAAM,sBAAsB,GAAG,MAAM,IAAA,qDAA8B,EAAC,QAAQ,CAAC,CAAC;YAC9E,IAAI,CAAC,sBAAsB,EAAE,CAAC;gBAC5B,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,8CAA8C,CAAC,CAAC,CAAC;gBACzE,OAAO;YACT,CAAC;YACD,IAAA,gDAAiC,EAAC,sBAAsB,EAAE,cAAc,CAAC,CAAC;QAC5E,CAAC,CAAC;QACF,IAAA,gCAAiB,EAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IACzC,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateViewTypesCommand = generateViewTypesCommand;
|
|
4
|
+
const commandUtils_1 = require("./commandUtils");
|
|
5
|
+
const typescriptGeneration_1 = require("../typescriptGeneration");
|
|
6
|
+
function generateViewTypesCommand(cli) {
|
|
7
|
+
return (0, commandUtils_1.addCommonOptions)(cli.command('generate-view-types')).action(async (options) => {
|
|
8
|
+
const parsedArgs = await (0, commandUtils_1.parseCommandArguments)(options);
|
|
9
|
+
if (!parsedArgs) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const { realOutputPath } = parsedArgs;
|
|
13
|
+
const command = async () => {
|
|
14
|
+
const typeInfo = await (0, commandUtils_1.getFileTypeInformationFromArgs)(parsedArgs);
|
|
15
|
+
if (!typeInfo) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const viewTypesFileContent = await (0, typescriptGeneration_1.generateViewTypesFileContent)(typeInfo);
|
|
19
|
+
if (!viewTypesFileContent) {
|
|
20
|
+
console.error("Couldn't generate view types!");
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
(0, commandUtils_1.writeStringToFileOrPrintToConsole)(viewTypesFileContent, realOutputPath);
|
|
24
|
+
};
|
|
25
|
+
(0, commandUtils_1.runCommandOnWatch)(parsedArgs, command);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=generateViewTypesCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateViewTypesCommand.js","sourceRoot":"","sources":["../../src/commands/generateViewTypesCommand.ts"],"names":[],"mappings":";;AAYA,4DA0BC;AApCD,iDAOwB;AACxB,kEAAuE;AAEvE,SAAgB,wBAAwB,CAAC,GAAsB;IAC7D,OAAO,IAAA,+BAAgB,EAAC,GAAG,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC,CAAC,MAAM,CAChE,KAAK,EAAE,OAAiD,EAAE,EAAE;QAC1D,MAAM,UAAU,GAAG,MAAM,IAAA,oCAAqB,EAAC,OAAO,CAAC,CAAC;QACxD,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,OAAO;QACT,CAAC;QACD,MAAM,EAAE,cAAc,EAAE,GAAG,UAAU,CAAC;QAEtC,MAAM,OAAO,GAAG,KAAK,IAAI,EAAE;YACzB,MAAM,QAAQ,GAAG,MAAM,IAAA,6CAA8B,EAAC,UAAU,CAAC,CAAC;YAClE,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACd,OAAO;YACT,CAAC;YAED,MAAM,oBAAoB,GAAG,MAAM,IAAA,mDAA4B,EAAC,QAAQ,CAAC,CAAC;YAC1E,IAAI,CAAC,oBAAoB,EAAE,CAAC;gBAC1B,OAAO,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;gBAC/C,OAAO;YACT,CAAC;YACD,IAAA,gDAAiC,EAAC,oBAAoB,EAAE,cAAc,CAAC,CAAC;QAC1E,CAAC,CAAC;QAEF,IAAA,gCAAiB,EAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IACzC,CAAC,CACF,CAAC;AACJ,CAAC"}
|