-
-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy pathproject.d.ts
532 lines (461 loc) · 19.8 KB
/
project.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
interface IProjectName {
/**
* Name of the newly created application.
*/
projectName: string;
}
interface IProjectSettingsBase extends IProjectName {
/**
* Defines whether the `npm install` command should be executed with `--ignore-scripts` option.
* When it is passed, all scripts (postinstall for example) will not be executed.
*/
ignoreScripts?: boolean;
/**
* Selected template from which to create the project. If not specified, defaults to hello-world template.
* Template can be any npm package, local dir, github url, .tgz file.
* If it is set to `angular` or `ng`, default NativeScript Angular Hello World template will be used.
* If it is set to `typescript` or `tsc`, default NativeScript TypeScript Hello World template will be used.
*/
template?: string;
/**
* Application identifier for the newly created application. If not specified, defaults to org.nativescript.<projectName>.
*/
appId?: string;
}
/**
* Describes information passed to project creation hook (createProject).
*/
interface IProjectCreationSettings extends IProjectSettingsBase, IProjectDir {
}
/**
* Describes available settings when creating new NativeScript application.
*/
interface IProjectSettings extends IProjectSettingsBase {
/**
* Path where the project will be created. If not specified, defaults to current working dir.
*/
pathToProject?: string;
/**
* Defines if invalid application name can be used for project creation.
*/
force?: boolean;
}
interface ICreateProjectData extends IProjectDir, IProjectName {
}
interface IProjectService {
validateProjectName(opts: { projectName: string, force: boolean, pathToProject: string }) : Promise<string>
/**
* Creates new NativeScript application.
* @param {any} projectSettings Options describing new project - its name, appId, path and template from which to be created.
* @returns {Promise<void>}
*/
createProject(projectSettings: IProjectSettings): Promise<ICreateProjectData>;
/**
* Checks if the specified project is valid NativeScript project.
* @param {string} pathToProject Directory to check.
* @returns {boolean} returns true if the project is valid NativeScript project.
*/
isValidNativeScriptProject(pathToProject?: string): boolean;
}
interface INsConfig {
appPath?: string;
appResourcesPath?: string;
shared?: boolean;
}
interface IProjectData extends ICreateProjectData {
platformsDir: string;
projectFilePath: string;
projectId: string;
projectIdentifiers?: Mobile.IProjectIdentifier;
dependencies: any;
devDependencies: IStringDictionary;
appDirectoryPath: string;
appResourcesDirectoryPath: string;
projectType: string;
nsConfig: INsConfig;
androidManifestPath: string;
appGradlePath: string;
gradleFilesDirectoryPath: string;
infoPlistPath: string;
buildXcconfigPath: string;
podfilePath: string;
/**
* Defines if the project is a code sharing one.
* Value is true when project has nsconfig.json and it has `shared: true` in it.
*/
isShared: boolean;
/**
* Initializes project data with the given project directory. If none supplied defaults to --path option or cwd.
* @param {string} projectDir Project root directory.
* @returns {void}
*/
initializeProjectData(projectDir?: string): void;
initializeProjectDataFromContent(packageJsonContent: string, nsconfigContent: string, projectDir?: string): void;
getAppDirectoryPath(projectDir?: string): string;
getAppDirectoryRelativePath(): string;
getAppResourcesDirectoryPath(projectDir?: string): string;
getAppResourcesRelativeDirectoryPath(): string;
}
interface IProjectDataService {
/**
* Returns a value from `nativescript` key in project's package.json.
* @param {string} projectDir The project directory - the place where the root package.json is located.
* @param {string} propertyName The name of the property to be checked in `nativescript` key.
* @returns {any} The value of the property.
*/
getNSValue(projectDir: string, propertyName: string): any;
/**
* Sets a value in the `nativescript` key in a project's package.json.
* @param {string} projectDir The project directory - the place where the root package.json is located.
* @param {string} key Key to be added to `nativescript` key in project's package.json.
* @param {any} value Value of the key to be added to `nativescript` key in project's package.json.
* @returns {void}
*/
setNSValue(projectDir: string, key: string, value: any): void;
/**
* Removes a property from `nativescript` key in project's package.json.
* @param {string} projectDir The project directory - the place where the root package.json is located.
* @param {string} propertyName The name of the property to be removed from `nativescript` key.
* @returns {void}
*/
removeNSProperty(projectDir: string, propertyName: string): void;
/**
* Removes dependency from package.json
* @param {string} projectDir The project directory - the place where the root package.json is located.
* @param {string} dependencyName Name of the dependency that has to be removed.
* @returns {void}
*/
removeDependency(projectDir: string, dependencyName: string): void;
getProjectData(projectDir?: string): IProjectData;
/**
* Gives information about the whole assets structure for both iOS and Android.
* For each of the platforms, the returned object will contain icons, splashBackgrounds, splashCenterImages and splashImages (only for iOS).
* @param {IProjectDir} opts Object with a single property - projectDir. This is the root directory where NativeScript project is located.
* @returns {Promise<IAssetsStructure>} An object describing the current asset structure.
*/
getAssetsStructure(opts: IProjectDir): Promise<IAssetsStructure>;
/**
* Gives information about the whole assets structure for iOS.
* The returned object will contain icons, splashBackgrounds, splashCenterImages and splashImages.
* @param {IProjectDir} opts Object with a single property - projectDir. This is the root directory where NativeScript project is located.
* @returns {Promise<IAssetGroup>} An object describing the current asset structure for iOS.
*/
getIOSAssetsStructure(opts: IProjectDir): Promise<IAssetGroup>;
/**
* Gives information about the whole assets structure for Android.
* The returned object will contain icons, splashBackgrounds and splashCenterImages.
* @param {IProjectDir} opts Object with a single property - projectDir. This is the root directory where NativeScript project is located.
* @returns {Promise<IAssetGroup>} An object describing the current asset structure for Android.
*/
getAndroidAssetsStructure(opts: IProjectDir): Promise<IAssetGroup>;
}
interface IAssetItem {
path: string;
size: string;
width: number;
height: number;
filename: string;
directory: string;
scale: string;
idiom: string;
resizeOperation?: string;
overlayImageScale?: number;
}
interface IAssetSubGroup {
images: IAssetItem[];
info?: { version: string, author: string };
[imageType: string]: any;
}
interface IAssetGroup {
icons: IAssetSubGroup;
splashBackgrounds: IAssetSubGroup;
splashCenterImages: IAssetSubGroup;
splashImages?: IAssetSubGroup;
[imageType: string]: IAssetSubGroup;
}
interface IAssetsStructure {
ios: IAssetGroup;
android: IAssetGroup;
}
interface IImageDefinitionGroup {
icons: IAssetItem[];
splashBackgrounds: IAssetItem[];
splashCenterImages: IAssetItem[];
splashImages?: IAssetItem[];
}
interface IImageDefinitionsStructure {
ios: IImageDefinitionGroup;
android: IImageDefinitionGroup;
}
interface ITemplateData {
/**
* The normalized template name
* In case no --template option is provided, use default template name
* In case --template <templateName> option is provided, use <templateName>
* In case --template <templateName>@<version> is provided, use <templateName>
* In case --ng option is provided, use default angular template name
* In case --ts option is provided, use default typescript template name
*/
templateName: string;
/**
* The path to the template.
* In case template is v1, will be {pathToProjectDir}/node_modules/{templateName}.
* In case template is v2, will be null.
*/
templatePath: string;
/**
* The templateVersion property from nativescript section inside package.json file
* "nativescript": {
"id": "org.nativescript.app6",
"templateVersion": "v2"
}
*/
templateVersion: string;
/**
* The whole content of package.json file
*/
templatePackageJsonContent: ITemplatePackageJsonContent;
/**
* The version of the package used for creating the application.
*/
version: string;
}
interface ITemplatePackageJsonContent extends IBasePluginData {
dependencies: IStringDictionary;
devDependencies: IStringDictionary;
nativescript?: {
templateVersion?: string;
}
}
/**
* Describes working with templates.
*/
interface IProjectTemplatesService {
/**
* Prepares template for project creation.
* In case templateName is not provided, use defaultTemplatePath.
* In case templateName is a special word, validated from us (for ex. typescript), resolve the real template name and add it to npm cache.
* In any other cases try to `npm install` the specified templateName to temp directory.
* @param {string} templateName The name of the template.
* @return {ITemplateData} Data describing the template - location where it is installed and its NativeScript version.
*/
prepareTemplate(templateName: string, projectDir: string): Promise<ITemplateData>;
}
interface IPlatformProjectServiceBase {
getPluginPlatformsFolderPath(pluginData: IPluginData, platform: string): string;
getFrameworkVersion(projectData: IProjectData): string;
}
interface IBuildForDevice {
buildForDevice: boolean;
}
interface INativePrepare {
skipNativePrepare: boolean;
}
interface IBuildConfig extends IAndroidBuildOptionsSettings, IiOSBuildConfig, IProjectDir {
clean?: boolean;
architectures?: string[];
buildOutputStdio?: string;
}
/**
* Describes iOS-specific build configuration properties
*/
interface IiOSBuildConfig extends IBuildForDevice, IDeviceIdentifier, IProvision, ITeamIdentifier, IRelease {
/**
* Identifier of the mobile provision which will be used for the build. If not set a provision will be selected automatically if possible.
*/
mobileProvisionIdentifier?: string;
/**
* Code sign identity used for build. If not set iPhone Developer is used as a default when building for device.
*/
codeSignIdentity?: string;
}
/**
* Describes service used for building a project locally.
*/
interface ILocalBuildService {
/**
* Builds a project locally.
* @param {string} platform Platform for which to build.
* @param {IPlatformBuildData} platformBuildOptions Additional options for controlling the build.
* @param {string} platformTemplate The name of the template.
* @return {Promise<string>} Path to the build output.
*/
build(platform: string, platformBuildOptions: IPlatformBuildData, platformTemplate?: string): Promise<string>;
/**
* Removes build artifacts specific to the platform
* @param {ICleanNativeAppData} data Data describing the clean app process
* @returns {void}
*/
cleanNativeApp(data: ICleanNativeAppData): Promise<void>;
}
interface ICleanNativeAppData extends IProjectDir, IPlatform { }
interface IPlatformProjectService extends NodeJS.EventEmitter, IPlatformProjectServiceBase {
getPlatformData(projectData: IProjectData): IPlatformData;
validate(projectData: IProjectData, options: IOptions, notConfiguredEnvOptions?: INotConfiguredEnvOptions): Promise<IValidatePlatformOutput>;
createProject(frameworkDir: string, frameworkVersion: string, projectData: IProjectData, config: ICreateProjectOptions): Promise<void>;
interpolateData(projectData: IProjectData, platformSpecificData: IPlatformSpecificData): Promise<void>;
interpolateConfigurationFile(projectData: IProjectData, platformSpecificData: IPlatformSpecificData): void;
/**
* Executes additional actions after native project is created.
* @param {string} projectRoot Path to the real NativeScript project.
* @param {IProjectData} projectData DTO with information about the project.
* @returns {void}
*/
afterCreateProject(projectRoot: string, projectData: IProjectData): void;
/**
* Gets first chance to validate the options provided as command line arguments.
* @param {string} projectId Project identifier - for example org.nativescript.test.
* @param {any} provision UUID of the provisioning profile used in iOS option validation.
* @returns {void}
*/
validateOptions(projectId?: string, provision?: true | string, teamId?: true | string): Promise<boolean>;
validatePlugins(projectData: IProjectData): Promise<void>;
buildProject(projectRoot: string, projectData: IProjectData, buildConfig: IBuildConfig): Promise<void>;
/**
* Prepares images in Native project (for iOS).
* @param {IProjectData} projectData DTO with information about the project.
* @param {any} platformSpecificData Platform specific data required for project preparation.
* @returns {void}
*/
prepareProject(projectData: IProjectData, platformSpecificData: IPlatformSpecificData): Promise<void>;
/**
* Prepares App_Resources in the native project by clearing data from other platform and applying platform specific rules.
* @param {string} appResourcesDirectoryPath The place in the native project where the App_Resources are copied first.
* @param {IProjectData} projectData DTO with information about the project.
* @returns {void}
*/
prepareAppResources(appResourcesDirectoryPath: string, projectData: IProjectData): void;
/**
* Defines if current platform is prepared (i.e. if <project dir>/platforms/<platform> dir exists).
* @param {string} projectRoot The project directory (path where root's package.json is located).
* @param {IProjectData} projectData DTO with information about the project.
* @returns {boolean} True in case platform is prepare (i.e. if <project dir>/platforms/<platform> dir exists), false otherwise.
*/
isPlatformPrepared(projectRoot: string, projectData: IProjectData): boolean;
/**
* Checks if current platform can be updated to a newer versions.
* @param {string} newInstalledModuleDir Path to the native project.
* @param {IProjectData} projectData DTO with information about the project.
* @return {boolean} True if platform can be updated. false otherwise.
*/
canUpdatePlatform(newInstalledModuleDir: string, projectData: IProjectData): boolean;
preparePluginNativeCode(pluginData: IPluginData, options?: any): Promise<void>;
/**
* Removes native code of a plugin (CocoaPods, jars, libs, src).
* @param {IPluginData} Plugins data describing the plugin which should be cleaned.
* @param {IProjectData} projectData DTO with information about the project.
* @returns {void}
*/
removePluginNativeCode(pluginData: IPluginData, projectData: IProjectData): Promise<void>;
afterPrepareAllPlugins(projectData: IProjectData): Promise<void>;
beforePrepareAllPlugins(projectData: IProjectData, dependencies?: IDependencyData[]): Promise<void>;
/**
* Gets the path wheren App_Resources should be copied.
* @returns {string} Path to native project, where App_Resources should be copied.
*/
getAppResourcesDestinationDirectoryPath(projectData: IProjectData): string;
cleanDeviceTempFolder(deviceIdentifier: string, projectData: IProjectData): Promise<void>;
processConfigurationFilesFromAppResources(projectData: IProjectData, opts: { release: boolean, installPods: boolean }): Promise<void>;
/**
* Ensures there is configuration file (AndroidManifest.xml, Info.plist) in app/App_Resources.
* @param {IProjectData} projectData DTO with information about the project.
* @returns {void}
*/
ensureConfigurationFileInAppResources(projectData: IProjectData): void;
/**
* Stops all running processes that might hold a lock on the filesystem.
* Android: Gradle daemon processes are terminated.
* @param {string} projectRoot The root directory of the native project.
* @returns {void}
*/
stopServices(projectRoot: string): Promise<ISpawnResult>;
/**
* Removes build artifacts specific to the platform
* @param {string} projectRoot The root directory of the native project.
* @param {IProjectData} projectData DTO with information about the project.
* @returns {void}
*/
cleanProject(projectRoot: string, projectData: IProjectData): Promise<void>
/**
* Check the current state of the project, and validate against the options.
* If there are parts in the project that are inconsistent with the desired options, marks them in the changeset flags.
*/
checkForChanges(changeset: IProjectChangesInfo, options: IProjectChangesOptions, projectData: IProjectData): Promise<void>;
/**
* Build native part of a nativescript plugins if necessary
*/
prebuildNativePlugin(buildOptions: IPluginBuildOptions): Promise<void>;
/**
* Traverse through the production dependencies and find plugins that need build/rebuild
*/
checkIfPluginsNeedBuild(projectData: IProjectData): Promise<Array<any>>;
/**
* Get the deployment target's version
* Currently implemented only for iOS -> returns the value of IPHONEOS_DEPLOYMENT_TARGET property from xcconfig file
*/
getDeploymentTarget(projectData: IProjectData): any;
}
interface IValidatePlatformOutput {
checkEnvironmentRequirementsOutput: ICheckEnvironmentRequirementsOutput;
}
interface ITestExecutionService {
startTestRunner(platform: string, projectData: IProjectData, projectFilesConfig: IProjectFilesConfig): Promise<void>;
startKarmaServer(platform: string, projectData: IProjectData, projectFilesConfig: IProjectFilesConfig): Promise<void>;
}
/**
* Describes a service used to facilitate communication with CocoaPods
*/
interface ICocoaPodsService {
/**
* Get the header needed for the beginning of every Podfile
* @param {string} targetName The name of the target (usually the same as the project's name).
* @return {string} The header which needs to be placed at the beginning of a Podfile.
*/
getPodfileHeader(targetName: string): string;
/**
* Get the footer needed for the end of every Podfile
* @return {string} The footer which needs to be placed at the end of a Podfile.
*/
getPodfileFooter(): string;
/**
* Prepares the Podfile content of a plugin and merges it in the project's Podfile.
* @param {string} moduleName The module which the Podfile is from.
* @param {string} podfilePath The path to the podfile.
* @param {IProjectData} projectData Information about the project.
* @param {string} nativeProjectPath Path to the native Xcode project.
* @returns {Promise<void>}
*/
applyPodfileToProject(moduleName: string, podfilePath: string, projectData: IProjectData, nativeProjectPath: string): Promise<void>;
/**
* Gives the path to the plugin's Podfile.
* @param {IPluginData} pluginData Information about the plugin.
* @returns {string} Path to plugin's Podfile
*/
getPluginPodfilePath(pluginData: IPluginData): string;
/**
* Removes plugins Podfile content from the project.
* @param {string} moduleName The name of the module.
* @param {string} podfilePath The path to the module's Podfile.
* @param {string} projectData Information about the project.
* @param {string} nativeProjectPath Path to the native Xcode project.
* @returns {void}
*/
removePodfileFromProject(moduleName: string, podfilePath: string, projectData: IProjectData, nativeProjectPath: string): void;
/**
* Gives the path to project's Podfile.
* @param {string} nativeProjectPath Path to the native Xcode project.
* @returns {string} Path to project's Podfile.
*/
getProjectPodfilePath(nativeProjectPath: string): string;
/**
* Executes `pod install` or `sanboxpod install` in the passed project.
* @param {string} projectRoot The root directory of the native iOS project.
* @param {string} xcodeProjPath The full path to the .xcodeproj file.
* @returns {Promise<ISpawnResult>} Information about the spawned process.
*/
executePodInstall(projectRoot: string, xcodeProjPath: string): Promise<ISpawnResult>;
}
interface IRubyFunction {
functionName: string;
functionParameters?: string;
}