|
14 | 14 | import type {Command} from '@react-native-community/cli-types'; |
15 | 15 | */ |
16 | 16 |
|
17 | | -// React Native shouldn't be exporting itself like this, the Community Template should be be directly |
18 | | -// depending on and injecting: |
| 17 | +// IMPORTANT: This is a routing file only. Do NOT add new command |
| 18 | +// definitions or implementations here. |
| 19 | +// |
| 20 | +// New CLI commands belong in @react-native/community-cli-plugin, and |
| 21 | +// may (temporarily) be imported and registered here. |
| 22 | +// |
| 23 | +// Future state: The Community Template should directly depend on and inject: |
19 | 24 | // - @react-native-community/cli-platform-android |
20 | 25 | // - @react-native-community/cli-platform-ios |
21 | 26 | // - @react-native/community-cli-plugin |
22 | | -// - codegen command should be inhoused into @react-native-community/cli |
23 | | -// |
24 | | -// This is a temporary workaround. |
25 | 27 |
|
26 | 28 | const verbose = Boolean(process.env.DEBUG?.includes('react-native')); |
27 | 29 |
|
@@ -72,126 +74,12 @@ const commands /*: Array<Command> */ = []; |
72 | 74 |
|
73 | 75 | const { |
74 | 76 | bundleCommand, |
| 77 | + codegenCommand, |
| 78 | + spmCommand, |
75 | 79 | startCommand, |
76 | 80 | } = require('@react-native/community-cli-plugin'); |
77 | 81 |
|
78 | | -commands.push(bundleCommand, startCommand); |
79 | | - |
80 | | -const codegenCommand /*: Command */ = { |
81 | | - name: 'codegen', |
82 | | - options: [ |
83 | | - { |
84 | | - name: '--path <path>', |
85 | | - description: 'Path to the React Native project root.', |
86 | | - default: process.cwd(), |
87 | | - }, |
88 | | - { |
89 | | - name: '--platform <string>', |
90 | | - description: |
91 | | - 'Target platform. Supported values: "android", "ios", "all".', |
92 | | - default: 'all', |
93 | | - }, |
94 | | - { |
95 | | - name: '--outputPath <path>', |
96 | | - description: 'Path where generated artifacts will be output to.', |
97 | | - }, |
98 | | - { |
99 | | - name: '--source <string>', |
100 | | - description: 'Whether the script is invoked from an `app` or a `library`', |
101 | | - default: 'app', |
102 | | - }, |
103 | | - ], |
104 | | - func: (argv, config, args) => |
105 | | - require('./scripts/codegen/generate-artifacts-executor').execute( |
106 | | - args.path, |
107 | | - args.platform, |
108 | | - args.outputPath, |
109 | | - args.source, |
110 | | - ), |
111 | | -}; |
112 | | - |
113 | | -commands.push(codegenCommand); |
114 | | - |
115 | | -const spmCommand /*: Command */ = { |
116 | | - name: 'spm [action]', |
117 | | - description: |
118 | | - 'Set up or maintain Swift Package Manager support for the iOS/macOS app. ' + |
119 | | - 'Actions: add, update, deinit, scaffold. With no action: add (or update ' + |
120 | | - 'if SPM is already set up).', |
121 | | - options: [ |
122 | | - { |
123 | | - name: '--version <string>', |
124 | | - description: |
125 | | - 'React Native version (e.g. 0.80.0). Defaults to the version in node_modules/react-native/package.json.', |
126 | | - }, |
127 | | - { |
128 | | - name: '--yes', |
129 | | - description: 'Skip the dirty-pbxproj confirmation prompt.', |
130 | | - }, |
131 | | - { |
132 | | - name: '--xcodeproj <path>', |
133 | | - description: |
134 | | - '[add] Path to the .xcodeproj to inject SPM packages into ' + |
135 | | - '(disambiguates when several exist).', |
136 | | - }, |
137 | | - { |
138 | | - name: '--productName <string>', |
139 | | - description: |
140 | | - '[add] App target to inject into (disambiguates when several exist).', |
141 | | - }, |
142 | | - { |
143 | | - name: '--deintegrate', |
144 | | - description: |
145 | | - '[add] Run `pod deintegrate` and strip React Native from the Podfile ' + |
146 | | - 'before injecting (CocoaPods → SwiftPM migration).', |
147 | | - }, |
148 | | - { |
149 | | - name: '--artifacts <path>', |
150 | | - description: |
151 | | - '[advanced] Local artifact root containing complete debug/ and release/ slots.', |
152 | | - }, |
153 | | - { |
154 | | - name: '--download <string>', |
155 | | - description: |
156 | | - '[advanced] Artifact download policy: auto (default), skip, or force.', |
157 | | - }, |
158 | | - { |
159 | | - name: '--skipCodegen', |
160 | | - description: '[advanced] Skip the react-native codegen step.', |
161 | | - }, |
162 | | - ], |
163 | | - func: async (argv, _config, args) => { |
164 | | - const passthrough /*: Array<string> */ = []; |
165 | | - if (argv[0] != null) { |
166 | | - passthrough.push(argv[0]); |
167 | | - } |
168 | | - const stringOpts /*: Array<[string, string]> */ = [ |
169 | | - ['version', '--version'], |
170 | | - ['productName', '--product-name'], |
171 | | - ['xcodeproj', '--xcodeproj'], |
172 | | - ['artifacts', '--artifacts'], |
173 | | - ['download', '--download'], |
174 | | - ]; |
175 | | - for (const [key, flag] of stringOpts) { |
176 | | - if (args[key] != null) { |
177 | | - passthrough.push(flag, String(args[key])); |
178 | | - } |
179 | | - } |
180 | | - const boolOpts /*: Array<[string, string]> */ = [ |
181 | | - ['skipCodegen', '--skip-codegen'], |
182 | | - ['deintegrate', '--deintegrate'], |
183 | | - ['yes', '--yes'], |
184 | | - ]; |
185 | | - for (const [key, flag] of boolOpts) { |
186 | | - if (args[key]) { |
187 | | - passthrough.push(flag); |
188 | | - } |
189 | | - } |
190 | | - await require('./scripts/setup-apple-spm').main(passthrough); |
191 | | - }, |
192 | | -}; |
193 | | - |
194 | | -commands.push(spmCommand); |
| 82 | +commands.push(bundleCommand, startCommand, spmCommand, codegenCommand); |
195 | 83 |
|
196 | 84 | const config = { |
197 | 85 | commands, |
|
0 commit comments