@callstack/brownfield-cli 1.0.3 → 2.0.0-rc.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.
Files changed (50) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +0 -1
  3. package/dist/brownfield/commands/packageAndroid.d.ts.map +1 -1
  4. package/dist/brownfield/commands/packageAndroid.js +8 -1
  5. package/dist/brownfield/commands/packageIos.d.ts.map +1 -1
  6. package/dist/brownfield/commands/packageIos.js +23 -12
  7. package/dist/brownfield/commands/publishAndroid.d.ts.map +1 -1
  8. package/dist/brownfield/commands/publishAndroid.js +8 -1
  9. package/dist/brownfield/index.d.ts +0 -1
  10. package/dist/brownfield/index.d.ts.map +1 -1
  11. package/dist/brownfield/index.js +0 -1
  12. package/dist/brownfield/utils/expo.d.ts +7 -0
  13. package/dist/brownfield/utils/expo.d.ts.map +1 -0
  14. package/dist/brownfield/utils/expo.js +40 -0
  15. package/dist/brownfield/utils/paths.d.ts +6 -1
  16. package/dist/brownfield/utils/paths.d.ts.map +1 -1
  17. package/dist/brownfield/utils/paths.js +6 -4
  18. package/dist/brownfield/utils/project.d.ts +51 -0
  19. package/dist/brownfield/utils/project.d.ts.map +1 -0
  20. package/dist/brownfield/utils/project.js +114 -0
  21. package/dist/brownie/commands/codegen.d.ts.map +1 -1
  22. package/dist/brownie/commands/codegen.js +26 -11
  23. package/dist/brownie/errors/NoBrownieStoresError.d.ts +4 -0
  24. package/dist/brownie/errors/NoBrownieStoresError.d.ts.map +1 -0
  25. package/dist/brownie/errors/NoBrownieStoresError.js +6 -0
  26. package/dist/brownie/helpers/runBrownieCodegenIfApplicable.d.ts +5 -0
  27. package/dist/brownie/helpers/runBrownieCodegenIfApplicable.d.ts.map +1 -0
  28. package/dist/brownie/helpers/runBrownieCodegenIfApplicable.js +9 -0
  29. package/dist/brownie/store-discovery.d.ts.map +1 -1
  30. package/dist/brownie/store-discovery.js +2 -1
  31. package/package.json +7 -8
  32. package/src/brownfield/commands/packageAndroid.ts +9 -1
  33. package/src/brownfield/commands/packageIos.ts +28 -13
  34. package/src/brownfield/commands/publishAndroid.ts +9 -1
  35. package/src/brownfield/index.ts +0 -2
  36. package/src/brownfield/utils/expo.ts +71 -0
  37. package/src/brownfield/utils/paths.ts +7 -10
  38. package/src/brownfield/utils/project.ts +174 -0
  39. package/src/brownie/commands/codegen.ts +27 -14
  40. package/src/brownie/errors/NoBrownieStoresError.ts +6 -0
  41. package/src/brownie/helpers/runBrownieCodegenIfApplicable.ts +16 -0
  42. package/src/brownie/store-discovery.ts +3 -1
  43. package/dist/brownfield/utils/index.d.ts +0 -4
  44. package/dist/brownfield/utils/index.d.ts.map +0 -1
  45. package/dist/brownfield/utils/index.js +0 -3
  46. package/dist/brownfield/utils/rn-cli.d.ts +0 -17
  47. package/dist/brownfield/utils/rn-cli.d.ts.map +0 -1
  48. package/dist/brownfield/utils/rn-cli.js +0 -31
  49. package/src/brownfield/utils/index.ts +0 -3
  50. package/src/brownfield/utils/rn-cli.ts +0 -58
