@rock-js/plugin-brownfield-ios 0.12.4 → 0.12.6

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.
@@ -1 +1,2 @@
1
1
  export * from './lib/pluginBrownfieldIos.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC"}
@@ -3,3 +3,4 @@ export declare function copyHermesXcframework({ sourceDir, destinationDir, react
3
3
  destinationDir: string;
4
4
  reactNativeVersion: string;
5
5
  }): void;
6
+ //# sourceMappingURL=copyHermesXcframework.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copyHermesXcframework.d.ts","sourceRoot":"","sources":["../../../src/lib/copyHermesXcframework.ts"],"names":[],"mappings":"AAIA,wBAAgB,qBAAqB,CAAC,EACpC,SAAS,EACT,cAAc,EACd,kBAAkB,GACnB,EAAE;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,kBAAkB,EAAE,MAAM,CAAC;CAC5B,QAyBA"}
@@ -1,4 +1,14 @@
1
1
  import type { IOSProjectConfig } from '@react-native-community/cli-types';
2
2
  import type { PluginApi, PluginOutput } from '@rock-js/config';
3
+ import { type BuildFlags } from '@rock-js/platform-apple-helpers';
4
+ export declare const packageIosAction: (args: BuildFlags, { projectRoot, reactNativePath, reactNativeVersion, usePrebuiltRNCore, skipCache, packageDir, }: {
5
+ projectRoot: string;
6
+ reactNativePath: string;
7
+ reactNativeVersion: string;
8
+ usePrebuiltRNCore: boolean | undefined;
9
+ skipCache?: boolean;
10
+ packageDir?: string;
11
+ }, pluginConfig?: IOSProjectConfig) => Promise<void>;
3
12
  export declare const pluginBrownfieldIos: (pluginConfig?: IOSProjectConfig) => (api: PluginApi) => PluginOutput;
4
13
  export default pluginBrownfieldIos;
14
+ //# sourceMappingURL=pluginBrownfieldIos.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pluginBrownfieldIos.d.ts","sourceRoot":"","sources":["../../../src/lib/pluginBrownfieldIos.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAEL,KAAK,UAAU,EAMhB,MAAM,iCAAiC,CAAC;AAazC,eAAO,MAAM,gBAAgB,GAC3B,MAAM,UAAU,EAChB,iGAOG;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,iBAAiB,EAAE,OAAO,GAAG,SAAS,CAAC;IACvC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,EACD,eAAe,gBAAgB,kBAgGhC,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAC7B,eAAe,gBAAgB,MAC/B,KAAK,SAAS,KAAG,YAsBjB,CAAC;AAEJ,eAAe,mBAAmB,CAAC"}
@@ -1,66 +1,79 @@
1
1
  import path from 'node:path';
2
- import { createBuild, genericDestinations, getBuildOptions, getBuildPaths, getValidProjectConfig, mergeFrameworks, } from '@rock-js/platform-apple-helpers';
3
- import { colorLink, intro, logger, outro, relativeToCwd } from '@rock-js/tools';
2
+ import { buildApp, genericDestinations, getBuildOptions, getBuildPaths, getValidProjectConfig, mergeFrameworks, } from '@rock-js/platform-apple-helpers';
3
+ import { colorLink, intro, logger, outro, relativeToCwd, RockError, } from '@rock-js/tools';
4
4
  import { copyHermesXcframework } from './copyHermesXcframework.js';
5
5
  const buildOptions = getBuildOptions({ platformName: 'ios' });
