@@ -11,6 +11,9 @@ const tns = require("nativescript");
11
11
* [ projectService] ( #projectservice )
12
12
* [createProject](#createproject)
13
13
* [isValidNativeScriptProject](#isvalidnativescriptproject)
14
+ * [ projectDataService] ( #projectdataservice )
15
+ * [getProjectData](#getprojectdata)
16
+ * [getProjectDataFromContent](#getprojectdatafromcontent)
14
17
* [ extensibilityService] ( #extensibilityservice )
15
18
* [installExtension](#installextension)
16
19
* [uninstallExtension](#uninstallextension)
@@ -109,6 +112,81 @@ const isValidProject = tns.projectService.isValidNativeScriptProject("/tmp/myPro
109
112
console .log (isValidProject); // true or false
110
113
` ` `
111
114
115
+ ## projectDataService
116
+ ` projectDataService` provides a way to get information about a NativeScript project.
117
+
118
+ A common interface describing the results of a method is ` IProjectData` :
119
+
120
+ ` ` ` TypeScript
121
+ interface IProjectData extends IProjectDir {
122
+ projectName: string;
123
+ platformsDir: string;
124
+ projectFilePath: string;
125
+ projectId?: string;
126
+ dependencies: any;
127
+ devDependencies: IStringDictionary;
128
+ appDirectoryPath: string;
129
+ appResourcesDirectoryPath: string;
130
+ projectType: string;
131
+ nsConfig: INsConfig;
132
+ /**
133
+ * Initializes project data with the given project directory. If none supplied defaults to cwd.
134
+ * @param {string} projectDir Project root directory.
135
+ * @returns {void}
136
+ */
137
+ initializeProjectData (projectDir?: string): void ;
138
+ /**
139
+ * Initializes project data with the given package.json, nsconfig.json content and project directory. If none supplied defaults to cwd.
140
+ * @param {string} packageJsonContent : string
141
+ * @param {string} nsconfigContent : string
142
+ * @param {string} projectDir Project root directory.
143
+ * @returns {void}
144
+ */
145
+ initializeProjectDataFromContent (packageJsonContent: string, nsconfigContent: string, projectDir?: string): void ;
146
+ getAppDirectoryPath (projectDir?: string): string;
147
+ getAppDirectoryRelativePath (): string;
148
+ getAppResourcesDirectoryPath (projectDir?: string): string;
149
+ getAppResourcesRelativeDirectoryPath (): string;
150
+ }
151
+
152
+ interface IProjectDir {
153
+ projectDir: string;
154
+ }
155
+
156
+ interface INsConfig {
157
+ appPath?: string;
158
+ appResourcesPath?: string;
159
+ }
160
+ ` ` `
161
+
162
+ ### getProjectData
163
+ Returns an initialized IProjectData object containing data about the NativeScript project in the provided ` projectDir` .
164
+
165
+ * Definition:
166
+ ` ` ` TypeScript
167
+ /**
168
+ * Returns an initialized IProjectData object containing data about the NativeScript project in the provided projectDir
169
+ * @param {string} projectDir The path to the project
170
+ * @returns {IProjectData} Information about the NativeScript project
171
+ */
172
+ getProjectData (projectDir: string): IProjectData
173
+ ` ` `
174
+
175
+ ### getProjectDataFromContent
176
+ Returns an IProjectData object that is initialized with the provided package.json content, nsconfig.json content and ` projectDir` .
177
+
178
+ * Definition:
179
+ ` ` ` TypeScript
180
+ /**
181
+ * Returns an initialized IProjectData object containing data about the NativeScript project in the provided projectDir
182
+ * @param {string} packageJsonContent The content of the project.json file in the root of the project
183
+ * @param {string} nsconfigContent The content of the nsconfig.json file in the root of the project
184
+ * @param {string} projectDir The path to the project
185
+ * @returns {IProjectData} Information about the NativeScript project
186
+ */
187
+ getProjectDataFromContent (packageJsonContent: string, nsconfigContent: string, projectDir?: string): IProjectData
188
+ ` ` `
189
+
112
190
## extensibilityService
113
191
` extensibilityService` module gives access to methods for working with CLI's extensions - list, install, uninstall, load them. The extensions add new functionality to CLI, so once an extension is loaded, all methods added to it's public API are accessible directly through CLI when it is used as a library. Extensions may also add new commands, so they are accessible through command line when using NativeScript CLI.
114
192
0 commit comments