@@ -15,14 +15,15 @@ import {
15
15
 
16
16
  import { Command } from 'commander';
17
17
 
18
- import { isBrownieInstalled } from '../../brownie/config.js';
19
- import { runCodegen } from '../../brownie/commands/codegen.js';
20
- import { getProjectInfo, stripFrameworkBinary } from '../utils/index.js';
18
+ import { runExpoPrebuildIfNeeded } from '../utils/expo.js';
19
+ import { getProjectInfo } from '../utils/project.js';
21
20
  import {
22
21
  actionRunner,
23
22
  curryOptions,
24
23
  ExampleUsage,
25
24
  } from '../../shared/index.js';
25
+ import { runBrownieCodegenIfApplicable } from '../../brownie/helpers/runBrownieCodegenIfApplicable.js';
26
+ import { stripFrameworkBinary } from '../utils/stripFrameworkBinary.js';
26
27
 
27
28
  export const packageIosCommand = curryOptions(
28
29
  new Command('package:ios').description('Build iOS XCFramework'),
@@ -32,13 +33,14 @@ export const packageIosCommand = curryOptions(
32
33
  ...option,
33
34
  description:
34
35
  option.description +
35
- " By default, the '<iOS project folder>/build' path will be used.",
36
+ " By default, the '.brownfield/build' path will be used.",
36
37
  }
37
38
  : option
38
39
  )
39
40
  ).action(
40
41
  actionRunner(async (options: AppleBuildFlags) => {
41
42
  const { projectRoot, platformConfig, userConfig } = getProjectInfo('ios');
43
+ await runExpoPrebuildIfNeeded({ projectRoot, platform: 'ios' });
42
44
 
43
45
  if (!userConfig.project.ios) {
44
46
  throw new Error('iOS project not found.');
@@ -48,19 +50,32 @@ export const packageIosCommand = curryOptions(
48
50
  throw new Error('iOS Xcode project not found in the configuration.');
49
51
  }
50
52
 
51
- const brownieCacheDir = path.join(
52
- userConfig.project.ios.sourceDir,
53
+ let dotBrownfieldDir = path.join(
54
+ // for Expo projects, platformConfig?.sourceDir == "", but for non-Expo projects, it's "ios"
55
+ ...(userConfig.project.ios.sourceDir.trim().length > 0
56
+ ? [userConfig.project.ios.sourceDir]
57
+ : [projectRoot, 'ios']),
53
58
  '.brownfield'
54
59
  );
55
60
 
56
- options.buildFolder ??= path.join(brownieCacheDir, 'build');
57
- const packageDir = path.join(brownieCacheDir, 'package');
61
+ // non-Expo projects have a relative sourceDir path, so we need to make it absolute
62
+ if (!path.isAbsolute(dotBrownfieldDir)) {
63
+ dotBrownfieldDir = path.join(projectRoot, dotBrownfieldDir);
64
+ }
65
+
66
+ options.buildFolder ??= path.join(dotBrownfieldDir, 'build');
67
+
68
+ // The new_architecture.rb script scans Info.plist and fails on binary plist files,
69
+ // which is the case for our XCFrameworks.
70
+ // We're reusing the "build" directory which is excluded from the scan.
71
+ // Reference: https://github.com/facebook/react-native/blob/490c5e8dcc6cdb19c334cc39e93a39a48ba71e96/packages/react-native/scripts/cocoapods/new_architecture.rb#L171
72
+ const packageDir = path.join(dotBrownfieldDir, 'package', 'build');
58
73
  const configuration = options.configuration ?? 'Debug';
59
74
 
60
- const hasBrownie = isBrownieInstalled(projectRoot);
61
- if (hasBrownie) {
62
- await runCodegen({ platform: 'swift' });
63
- }
75
+ const { hasBrownie } = await runBrownieCodegenIfApplicable(
76
+ projectRoot,
77
+ 'swift'
78
+ );
64
79
 
65
80
  await packageIosAction(
66
81
  options,
@@ -104,7 +119,7 @@ export const packageIosCommand = curryOptions(
104
119
  // Strip the binary from Brownie.xcframework to make it interface-only.
105
120
  // This avoids duplicate symbols when consumer apps embed both BrownfieldLib
106
121
  // (which contains Brownie symbols) and Brownie.xcframework.
107
- await stripFrameworkBinary(brownieOutputPath);
122
+ stripFrameworkBinary(brownieOutputPath);
108
123
 
109
124
  logger.success(
110
125
  `Brownie.xcframework created at ${colorLink(relativeToCwd(brownieOutputPath))}`
@@ -6,12 +6,14 @@ import {
6
6
 
7
7
  import { Command } from 'commander';
8
8
 
9
- import { getProjectInfo } from '../utils/index.js';
10
9
  import {
11
10
  actionRunner,
12
11
  curryOptions,
13
12
  ExampleUsage,
14
13
  } from '../../shared/index.js';
14
+ import { getProjectInfo } from '../utils/project.js';
15
+ import { runExpoPrebuildIfNeeded } from '../utils/expo.js';
16
+ import { runBrownieCodegenIfApplicable } from '../../brownie/helpers/runBrownieCodegenIfApplicable.js';
15
17
 
16
18
  export const publishAndroidCommand = curryOptions(
17
19
  new Command('publish:android').description(
@@ -21,6 +23,12 @@ export const publishAndroidCommand = curryOptions(
21
23
  ).action(
22
24
  actionRunner(async (options: PublishLocalAarFlags) => {
23
25
  const { projectRoot, platformConfig } = getProjectInfo('android');
26
+ await runExpoPrebuildIfNeeded({
27
+ projectRoot,
28
+ platform: 'android',
29
+ });
30
+
31
+ await runBrownieCodegenIfApplicable(projectRoot, 'kotlin');
24
32
 
25
33
  await publishLocalAarAction({
26
34
  projectRoot,
@@ -9,8 +9,6 @@ import {
9
9
  } from './commands/publishAndroid.js';
10
10
  import { packageIosCommand, packageIosExample } from './commands/packageIos.js';
11
11
 
12
- export * from './utils/index.js';
13
-
14
12
  export const groupName = `${styleText(['bold', 'blueBright'], '@callstack/react-native-brownfield')}${styleText('whiteBright', ' - utilities for React Native Brownfield projects')}`;
15
13
 
16
14
  export const Commands = {
@@ -0,0 +1,71 @@
1
+ import { spawn } from 'node:child_process';
2
+
3
+ import { logger } from '@rock-js/tools';
4
+
5
+ import { isExpoProject } from './project.js';
6
+
7
+ type ExpoPlatform = 'ios' | 'android';
8
+
9
+ async function spawnCommand({
10
+ command,
11
+ args,
12
+ cwd,
13
+ }: {
14
+ command: string;
15
+ args: string[];
16
+ cwd: string;
17
+ }) {
18
+ await new Promise<void>((resolve, reject) => {
19
+ const child = spawn(command, args, {
20
+ cwd,
21
+ env: process.env,
22
+ stdio: 'inherit',
23
+ });
24
+
25
+ child.on('error', reject);
26
+ child.on('close', (code) => {
27
+ if (code === 0) {
28
+ resolve();
29
+ } else {
30
+ reject(
31
+ new Error(
32
+ `Command "${command} ${args.join(' ')}" failed with exit code ${code ?? 'unknown'}.`
33
+ )
34
+ );
35
+ }
36
+ });
37
+ });
38
+ }
39
+
40
+ function getNpxCommand() {
41
+ return process.platform === 'win32' ? 'npx.cmd' : 'npx';
42
+ }
43
+
44
+ export async function runExpoPrebuildIfNeeded({
45
+ projectRoot,
46
+ platform,
47
+ }: {
48
+ projectRoot: string;
49
+ platform: ExpoPlatform;
50
+ }) {
51
+ if (!isExpoProject(projectRoot)) {
52
+ return false;
53
+ }
54
+
55
+ logger.info(
56
+ `Expo project detected. Running expo prebuild for ${platform}...`
57
+ );
58
+
59
+ const args = ['expo', 'prebuild', '--platform', platform];
60
+ if (platform === 'ios') {
61
+ args.push('--no-install');
62
+ }
63
+
64
+ await spawnCommand({
65
+ command: getNpxCommand(),
66
+ args,
67
+ cwd: projectRoot,
68
+ });
69
+
70
+ return true;
71
+ }
@@ -5,21 +5,18 @@ import type {
5
5
  AndroidProjectConfig,
6
6
  IOSProjectConfig,
7
7
  } from '@react-native-community/cli-types';
8
- import cloneDeep from 'lodash.clonedeep';
9
8
 
9
+ /**
10
+ * Helper function to mutate the user config paths in place to be relative to the project root
11
+ * @param projectRoot The path to the project root directory
12
+ * @param userConfig User configuration from the RNC CLI
13
+ */
10
14
  export function makeRelativeProjectConfigPaths<
11
15
  UserConfig extends AndroidProjectConfig | IOSProjectConfig | undefined,
12
- >(projectRoot: string, userConfig: UserConfig): UserConfig {
13
- const relativeConfig = cloneDeep(userConfig);
14
-
16
+ >(projectRoot: string, userConfig: UserConfig) {
15
17
  if (userConfig?.sourceDir) {
16
- relativeConfig!.sourceDir = path.relative(
17
- projectRoot,
18
- userConfig.sourceDir
19
- );
18
+ userConfig.sourceDir = path.relative(projectRoot, userConfig.sourceDir);
20
19
  }
21
-
22
- return relativeConfig;
23
20
  }
24
21
 
25
22
  /**
@@ -0,0 +1,174 @@
1
+ import * as fs from 'node:fs';
2
+ import * as path from 'node:path';
3
+ import type {
4
+ AndroidProjectConfig,
5
+ ProjectConfig,
6
+ UserConfig,
7
+ } from '@react-native-community/cli-types';
8
+ import type { PackageAarFlags } from '@rock-js/platform-android';
9
+
10
+ import cliConfigImport from '@react-native-community/cli-config';
11
+
12
+ import { findProjectRoot, makeRelativeProjectConfigPaths } from './paths.js';
13
+ import {
14
+ getConfig,
15
+ type ProjectConfig as ExpoProjectConfig,
16
+ } from '@expo/config';
17
+
18
+ const cliConfig: typeof cliConfigImport =
19
+ typeof cliConfigImport === 'function'
20
+ ? cliConfigImport
21
+ : // @ts-expect-error: interop default
22
+ cliConfigImport.default;
23
+
24
+ /**
25
+ * Gets the Expo config if the project is an Expo project
26
+ * @param projectRoot The project root path
27
+ * @returns The Expo config if the project is an Expo project, null otherwise
28
+ */
29
+ export function getExpoConfigIfIsExpo(projectRoot: string) {
30
+ try {
31
+ return getConfig(projectRoot, { skipSDKVersionRequirement: true });
32
+ } catch {
33
+ return null;
34
+ }
35
+ }
36
+
37
+ /**
38
+ * Checks if the project is an Expo project; checks both if installed and explicitly listed
39
+ * in the project's package.json to prevent false positives in a monorepo setup
40
+ * @param projectRoot The project root path
41
+ * @returns Whether the project is an Expo project
42
+ */
43
+ export function isExpoProject(projectRoot: string): boolean {
44
+ const hasExpoConfig = getExpoConfigIfIsExpo(projectRoot) !== null;
45
+
46
+ // additionally, it is needed to check if the project depends on Expo packages explicitly
47
+ // to prevent false positives in a monorepo setup
48
+ const rnProjectRoot = findProjectRoot();
49
+ const packageJsonPath = path.join(rnProjectRoot, 'package.json');
50
+ const dependsOnExpo =
51
+ fs.existsSync(packageJsonPath) &&
52
+ ['dependencies', 'peerDependencies', 'devDependencies'].some(
53
+ (key) => JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'))[key]?.expo
54
+ );
55
+
56
+ return hasExpoConfig && dependsOnExpo;
57
+ }
58
+
59
+ /**
60
+ * Fills the RNC CLI project config from the Expo config by mutating the passed in `options.projectConfig` object in place
61
+ */
62
+ export function fillProjectConfigFromExpoConfig({
63
+ projectConfig,
64
+ expoConfig: { exp },
65
+ projectRoot,
66
+ }: {
67
+ /** The RNC CLI project config to be filled */
68
+ projectConfig: ProjectConfig;
69
+
70
+ /** The Expo project config */
71
+ expoConfig: ExpoProjectConfig;
72
+
73
+ /** The project root path */
74
+ projectRoot: string;
75
+ }) {
76
+ if (exp.android) {
77
+ projectConfig['android'] = {
78
+ applicationId: exp.android.package!,
79
+ packageName: exp.android.package!,
80
+ appName: exp.name!,
81
+ assets: [],
82
+ mainActivity: 'MainActivity',
83
+ sourceDir: 'android',
84
+ };
85
+ }
86
+
87
+ if (exp.ios) {
88
+ projectConfig['ios'] = {
89
+ assets: [],
90
+ sourceDir: projectRoot,
91
+ xcodeProject: {
92
+ path: '.',
93
+ name: `${exp.name}.xcworkspace`,
94
+ isWorkspace: true,
95
+ },
96
+ };
97
+ }
98
+ }
99
+
100
+ /**
101
+ * Gets the project info for the given platform from the current working directory
102
+ * @param platform the platform for which to get project info
103
+ * @returns project root and android project config
104
+ */
105
+ export function getProjectInfo<Platform extends 'ios' | 'android'>(
106
+ platform: Platform
107
+ ): {
108
+ projectRoot: string;
109
+ userConfig: UserConfig;
110
+ platformConfig: ProjectConfig[Platform];
111
+ } {
112
+ const projectRoot = findProjectRoot();
113
+
114
+ const userConfig = getUserConfig({ projectRoot, platform });
115
+ const platformConfig = userConfig.project[platform as Platform];
116
+
117
+ if (!platformConfig) {
118
+ throw new Error(`${platform} project not found.`);
119
+ }
120
+
121
+ return {
122
+ projectRoot,
123
+ userConfig,
124
+ platformConfig: platformConfig,
125
+ };
126
+ }
127
+
128
+ export function getUserConfig({
129
+ projectRoot,
130
+ platform,
131
+ }: {
132
+ projectRoot: string;
133
+ platform: 'ios' | 'android';
134
+ }): UserConfig {
135
+ // resolve the config using RNC CLI
136
+ const userConfig = cliConfig({
137
+ projectRoot,
138
+ selectedPlatform: platform,
139
+ });
140
+
141
+ let projectConfig = userConfig.project;
142
+
143
+ // below: try augmenting the config with values for Expo projects, if applicable
144
+ const maybeExpoConfig = getExpoConfigIfIsExpo(projectRoot);
145
+ if (maybeExpoConfig) {
146
+ fillProjectConfigFromExpoConfig({
147
+ projectConfig,
148
+ expoConfig: maybeExpoConfig,
149
+ projectRoot,
150
+ });
151
+ }
152
+
153
+ // below: relative sourceDir path is required by RN CLI's API
154
+ makeRelativeProjectConfigPaths(projectRoot, projectConfig[platform]);
155
+
156
+ return userConfig;
157
+ }
158
+
159
+ /**
160
+ * Gets the AAR packaging configuration for the given Android project
161
+ * @param args The AAR packaging flags
162
+ * @param androidConfig The Android project config
163
+ */
164
+ export function getAarConfig(
165
+ args: PackageAarFlags,
166
+ androidConfig: AndroidProjectConfig
167
+ ) {
168
+ const config = {
169
+ sourceDir: androidConfig.sourceDir,
170
+ moduleName: args.moduleName ?? '',
171
+ };
172
+
173
+ return config;
174
+ }
@@ -15,6 +15,7 @@ import { generateSwift } from '../generators/swift.js';
15
15
  import { generateKotlin } from '../generators/kotlin.js';
16
16
  import { discoverStores, type DiscoveredStore } from '../store-discovery.js';
17
17
  import type { Platform } from '../types.js';
18
+ import { NoBrownieStoresError } from '../errors/NoBrownieStoresError.js';
18
19
 
19
20
  function getOutputPath(dir: string, name: string, ext: string): string {
20
21
  return path.join(dir, `${name}.${ext}`);
@@ -100,25 +101,37 @@ export async function runCodegen({ platform }: RunCodegenOptions) {
100
101
  process.exit(1);
101
102
  }
102
103
 
103
- const stores = discoverStores();
104
- const isMultipleStores = stores.length > 1;
105
- const schemaList = stores.map((s) => path.basename(s.schemaPath)).join(', ');
104
+ try {
105
+ const stores = discoverStores();
106
+ const isMultipleStores = stores.length > 1;
107
+ const schemaList = stores
108
+ .map((s) => path.basename(s.schemaPath))
109
+ .join(', ');
106
110
 
107
- logger.info(
108
- styleText('cyan', `Generating store types from ${schemaList}...`)
109
- );
111
+ logger.info(
112
+ styleText('cyan', `Generating store types from ${schemaList}...`)
113
+ );
114
+
115
+ for (const store of stores) {
116
+ let platforms: Platform[];
110
117
 
111
- for (const store of stores) {
112
- let platforms: Platform[];
118
+ if (platform) {
119
+ platforms = [platform];
120
+ } else {
121
+ // Only generate Swift by default (Kotlin not yet released)
122
+ platforms = ['swift'];
123
+ }
113
124
 
114
- if (platform) {
115
- platforms = [platform];
125
+ await generateForStore(store, config, platforms, isMultipleStores);
126
+ }
127
+ } catch (error) {
128
+ if (error instanceof NoBrownieStoresError) {
129
+ logger.error(error.message);
130
+ outro('No brownie stores found, nothing was generated.');
131
+ return;
116
132
  } else {
117
- // Only generate Swift by default (Kotlin not yet released)
118
- platforms = ['swift'];
133
+ throw error;
119
134
  }
120
-
121
- await generateForStore(store, config, platforms, isMultipleStores);
122
135
  }
123
136
 
124
137
  outro('Done!');
@@ -0,0 +1,6 @@
1
+ export class NoBrownieStoresError extends Error {
2
+ constructor(message: string) {
3
+ super(message);
4
+ this.name = 'NoBrownieStoresError';
5
+ }
6
+ }
@@ -0,0 +1,16 @@
1
+ import { runCodegen } from '../commands/codegen.js';
2
+ import { isBrownieInstalled } from '../config.js';
3
+
4
+ import type { Platform } from '../types.js';
5
+
6
+ export async function runBrownieCodegenIfApplicable(
7
+ projectRoot: string,
8
+ platform: Platform
9
+ ) {
10
+ const hasBrownie = isBrownieInstalled(projectRoot);
11
+ if (hasBrownie) {
12
+ await runCodegen({ platform });
13
+ }
14
+
15
+ return { hasBrownie };
16
+ }
@@ -2,6 +2,8 @@ import fs from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import { Project } from 'ts-morph';
4
4
 
5
+ import { NoBrownieStoresError } from './errors/NoBrownieStoresError.js';
6
+
5
7
  export interface DiscoveredStore {
6
8
  name: string;
7
9
  schemaPath: string;
@@ -75,7 +77,7 @@ export function discoverStores(
75
77
  const brownieFiles = findBrownieFiles(rootDir);
76
78
 
77
79
  if (brownieFiles.length === 0) {
78
- throw new Error(
80
+ throw new NoBrownieStoresError(
79
81
  'No brownie store files found. Create a file ending with .brownie.ts ' +
80
82
  '(e.g., MyStore.brownie.ts)'
81
83
  );
@@ -1,4 +0,0 @@
1
- export * from './paths.js';
2
- export * from './rn-cli.js';
3
- export * from './stripFrameworkBinary.js';
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/brownfield/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,2BAA2B,CAAC"}
@@ -1,3 +0,0 @@
1
- export * from './paths.js';
2
- export * from './rn-cli.js';
3
- export * from './stripFrameworkBinary.js';
@@ -1,17 +0,0 @@
1
- import type { PackageAarFlags } from '@rock-js/platform-android';
2
- import type { AndroidProjectConfig, Config as UserConfig, ProjectConfig } from '@react-native-community/cli-types';
3
- /**
4
- * Gets the project info for the given platform from the current working directory
5
- * @param platform the platform for which to get project info
6
- * @returns project root and android project config
7
- */
8
- export declare function getProjectInfo<Platform extends 'ios' | 'android'>(platform: Platform): {
9
- projectRoot: string;
10
- userConfig: UserConfig;
11
- platformConfig: ProjectConfig[Platform];
12
- };
13
- export declare const getAarConfig: (args: PackageAarFlags, androidConfig: AndroidProjectConfig) => {
14
- sourceDir: string;
15
- moduleName: string;
16
- };
17
- //# sourceMappingURL=rn-cli.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rn-cli.d.ts","sourceRoot":"","sources":["../../../src/brownfield/utils/rn-cli.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,KAAK,EACV,oBAAoB,EACpB,MAAM,IAAI,UAAU,EACpB,aAAa,EACd,MAAM,mCAAmC,CAAC;AAW3C;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,QAAQ,SAAS,KAAK,GAAG,SAAS,EAC/D,QAAQ,EAAE,QAAQ,GACjB;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,UAAU,CAAC;IACvB,cAAc,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;CACzC,CAmBA;AAED,eAAO,MAAM,YAAY,GACvB,MAAM,eAAe,EACrB,eAAe,oBAAoB;;;CAOpC,CAAC"}
@@ -1,31 +0,0 @@
1
- import cliConfigImport from '@react-native-community/cli-config';
2
- const cliConfig = typeof cliConfigImport === 'function'
3
- ? cliConfigImport
4
- : // @ts-expect-error: interop default
5
- cliConfigImport.default;
6
- import { findProjectRoot, makeRelativeProjectConfigPaths } from './paths.js';
7
- /**
8
- * Gets the project info for the given platform from the current working directory
9
- * @param platform the platform for which to get project info
10
- * @returns project root and android project config
11
- */
12
- export function getProjectInfo(platform) {
13
- const projectRoot = findProjectRoot();
14
- const userConfig = cliConfig({
15
- projectRoot,
16
- selectedPlatform: platform,
17
- });
18
- // below: relative sourceDir path is required by RN CLI's API
19
- const platformConfig = makeRelativeProjectConfigPaths(projectRoot, userConfig.project[platform]);
20
- if (!platformConfig) {
21
- throw new Error(`${platform} project not found.`);
22
- }
23
- return { projectRoot, userConfig, platformConfig };
24
- }
25
- export const getAarConfig = (args, androidConfig) => {
26
- const config = {
27
- sourceDir: androidConfig.sourceDir,
28
- moduleName: args.moduleName ?? '',
29
- };
30
- return config;
31
- };
@@ -1,3 +0,0 @@
1
- export * from './paths.js';
2
- export * from './rn-cli.js';
3
- export * from './stripFrameworkBinary.js';
@@ -1,58 +0,0 @@
1
- import type { PackageAarFlags } from '@rock-js/platform-android';
2
- import type {
3
- AndroidProjectConfig,
4
- Config as UserConfig,
5
- ProjectConfig,
6
- } from '@react-native-community/cli-types';
7
- import cliConfigImport from '@react-native-community/cli-config';
8
-
9
- const cliConfig: typeof cliConfigImport =
10
- typeof cliConfigImport === 'function'
11
- ? cliConfigImport
12
- : // @ts-expect-error: interop default
13
- cliConfigImport.default;
14
-
15
- import { findProjectRoot, makeRelativeProjectConfigPaths } from './paths.js';
16
-
17
- /**
18
- * Gets the project info for the given platform from the current working directory
19
- * @param platform the platform for which to get project info
20
- * @returns project root and android project config
21
- */
22
- export function getProjectInfo<Platform extends 'ios' | 'android'>(
23
- platform: Platform
24
- ): {
25
- projectRoot: string;
26
- userConfig: UserConfig;
27
- platformConfig: ProjectConfig[Platform];
28
- } {
29
- const projectRoot = findProjectRoot();
30
-
31
- const userConfig = cliConfig({
32
- projectRoot,
33
- selectedPlatform: platform,
34
- });
35
-
36
- // below: relative sourceDir path is required by RN CLI's API
37
- const platformConfig = makeRelativeProjectConfigPaths(
38
- projectRoot,
39
- userConfig.project[platform]
40
- );
41
-
42
- if (!platformConfig) {
43
- throw new Error(`${platform} project not found.`);
44
- }
45
-
46
- return { projectRoot, userConfig, platformConfig };
47
- }
48
-
49
- export const getAarConfig = (
50
- args: PackageAarFlags,
51
- androidConfig: AndroidProjectConfig
52
- ) => {
53
- const config = {
54
- sourceDir: androidConfig.sourceDir,
55
- moduleName: args.moduleName ?? '',
56
- };
57
- return config;
58
- };