6
+ export const packageIosAction = async (args, { projectRoot, reactNativePath, reactNativeVersion, usePrebuiltRNCore, skipCache, packageDir, }, pluginConfig) => {
7
+ intro('Packaging iOS project');
8
+ // 1) Build the project
9
+ const iosConfig = getValidProjectConfig('ios', projectRoot, pluginConfig);
10
+ const destination = args.destination ?? [
11
+ genericDestinations.ios.device,
12
+ genericDestinations.ios.simulator,
13
+ ];
14
+ const buildFolder = args.buildFolder ?? getBuildPaths('ios').derivedDataDir;
15
+ const configuration = args.configuration ?? 'Debug';
16
+ let scheme;
17
+ try {
18
+ const { appPath, ...buildAppResult } = await buildApp({
19
+ projectRoot,
20
+ projectConfig: iosConfig,
21
+ platformName: 'ios',
22
+ args: { ...args, destination, buildFolder },
23
+ reactNativePath,
24
+ brownfield: true,
25
+ usePrebuiltRNCore,
26
+ pluginConfig,
27
+ skipCache,
28
+ });
29
+ logger.log(`Build available at: ${colorLink(relativeToCwd(appPath))}`);
30
+ scheme = buildAppResult.scheme;
31
+ }
32
+ catch (error) {
33
+ const message = `Failed to create ${args.archive ? 'archive' : 'build'}`;
34
+ throw new RockError(message, { cause: error });
35
+ }
36
+ // 2) Merge the .framework outputs of the framework target
37
+ const productsPath = path.join(buildFolder, 'Build', 'Products');
38
+ const frameworkTargetOutputDir = packageDir ?? getBuildPaths('ios').packageDir;
39
+ const { sourceDir } = iosConfig;
40
+ await mergeFrameworks({
41
+ sourceDir,
42
+ frameworkPaths: [
43
+ path.join(productsPath, `${configuration}-iphoneos`, `${scheme}.framework`),
44
+ path.join(productsPath, `${configuration}-iphonesimulator`, `${scheme}.framework`),
45
+ ],
46
+ outputPath: path.join(frameworkTargetOutputDir, `${scheme}.xcframework`),
47
+ });
48
+ // 3) Merge React Native Brownfield paths
49
+ await mergeFrameworks({
50
+ sourceDir,
51
+ frameworkPaths: [
52
+ path.join(productsPath, `${configuration}-iphoneos`, 'ReactBrownfield', 'ReactBrownfield.framework'),
53
+ path.join(productsPath, `${configuration}-iphonesimulator`, 'ReactBrownfield', 'ReactBrownfield.framework'),
54
+ ],
55
+ outputPath: path.join(frameworkTargetOutputDir, 'ReactBrownfield.xcframework'),
56
+ });
57
+ // 4) Copy hermes xcframework to the output path
58
+ copyHermesXcframework({
59
+ sourceDir,
60
+ destinationDir: frameworkTargetOutputDir,
61
+ reactNativeVersion,
62
+ });
63
+ // 5) Inform the user
64
+ logger.log(`XCFrameworks are available at: ${colorLink(relativeToCwd(frameworkTargetOutputDir))}`);
65
+ outro('Success 🎉.');
66
+ };
6
67
  export const pluginBrownfieldIos = (pluginConfig) => (api) => {
7
68
  api.registerCommand({
8
69
  name: 'package:ios',
9
70
  description: 'Emit a .xcframework file from React Native code.',
10
- action: async (args) => {
11
- intro('Packaging iOS project');
12
- // 1) Build the project
13
- const projectRoot = api.getProjectRoot();
14
- const iosConfig = getValidProjectConfig('ios', projectRoot, pluginConfig);
15
- const { derivedDataDir } = getBuildPaths('ios');
16
- const destination = args.destination ?? [
17
- genericDestinations.ios.device,
18
- genericDestinations.ios.simulator,
19
- ];
20
- const buildFolder = args.buildFolder ?? derivedDataDir;
21
- const configuration = args.configuration ?? 'Debug';
22
- const { sourceDir } = iosConfig;
23
- const { scheme } = await createBuild({
24
- platformName: 'ios',
25
- projectConfig: iosConfig,
26
- args: { ...args, destination, buildFolder },
27
- projectRoot,
28
- reactNativePath: api.getReactNativePath(),
29
- fingerprintOptions: api.getFingerprintOptions(),
30
- brownfield: true,
31
- remoteCacheProvider: await api.getRemoteCacheProvider(),
32
- usePrebuiltRNCore: api.getUsePrebuiltRNCore(),
33
- });
34
- // 2) Merge the .framework outputs of the framework target
35
- const productsPath = path.join(buildFolder, 'Build', 'Products');
36
- const { packageDir: frameworkTargetOutputDir } = getBuildPaths('ios');
37
- await mergeFrameworks({
38
- sourceDir,
39
- frameworkPaths: [
40
- path.join(productsPath, `${configuration}-iphoneos`, `${scheme}.framework`),
41
- path.join(productsPath, `${configuration}-iphonesimulator`, `${scheme}.framework`),
42
- ],
43
- outputPath: path.join(frameworkTargetOutputDir, `${scheme}.xcframework`),
44
- });
45
- // 3) Merge React Native Brownfield paths
46
- await mergeFrameworks({
47
- sourceDir,
48
- frameworkPaths: [
49
- path.join(productsPath, `${configuration}-iphoneos`, 'ReactBrownfield', 'ReactBrownfield.framework'),
50
- path.join(productsPath, `${configuration}-iphonesimulator`, 'ReactBrownfield', 'ReactBrownfield.framework'),
51
- ],
52
- outputPath: path.join(frameworkTargetOutputDir, 'ReactBrownfield.xcframework'),
53
- });
54
- // 4) Copy hermes xcframework to the output path
55
- copyHermesXcframework({
56
- sourceDir,
57
- destinationDir: frameworkTargetOutputDir,
58
- reactNativeVersion: api.getReactNativeVersion(),
59
- });
60
- // 5) Inform the user
61
- logger.log(`XCFrameworks are available at: ${colorLink(relativeToCwd(frameworkTargetOutputDir))}`);
62
- outro('Success 🎉.');
63
- },
71
+ action: async (args) => packageIosAction(args, {
72
+ projectRoot: api.getProjectRoot(),
73
+ reactNativePath: api.getReactNativePath(),
74
+ reactNativeVersion: api.getReactNativeVersion(),
75
+ usePrebuiltRNCore: api.getUsePrebuiltRNCore(),
76
+ }, pluginConfig),
64
77
  options: buildOptions,
65
78
  });
66
79
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"pluginBrownfieldIos.js","sourceRoot":"","sources":["../../../src/lib/pluginBrownfieldIos.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,OAAO,EAEL,WAAW,EACX,mBAAmB,EACnB,eAAe,EACf,aAAa,EACb,qBAAqB,EACrB,eAAe,GAChB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAChF,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,MAAM,YAAY,GAAG,eAAe,CAAC,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,CAAC;AAE9D,MAAM,CAAC,MAAM,mBAAmB,GAC9B,CAAC,YAA+B,EAAE,EAAE,CACpC,CAAC,GAAc,EAAgB,EAAE;IAC/B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
3
- "version": "0.12.4",
3
+ "version": "0.12.6",
4
4
  "description": "Plugin for integrating Rock projects with existing iOS apps",
5
5
  "type": "module",
6
6
  "types": "./dist/src/index.d.ts",
@@ -22,12 +22,12 @@
22
22
  "dependencies": {
23
23
  "@react-native-community/cli-config-apple": "^20.0.0",
24
24
  "@react-native-community/cli-types": "^20.0.0",
25
- "@rock-js/tools": "^0.12.4",
26
- "@rock-js/platform-apple-helpers": "^0.12.4",
25
+ "@rock-js/tools": "^0.12.6",
26
+ "@rock-js/platform-apple-helpers": "^0.12.6",
27
27
  "tslib": "^2.3.0"
28
28
  },
29
29
  "devDependencies": {
30
- "@rock-js/config": "^0.12.4"
30
+ "@rock-js/config": "^0.12.6"
31
31
  },
32
32
  "publishConfig": {
33
33
  "access": "public"
@@ -2,122 +2,158 @@ import path from 'node:path';
2
2
  import type { IOSProjectConfig } from '@react-native-community/cli-types';
3
3
  import type { PluginApi, PluginOutput } from '@rock-js/config';
4
4
  import {
5
+ buildApp,
5
6
  type BuildFlags,
6
- createBuild,
7
7
  genericDestinations,
8
8
  getBuildOptions,
9
9
  getBuildPaths,
10
10
  getValidProjectConfig,
11
11
  mergeFrameworks,
12
12
  } from '@rock-js/platform-apple-helpers';
13
- import { colorLink, intro, logger, outro, relativeToCwd } from '@rock-js/tools';
13
+ import {
14
+ colorLink,
15
+ intro,
16
+ logger,
17
+ outro,
18
+ relativeToCwd,
19
+ RockError,
20
+ } from '@rock-js/tools';
14
21
  import { copyHermesXcframework } from './copyHermesXcframework.js';
15
22
 
16
23
  const buildOptions = getBuildOptions({ platformName: 'ios' });
17
24
 
18
- export const pluginBrownfieldIos =
19
- (pluginConfig?: IOSProjectConfig) =>
20
- (api: PluginApi): PluginOutput => {
21
- api.registerCommand({
22
- name: 'package:ios',
23
- description: 'Emit a .xcframework file from React Native code.',
24
- action: async (args: BuildFlags) => {
25
- intro('Packaging iOS project');
25
+ export const packageIosAction = async (
26
+ args: BuildFlags,
27
+ {
28
+ projectRoot,
29
+ reactNativePath,
30
+ reactNativeVersion,
31
+ usePrebuiltRNCore,
32
+ skipCache,
33
+ packageDir,
34
+ }: {
35
+ projectRoot: string;
36
+ reactNativePath: string;
37
+ reactNativeVersion: string;
38
+ usePrebuiltRNCore: boolean | undefined;
39
+ skipCache?: boolean;
40
+ packageDir?: string;
41
+ },
42
+ pluginConfig?: IOSProjectConfig,
43
+ ) => {
44
+ intro('Packaging iOS project');
26
45
 
27
- // 1) Build the project
28
- const projectRoot = api.getProjectRoot();
29
- const iosConfig = getValidProjectConfig(
30
- 'ios',
31
- projectRoot,
32
- pluginConfig,
33
- );
34
- const { derivedDataDir } = getBuildPaths('ios');
46
+ // 1) Build the project
47
+ const iosConfig = getValidProjectConfig('ios', projectRoot, pluginConfig);
48
+ const destination = args.destination ?? [
49
+ genericDestinations.ios.device,
50
+ genericDestinations.ios.simulator,
51
+ ];
35
52
 
36
- const destination = args.destination ?? [
37
- genericDestinations.ios.device,
38
- genericDestinations.ios.simulator,
39
- ];
53
+ const buildFolder = args.buildFolder ?? getBuildPaths('ios').derivedDataDir;
54
+ const configuration = args.configuration ?? 'Debug';
55
+ let scheme;
40
56
 
41
- const buildFolder = args.buildFolder ?? derivedDataDir;
42
- const configuration = args.configuration ?? 'Debug';
57
+ try {
58
+ const { appPath, ...buildAppResult } = await buildApp({
59
+ projectRoot,
60
+ projectConfig: iosConfig,
61
+ platformName: 'ios',
62
+ args: { ...args, destination, buildFolder },
63
+ reactNativePath,
64
+ brownfield: true,
65
+ usePrebuiltRNCore,
66
+ pluginConfig,
67
+ skipCache,
68
+ });
69
+ logger.log(`Build available at: ${colorLink(relativeToCwd(appPath))}`);
43
70
 
44
- const { sourceDir } = iosConfig;
71
+ scheme = buildAppResult.scheme;
72
+ } catch (error) {
73
+ const message = `Failed to create ${args.archive ? 'archive' : 'build'}`;
74
+ throw new RockError(message, { cause: error });
75
+ }
45
76
 
46
- const { scheme } = await createBuild({
47
- platformName: 'ios',
48
- projectConfig: iosConfig,
49
- args: { ...args, destination, buildFolder },
50
- projectRoot,
51
- reactNativePath: api.getReactNativePath(),
52
- fingerprintOptions: api.getFingerprintOptions(),
53
- brownfield: true,
54
- remoteCacheProvider: await api.getRemoteCacheProvider(),
55
- usePrebuiltRNCore: api.getUsePrebuiltRNCore(),
56
- });
77
+ // 2) Merge the .framework outputs of the framework target
78
+ const productsPath = path.join(buildFolder, 'Build', 'Products');
79
+ const frameworkTargetOutputDir =
80
+ packageDir ?? getBuildPaths('ios').packageDir;
81
+ const { sourceDir } = iosConfig;
57
82
 
58
- // 2) Merge the .framework outputs of the framework target
59
- const productsPath = path.join(buildFolder, 'Build', 'Products');
60
- const { packageDir: frameworkTargetOutputDir } = getBuildPaths('ios');
83
+ await mergeFrameworks({
84
+ sourceDir,
85
+ frameworkPaths: [
86
+ path.join(
87
+ productsPath,
88
+ `${configuration}-iphoneos`,
89
+ `${scheme}.framework`,
90
+ ),
91
+ path.join(
92
+ productsPath,
93
+ `${configuration}-iphonesimulator`,
94
+ `${scheme}.framework`,
95
+ ),
96
+ ],
97
+ outputPath: path.join(frameworkTargetOutputDir, `${scheme}.xcframework`),
98
+ });
61
99
 
62
- await mergeFrameworks({
63
- sourceDir,
64
- frameworkPaths: [
65
- path.join(
66
- productsPath,
67
- `${configuration}-iphoneos`,
68
- `${scheme}.framework`,
69
- ),
70
- path.join(
71
- productsPath,
72
- `${configuration}-iphonesimulator`,
73
- `${scheme}.framework`,
74
- ),
75
- ],
76
- outputPath: path.join(
77
- frameworkTargetOutputDir,
78
- `${scheme}.xcframework`,
79
- ),
80
- });
100
+ // 3) Merge React Native Brownfield paths
101
+ await mergeFrameworks({
102
+ sourceDir,
103
+ frameworkPaths: [
104
+ path.join(
105
+ productsPath,
106
+ `${configuration}-iphoneos`,
107
+ 'ReactBrownfield',
108
+ 'ReactBrownfield.framework',
109
+ ),
110
+ path.join(
111
+ productsPath,
112
+ `${configuration}-iphonesimulator`,
113
+ 'ReactBrownfield',
114
+ 'ReactBrownfield.framework',
115
+ ),
116
+ ],
117
+ outputPath: path.join(
118
+ frameworkTargetOutputDir,
119
+ 'ReactBrownfield.xcframework',
120
+ ),
121
+ });
81
122
 
82
- // 3) Merge React Native Brownfield paths
83
- await mergeFrameworks({
84
- sourceDir,
85
- frameworkPaths: [
86
- path.join(
87
- productsPath,
88
- `${configuration}-iphoneos`,
89
- 'ReactBrownfield',
90
- 'ReactBrownfield.framework',
91
- ),
92
- path.join(
93
- productsPath,
94
- `${configuration}-iphonesimulator`,
95
- 'ReactBrownfield',
96
- 'ReactBrownfield.framework',
97
- ),
98
- ],
99
- outputPath: path.join(
100
- frameworkTargetOutputDir,
101
- 'ReactBrownfield.xcframework',
102
- ),
103
- });
123
+ // 4) Copy hermes xcframework to the output path
124
+ copyHermesXcframework({
125
+ sourceDir,
126
+ destinationDir: frameworkTargetOutputDir,
127
+ reactNativeVersion,
128
+ });
104
129
 
105
- // 4) Copy hermes xcframework to the output path
106
- copyHermesXcframework({
107
- sourceDir,
108
- destinationDir: frameworkTargetOutputDir,
109
- reactNativeVersion: api.getReactNativeVersion(),
110
- });
130
+ // 5) Inform the user
131
+ logger.log(
132
+ `XCFrameworks are available at: ${colorLink(
133
+ relativeToCwd(frameworkTargetOutputDir),
134
+ )}`,
135
+ );
111
136
 
112
- // 5) Inform the user
113
- logger.log(
114
- `XCFrameworks are available at: ${colorLink(
115
- relativeToCwd(frameworkTargetOutputDir),
116
- )}`,
117
- );
137
+ outro('Success 🎉.');
138
+ };
118
139
 
119
- outro('Success 🎉.');
120
- },
140
+ export const pluginBrownfieldIos =
141
+ (pluginConfig?: IOSProjectConfig) =>
142
+ (api: PluginApi): PluginOutput => {
143
+ api.registerCommand({
144
+ name: 'package:ios',
145
+ description: 'Emit a .xcframework file from React Native code.',
146
+ action: async (args: BuildFlags) =>
147
+ packageIosAction(
148
+ args,
149
+ {
150
+ projectRoot: api.getProjectRoot(),
151
+ reactNativePath: api.getReactNativePath(),
152
+ reactNativeVersion: api.getReactNativeVersion(),
153
+ usePrebuiltRNCore: api.getUsePrebuiltRNCore(),
154
+ },
155
+ pluginConfig,
156
+ ),
121
157
  options: buildOptions,
122
158
  });
123
159
 
@@ -7,6 +7,6 @@
7
7
  "@callstack/react-native-brownfield": "^2.0.0"
8
8
  },
9
9
  "devDependencies": {
10
- "@rock-js/plugin-brownfield-ios": "^0.12.4"
10
+ "@rock-js/plugin-brownfield-ios": "^0.12.6"
11
11
  }
12
12
  }