@callstack/brownfield-cli 3.12.0 → 3.13.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/CHANGELOG.md +12 -0
- package/dist/brownfield/commands/packageAndroid.d.ts.map +1 -1
- package/dist/brownfield/commands/packageAndroid.js +3 -3
- package/dist/brownfield/commands/packageIos.d.ts.map +1 -1
- package/dist/brownfield/commands/packageIos.js +4 -2
- package/dist/brownfield/commands/publishAndroid.d.ts.map +1 -1
- package/dist/brownfield/commands/publishAndroid.js +3 -1
- package/dist/brownie/commands/codegen.d.ts +4 -2
- package/dist/brownie/commands/codegen.d.ts.map +1 -1
- package/dist/brownie/commands/codegen.js +15 -7
- package/dist/brownie/config.d.ts +19 -5
- package/dist/brownie/config.d.ts.map +1 -1
- package/dist/brownie/config.js +45 -9
- package/dist/brownie/helpers/runBrownieCodegenIfApplicable.d.ts +1 -1
- package/dist/brownie/helpers/runBrownieCodegenIfApplicable.d.ts.map +1 -1
- package/dist/brownie/helpers/runBrownieCodegenIfApplicable.js +1 -1
- package/dist/brownie/index.d.ts +0 -1
- package/dist/brownie/index.d.ts.map +1 -1
- package/dist/config.d.ts +7 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +72 -0
- package/dist/navigation/commands/codegen.d.ts.map +1 -1
- package/dist/navigation/generators/ts.d.ts.map +1 -1
- package/dist/navigation/generators/ts.js +53 -4
- package/dist/navigation/runner.d.ts.map +1 -1
- package/dist/navigation/runner.js +16 -12
- package/dist/shared/utils/cli.d.ts +1 -1
- package/dist/shared/utils/cli.d.ts.map +1 -1
- package/dist/types.d.ts +30 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +11 -2
- package/schema.json +110 -0
- package/src/brownfield/commands/packageAndroid.ts +5 -6
- package/src/brownfield/commands/packageIos.ts +18 -18
- package/src/brownfield/commands/publishAndroid.ts +4 -1
- package/src/brownie/commands/codegen.ts +35 -10
- package/src/brownie/config.ts +72 -15
- package/src/brownie/helpers/runBrownieCodegenIfApplicable.ts +2 -2
- package/src/brownie/index.ts +0 -1
- package/src/config.ts +119 -0
- package/src/navigation/commands/codegen.ts +1 -3
- package/src/navigation/generators/ts.ts +61 -3
- package/src/navigation/runner.ts +17 -12
- package/src/shared/utils/cli.ts +4 -2
- package/src/types.ts +51 -0
- package/dist/brownie/types.d.ts +0 -2
- package/dist/brownie/types.d.ts.map +0 -1
- package/src/brownie/types.ts +0 -1
- /package/dist/{brownie/types.js → types.js} +0 -0
|
@@ -56,14 +56,72 @@ export default TurboModuleRegistry.getEnforcing<Spec>(
|
|
|
56
56
|
`;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
const SKIP_TYPE_TOKENS = new Set([
|
|
60
|
+
'Array',
|
|
61
|
+
'Date',
|
|
62
|
+
'Map',
|
|
63
|
+
'Object',
|
|
64
|
+
'Promise',
|
|
65
|
+
'ReadonlyArray',
|
|
66
|
+
'Record',
|
|
67
|
+
'Set',
|
|
68
|
+
'any',
|
|
69
|
+
'boolean',
|
|
70
|
+
'false',
|
|
71
|
+
'null',
|
|
72
|
+
'number',
|
|
73
|
+
'object',
|
|
74
|
+
'string',
|
|
75
|
+
'true',
|
|
76
|
+
'undefined',
|
|
77
|
+
'unknown',
|
|
78
|
+
'void',
|
|
79
|
+
]);
|
|
80
|
+
|
|
81
|
+
function collectTypesUsedByMethods(methods: MethodSignature[]): Set<string> {
|
|
82
|
+
const used = new Set<string>();
|
|
83
|
+
|
|
84
|
+
for (const method of methods) {
|
|
85
|
+
const typeTexts = [
|
|
86
|
+
method.returnType,
|
|
87
|
+
...method.params.map((param) => param.type),
|
|
88
|
+
];
|
|
89
|
+
|
|
90
|
+
for (const typeText of typeTexts) {
|
|
91
|
+
const matches = typeText.match(/\b[A-Za-z_]\w*\b/g);
|
|
92
|
+
if (!matches) {
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
for (const name of matches) {
|
|
97
|
+
if (!SKIP_TYPE_TOKENS.has(name)) {
|
|
98
|
+
used.add(name);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return used;
|
|
105
|
+
}
|
|
106
|
+
|
|
59
107
|
function buildTypeImportLine(
|
|
108
|
+
methods: MethodSignature[],
|
|
60
109
|
referencedTypeDeclarations: TypeDeclaration[]
|
|
61
110
|
): string {
|
|
62
111
|
if (referencedTypeDeclarations.length === 0) {
|
|
63
112
|
return '';
|
|
64
113
|
}
|
|
65
114
|
|
|
66
|
-
const
|
|
115
|
+
const usedTypes = collectTypesUsedByMethods(methods);
|
|
116
|
+
const names = referencedTypeDeclarations
|
|
117
|
+
.map((entry) => entry.name)
|
|
118
|
+
.filter((name) => usedTypes.has(name))
|
|
119
|
+
.join(', ');
|
|
120
|
+
|
|
121
|
+
if (names.length === 0) {
|
|
122
|
+
return '';
|
|
123
|
+
}
|
|
124
|
+
|
|
67
125
|
return `import type { ${names} } from './NativeBrownfieldNavigation';\n`;
|
|
68
126
|
}
|
|
69
127
|
|
|
@@ -71,7 +129,7 @@ export function generateIndexTs(
|
|
|
71
129
|
methods: MethodSignature[],
|
|
72
130
|
referencedTypeDeclarations: TypeDeclaration[] = []
|
|
73
131
|
): string {
|
|
74
|
-
const typeImportLine = buildTypeImportLine(referencedTypeDeclarations);
|
|
132
|
+
const typeImportLine = buildTypeImportLine(methods, referencedTypeDeclarations);
|
|
75
133
|
const functionImplementations = methods
|
|
76
134
|
.map((method) => {
|
|
77
135
|
const params = method.params
|
|
@@ -155,7 +213,7 @@ export function generateIndexDts(
|
|
|
155
213
|
methods: MethodSignature[],
|
|
156
214
|
referencedTypeDeclarations: TypeDeclaration[] = []
|
|
157
215
|
): string {
|
|
158
|
-
const typeImportLine = buildTypeImportLine(referencedTypeDeclarations);
|
|
216
|
+
const typeImportLine = buildTypeImportLine(methods, referencedTypeDeclarations);
|
|
159
217
|
const methodSignatures = methods
|
|
160
218
|
.map((method) => {
|
|
161
219
|
const params = method.params
|
package/src/navigation/runner.ts
CHANGED
|
@@ -122,47 +122,52 @@ function getOutputPaths(
|
|
|
122
122
|
};
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
+
function writeFileEnsuringDir(filePath: string, content: string): void {
|
|
126
|
+
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
127
|
+
fs.writeFileSync(filePath, content);
|
|
128
|
+
}
|
|
129
|
+
|
|
125
130
|
function writeArtifacts(
|
|
126
131
|
paths: NavigationOutputPaths,
|
|
127
132
|
artifacts: GeneratedNavigationArtifacts
|
|
128
133
|
): void {
|
|
129
|
-
|
|
134
|
+
writeFileEnsuringDir(paths.turboModuleSpec, artifacts.turboModuleSpec);
|
|
130
135
|
logger.success(`Generated ${paths.turboModuleSpec}`);
|
|
131
136
|
|
|
132
|
-
|
|
137
|
+
writeFileEnsuringDir(paths.navigationTs, artifacts.indexTs);
|
|
133
138
|
logger.success(`Generated ${paths.navigationTs}`);
|
|
134
139
|
|
|
135
|
-
|
|
140
|
+
writeFileEnsuringDir(paths.commonjsIndexJs, artifacts.indexJs);
|
|
136
141
|
logger.success(`Generated ${paths.commonjsIndexJs}`);
|
|
137
142
|
|
|
138
|
-
|
|
143
|
+
writeFileEnsuringDir(paths.moduleIndexJs, artifacts.indexJs);
|
|
139
144
|
logger.success(`Generated ${paths.moduleIndexJs}`);
|
|
140
145
|
|
|
141
|
-
|
|
146
|
+
writeFileEnsuringDir(paths.commonjsIndexDts, artifacts.indexDts);
|
|
142
147
|
logger.success(`Generated ${paths.commonjsIndexDts}`);
|
|
143
148
|
|
|
144
|
-
|
|
149
|
+
writeFileEnsuringDir(paths.moduleIndexDts, artifacts.indexDts);
|
|
145
150
|
logger.success(`Generated ${paths.moduleIndexDts}`);
|
|
146
151
|
|
|
147
|
-
|
|
152
|
+
writeFileEnsuringDir(paths.swiftDelegate, artifacts.swiftDelegate);
|
|
148
153
|
logger.success(`Generated ${paths.swiftDelegate}`);
|
|
149
154
|
|
|
150
155
|
if (artifacts.swiftModels) {
|
|
151
|
-
|
|
156
|
+
writeFileEnsuringDir(paths.swiftModels, artifacts.swiftModels);
|
|
152
157
|
logger.success(`Generated ${paths.swiftModels}`);
|
|
153
158
|
}
|
|
154
159
|
|
|
155
|
-
|
|
160
|
+
writeFileEnsuringDir(paths.objcImplementation, artifacts.objcImplementation);
|
|
156
161
|
logger.success(`Generated ${paths.objcImplementation}`);
|
|
157
162
|
|
|
158
|
-
|
|
163
|
+
writeFileEnsuringDir(paths.kotlinDelegate, artifacts.kotlinDelegate);
|
|
159
164
|
logger.success(`Generated ${paths.kotlinDelegate}`);
|
|
160
165
|
|
|
161
|
-
|
|
166
|
+
writeFileEnsuringDir(paths.kotlinModule, artifacts.kotlinModule);
|
|
162
167
|
logger.success(`Generated ${paths.kotlinModule}`);
|
|
163
168
|
|
|
164
169
|
if (artifacts.kotlinModels) {
|
|
165
|
-
|
|
170
|
+
writeFileEnsuringDir(paths.kotlinModels, artifacts.kotlinModels);
|
|
166
171
|
logger.success(`Generated ${paths.kotlinModels}`);
|
|
167
172
|
}
|
|
168
173
|
}
|
package/src/shared/utils/cli.ts
CHANGED
|
@@ -23,8 +23,10 @@ export function curryOptions(programCommand: Command, options: RockCLIOptions) {
|
|
|
23
23
|
return programCommand;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
export function actionRunner<
|
|
27
|
-
|
|
26
|
+
export function actionRunner<Args extends unknown[], R>(
|
|
27
|
+
fn: (...args: Args) => Promise<R>
|
|
28
|
+
) {
|
|
29
|
+
return async function wrappedCLIAction(...args: Args) {
|
|
28
30
|
try {
|
|
29
31
|
await fn(...args);
|
|
30
32
|
} catch (error) {
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
PublishLocalAarFlags,
|
|
3
|
+
PackageAarFlags,
|
|
4
|
+
} from '@rock-js/platform-android';
|
|
5
|
+
import type { BuildFlags as AppleBuildFlags } from '@rock-js/platform-apple-helpers';
|
|
6
|
+
|
|
7
|
+
export type Platform = 'swift' | 'kotlin';
|
|
8
|
+
|
|
9
|
+
export type BrownfieldCommonOptions = Partial<{
|
|
10
|
+
verbose: boolean;
|
|
11
|
+
}>;
|
|
12
|
+
|
|
13
|
+
export type BrownfieldConfigMetadata = Partial<{
|
|
14
|
+
$schema: string;
|
|
15
|
+
}>;
|
|
16
|
+
|
|
17
|
+
export type BrownieConfig = {
|
|
18
|
+
kotlin?: string;
|
|
19
|
+
kotlinPackageName?: string;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type PackageIosOptions = AppleBuildFlags & {
|
|
23
|
+
/** Set when `--use-prebuilt-rn-core` is passed; omitted when the flag is absent (Rock applies RN version defaults). */
|
|
24
|
+
usePrebuiltRnCore?: boolean;
|
|
25
|
+
/** When set, generate a local Swift Package Manager manifest next to the packaged XCFramework outputs. */
|
|
26
|
+
addSpmPackage?: boolean;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export type BrownfieldPackageAndroidOptions = BrownfieldCommonOptions &
|
|
30
|
+
Partial<PackageAarFlags>;
|
|
31
|
+
export type BrownfieldPublishAndroidOptions = BrownfieldCommonOptions &
|
|
32
|
+
Partial<PublishLocalAarFlags>;
|
|
33
|
+
export type BrownfieldPackageIosOptions = BrownfieldCommonOptions &
|
|
34
|
+
Partial<PackageIosOptions>;
|
|
35
|
+
|
|
36
|
+
export type BrownfieldAndroidConfig = Omit<
|
|
37
|
+
Partial<PackageAarFlags> & Partial<PublishLocalAarFlags>,
|
|
38
|
+
keyof BrownfieldCommonOptions
|
|
39
|
+
>;
|
|
40
|
+
export type BrownfieldIosConfig = Omit<
|
|
41
|
+
Partial<PackageIosOptions>,
|
|
42
|
+
keyof BrownfieldCommonOptions
|
|
43
|
+
>;
|
|
44
|
+
|
|
45
|
+
export type BrownfieldConfig = BrownfieldConfigMetadata &
|
|
46
|
+
BrownfieldCommonOptions &
|
|
47
|
+
Partial<{
|
|
48
|
+
android: BrownfieldAndroidConfig;
|
|
49
|
+
ios: BrownfieldIosConfig;
|
|
50
|
+
brownie: BrownieConfig;
|
|
51
|
+
}>;
|
package/dist/brownie/types.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/brownie/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAC"}
|
package/src/brownie/types.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type Platform = 'swift' | 'kotlin';
|
|
File without changes
|