@react-native-community/cli-types 7.0.0 → 7.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-community/cli-types",
3
- "version": "7.0.0",
3
+ "version": "7.0.1",
4
4
  "main": "build",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -16,6 +16,5 @@
16
16
  "type": "git",
17
17
  "url": "https://github.com/react-native-community/cli.git",
18
18
  "directory": "packages/cli-types"
19
- },
20
- "gitHead": "fcb746c46e6dc05225a26ab132ab380c841c849f"
19
+ }
21
20
  }
package/src/android.ts ADDED
@@ -0,0 +1,30 @@
1
+ export interface AndroidProjectConfig {
2
+ sourceDir: string;
3
+ isFlat: boolean;
4
+ folder: string;
5
+ stringsPath: string;
6
+ manifestPath: string;
7
+ buildGradlePath: string;
8
+ settingsGradlePath: string;
9
+ assetsPath: string;
10
+ mainFilePath: string;
11
+ packageName: string;
12
+ packageFolder: string;
13
+ appName: string;
14
+ dependencyConfiguration?: string;
15
+ }
16
+
17
+ export type AndroidProjectParams = Partial<AndroidProjectConfig>;
18
+
19
+ export interface AndroidDependencyConfig {
20
+ sourceDir: string;
21
+ folder: string;
22
+ packageImportPath: string;
23
+ packageInstance: string;
24
+ manifestPath: string;
25
+ packageName: string;
26
+ dependencyConfiguration?: string;
27
+ buildTypes: string[];
28
+ }
29
+
30
+ export type AndroidDependencyParams = Partial<AndroidDependencyConfig>;
package/src/index.ts ADDED
@@ -0,0 +1,198 @@
1
+ import {
2
+ IOSProjectConfig,
3
+ IOSProjectParams,
4
+ IOSDependencyConfig,
5
+ IOSDependencyParams,
6
+ IOSNativeModulesConfig,
7
+ } from './ios';
8
+ import {
9
+ AndroidProjectConfig,
10
+ AndroidProjectParams,
11
+ AndroidDependencyConfig,
12
+ AndroidDependencyParams,
13
+ } from './android';
14
+
15
+ export type Prompt = any;
16
+
17
+ export type CommandFunction<Args = Object> = (
18
+ argv: Array<string>,
19
+ ctx: Config,
20
+ args: Args,
21
+ ) => Promise<void> | void;
22
+
23
+ export type OptionValue = string | boolean | number;
24
+
25
+ export type CommandOption<T = (ctx: Config) => OptionValue> = {
26
+ name: string;
27
+ description?: string;
28
+ parse?: (val: string) => any;
29
+ default?: OptionValue | T;
30
+ };
31
+
32
+ export type DetachedCommandFunction<Args = Object> = (
33
+ argv: string[],
34
+ args: Args,
35
+ ) => Promise<void> | void;
36
+
37
+ export type Command<IsDetached extends boolean = false> = {
38
+ name: string;
39
+ description?: string;
40
+ detached?: IsDetached;
41
+ examples?: Array<{
42
+ desc: string;
43
+ cmd: string;
44
+ }>;
45
+ pkg?: {
46
+ name: string;
47
+ version: string;
48
+ };
49
+ func: IsDetached extends true
50
+ ? DetachedCommandFunction<Object>
51
+ : CommandFunction<Object>;
52
+ options?: Array<
53
+ CommandOption<
54
+ IsDetached extends true ? () => OptionValue : (ctx: Config) => OptionValue
55
+ >
56
+ >;
57
+ };
58
+
59
+ export type DetachedCommand = Command<true>;
60
+
61
+ interface PlatformConfig<
62
+ ProjectConfig,
63
+ ProjectParams,
64
+ DependencyConfig,
65
+ DependencyParams
66
+ > {
67
+ npmPackageName?: string;
68
+ projectConfig: (
69
+ projectRoot: string,
70
+ projectParams: ProjectParams | void,
71
+ ) => ProjectConfig | void;
72
+ dependencyConfig: (
73
+ dependency: string,
74
+ params: DependencyParams,
75
+ ) => DependencyConfig | void;
76
+ linkConfig: () => {
77
+ isInstalled: (
78
+ projectConfig: ProjectConfig,
79
+ packageName: string,
80
+ dependencyConfig: DependencyConfig,
81
+ ) => boolean;
82
+ register: (
83
+ name: string,
84
+ dependencyConfig: DependencyConfig,
85
+ params: Object,
86
+ projectConfig: ProjectConfig,
87
+ ) => void;
88
+ unregister: (
89
+ name: string,
90
+ dependencyConfig: DependencyConfig,
91
+ projectConfig: ProjectConfig,
92
+ otherDependencies: Array<DependencyConfig>,
93
+ ) => void;
94
+ copyAssets: (assets: string[], projectConfig: ProjectConfig) => void;
95
+ unlinkAssets: (assets: string[], projectConfig: ProjectConfig) => void;
96
+ };
97
+ }
98
+
99
+ export interface Dependency {
100
+ name: string;
101
+ root: string;
102
+ platforms: {
103
+ android?: AndroidDependencyConfig | null;
104
+ ios?: IOSDependencyConfig | null;
105
+ [key: string]: any;
106
+ };
107
+ assets: string[];
108
+ hooks: {
109
+ prelink?: string;
110
+ postlink?: string;
111
+ preunlink?: string;
112
+ postunlink?: string;
113
+ };
114
+ params: Prompt[];
115
+ }
116
+
117
+ export type ProjectConfig = {
118
+ android?: AndroidProjectConfig;
119
+ ios?: IOSProjectConfig;
120
+ [key: string]: any;
121
+ };
122
+
123
+ /**
124
+ * @property root - Root where the configuration has been resolved from
125
+ * @property reactNativePath - Path to React Native source
126
+ * @property project - Object that contains configuration for a project (null, when platform not available)
127
+ * @property assets - An array of assets as defined by the user
128
+ * @property dependencies - Map of the dependencies that are present in the project
129
+ * @property platforms - Map of available platforms (build-ins and dynamically loaded)
130
+ * @property commands - An array of commands that are present in 3rd party packages
131
+ * @property healthChecks - An array of health check categories to add to doctor command
132
+ */
133
+ export interface Config extends IOSNativeModulesConfig {
134
+ root: string;
135
+ reactNativePath: string;
136
+ project: ProjectConfig;
137
+ assets: string[];
138
+ dependencies: {[key: string]: Dependency};
139
+ platforms: {
140
+ android: PlatformConfig<
141
+ AndroidProjectConfig,
142
+ AndroidProjectParams,
143
+ AndroidDependencyConfig,
144
+ AndroidDependencyParams
145
+ >;
146
+ ios: PlatformConfig<
147
+ IOSProjectConfig,
148
+ IOSProjectParams,
149
+ IOSDependencyConfig,
150
+ IOSDependencyParams
151
+ >;
152
+ [name: string]: PlatformConfig<any, any, any, any>;
153
+ };
154
+ commands: Command[];
155
+ // @todo this should be removed: https://github.com/react-native-community/cli/issues/1261
156
+ healthChecks: [];
157
+ }
158
+
159
+ /**
160
+ * Shares some structure with Config, except that root is calculated and can't
161
+ * be defined
162
+ */
163
+
164
+ export type UserConfig = Omit<Config, 'root'> & {
165
+ reactNativePath: string | void;
166
+ // Additional project settings
167
+ project: {
168
+ android?: AndroidProjectParams;
169
+ ios?: IOSProjectParams;
170
+ [key: string]: any;
171
+ };
172
+ };
173
+
174
+ export type UserDependencyConfig = {
175
+ // Additional dependency settings
176
+ dependency: Omit<Dependency, 'name' | 'root'>;
177
+ // An array of commands that ship with the dependency
178
+ commands: Command[];
179
+ // An array of extra platforms to load
180
+ platforms: Config['platforms'];
181
+ // Additional health checks
182
+ healthChecks: [];
183
+ };
184
+
185
+ export {
186
+ IOSProjectConfig,
187
+ IOSProjectParams,
188
+ IOSDependencyConfig,
189
+ IOSDependencyParams,
190
+ IOSNativeModulesConfig,
191
+ };
192
+
193
+ export {
194
+ AndroidProjectConfig,
195
+ AndroidProjectParams,
196
+ AndroidDependencyConfig,
197
+ AndroidDependencyParams,
198
+ };
package/src/ios.ts ADDED
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Settings that user can define in the project configuration for iOS.
3
+ * Same for dependency - we share the type.
4
+ *
5
+ * See UserDependencyConfigT and UserConfigT for details
6
+ */
7
+ export interface IOSProjectParams {
8
+ project?: string;
9
+ /**
10
+ * @deprecated A podspec should always be at the root of a package and
11
+ * have the name of the package. This property will be
12
+ * removed in a future major version.
13
+ *
14
+ * @todo Log a warning when this is used.
15
+ */
16
+ podspecPath?: string;
17
+ sharedLibraries?: string[];
18
+ libraryFolder?: string;
19
+ plist: Array<any>;
20
+ scriptPhases?: Array<any>;
21
+ }
22
+
23
+ export interface IOSDependencyParams extends IOSProjectParams {
24
+ configurations?: string[];
25
+ }
26
+
27
+ // The following types are used in untyped-parts of the codebase, so I am leaving them
28
+ // until we actually need them.
29
+ export interface IOSProjectConfig {
30
+ sourceDir: string;
31
+ folder: string;
32
+ pbxprojPath: string;
33
+ podfile: string;
34
+ podspecPath: string;
35
+ projectPath: string;
36
+ projectName: string;
37
+ libraryFolder: string;
38
+ sharedLibraries: Array<any>;
39
+ plist: Array<any>;
40
+ }
41
+
42
+ export interface IOSDependencyConfig extends IOSProjectConfig {
43
+ configurations: string[];
44
+ }
45
+
46
+ /**
47
+ * @see https://www.rubydoc.info/gems/cocoapods-core/Pod/Podfile/DSL#script_phase-instance_method
48
+ *
49
+ * The only difference is that `script` may be omitted in favour of a
50
+ * `path`, relative to the root of the package, whose content will be
51
+ * used.
52
+ */
53
+ export type IOSScriptPhase = ({script: string} | {path: string}) & {
54
+ name: string;
55
+ shell_path?: string;
56
+ input_files?: string[];
57
+ output_files?: string[];
58
+ input_file_lists?: string[];
59
+ output_file_lists?: string[];
60
+ show_env_vars_in_log?: boolean;
61
+ dependency_file?: string;
62
+ execution_position?: 'before_compile' | 'after_compile' | 'any';
63
+ };
64
+
65
+ /**
66
+ * This describes the data that is expected by `native_modules.rb`. It is only
67
+ * meant to ensure the `Config` interface follows exactly what is needed, so
68
+ * only make changes to this interface (or `IOSScriptPhase`) if the data
69
+ * requirements of `native_modules.rb` change.
70
+ */
71
+ export interface IOSNativeModulesConfig {
72
+ reactNativePath: string;
73
+ project: {
74
+ ios?: {
75
+ sourceDir: string;
76
+ };
77
+ };
78
+ dependencies: {
79
+ [name: string]: {
80
+ root: string;
81
+ platforms: {
82
+ ios?: null | {
83
+ /**
84
+ * @deprecated A podspec should always be at the root of a package and
85
+ * have the name of the package. This property will be
86
+ * removed in a future major version.
87
+ *
88
+ * @todo Log a warning when this is used.
89
+ */
90
+ podspecPath: string;
91
+ scriptPhases?: Array<IOSScriptPhase>;
92
+ };
93
+ android?: null | {};
94
+ };
95
+ };
96
+ };
97
+ }
@@ -0,0 +1,66 @@
1
+ // https://github.com/antelle/node-stream-zip/issues/36#issuecomment-596249657
2
+ declare module 'node-stream-zip' {
3
+ import {Stream} from 'stream';
4
+
5
+ interface StreamZipOptions {
6
+ /**
7
+ * File to read
8
+ */
9
+ file: string;
10
+ /**
11
+ * You will be able to work with entries inside zip archive, otherwise the only way to access them is entry event
12
+ *
13
+ * default: true
14
+ */
15
+ storeEntries?: boolean;
16
+ /**
17
+ * By default, entry name is checked for malicious characters, like ../ or c:\123, pass this flag to disable validation errors
18
+ *
19
+ * default: false
20
+ */
21
+ skipEntryNameValidation?: boolean;
22
+ /**
23
+ * Undocumented adjustment of chunk size
24
+ *
25
+ * default: automatic
26
+ */
27
+ chunkSize?: number;
28
+ }
29
+
30
+ class ZipEntry {
31
+ name: string;
32
+ isDirectory: boolean;
33
+ isFile: boolean;
34
+ comment: string;
35
+ size: number;
36
+ }
37
+
38
+ class StreamZip {
39
+ constructor(config: StreamZipOptions);
40
+
41
+ on(event: 'ready', handler: () => void): void;
42
+
43
+ entry(entry: string): ZipEntry;
44
+ entries(): ZipEntry[];
45
+
46
+ entriesCount: number;
47
+
48
+ stream(
49
+ entry: string,
50
+ callback: (err: any | null, stream?: Stream) => void,
51
+ ): void;
52
+ entryDataSync(entry: string): Buffer;
53
+ openEntry(
54
+ entry: string,
55
+ callback: (err: any | null, entry?: ZipEntry) => void,
56
+ sync: boolean,
57
+ ): void;
58
+ extract(
59
+ entry: string | null,
60
+ outPath: string,
61
+ callback: (err?: any) => void,
62
+ ): void;
63
+ close(callback?: (err?: any) => void): void;
64
+ }
65
+ export = StreamZip;
66
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "rootDir": "src",
5
+ "outDir": "build"
6
+ }
7
+ }