Skip to content

Commit

Permalink
chore(public api): add projectDataService to public api documentation…
Browse files Browse the repository at this point in the history
… and tests
  • Loading branch information
KristianDD committed Feb 27, 2018
1 parent a824b19 commit b96a8cc
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 0 deletions.
78 changes: 78 additions & 0 deletions PublicAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ const tns = require("nativescript");
* [projectService](#projectservice)
* [createProject](#createproject)
* [isValidNativeScriptProject](#isvalidnativescriptproject)
* [projectDataService](#projectdataservice)
* [getProjectData](#getprojectdata)
* [getProjectDataFromContent](#getprojectdatafromcontent)
* [extensibilityService](#extensibilityservice)
* [installExtension](#installextension)
* [uninstallExtension](#uninstallextension)
Expand Down Expand Up @@ -109,6 +112,81 @@ const isValidProject = tns.projectService.isValidNativeScriptProject("/tmp/myPro
console.log(isValidProject); // true or false
```
## projectDataService
`projectDataService` provides a way to get information about a NativeScript project.
A common interface describing the results of a method is `IProjectData`:
```TypeScript
interface IProjectData extends IProjectDir {
projectName: string;
platformsDir: string;
projectFilePath: string;
projectId?: string;
dependencies: any;
devDependencies: IStringDictionary;
appDirectoryPath: string;
appResourcesDirectoryPath: string;
projectType: string;
nsConfig: INsConfig;
/**
* Initializes project data with the given project directory. If none supplied defaults to cwd.
* @param {string} projectDir Project root directory.
* @returns {void}
*/
initializeProjectData(projectDir?: string): void;
/**
* Initializes project data with the given package.json, nsconfig.json content and project directory. If none supplied defaults to cwd.
* @param {string} packageJsonContent: string
* @param {string} nsconfigContent: string
* @param {string} projectDir Project root directory.
* @returns {void}
*/
initializeProjectDataFromContent(packageJsonContent: string, nsconfigContent: string, projectDir?: string): void;
getAppDirectoryPath(projectDir?: string): string;
getAppDirectoryRelativePath(): string;
getAppResourcesDirectoryPath(projectDir?: string): string;
getAppResourcesRelativeDirectoryPath(): string;
}

interface IProjectDir {
projectDir: string;
}

interface INsConfig {
appPath?: string;
appResourcesPath?:string;
}
```
### getProjectData
Returns an initialized IProjectData object containing data about the NativeScript project in the provided `projectDir`.
* Definition:
```TypeScript
/**
* Returns an initialized IProjectData object containing data about the NativeScript project in the provided projectDir
* @param {string} projectDir The path to the project
* @returns {IProjectData} Information about the NativeScript project
*/
getProjectData(projectDir: string): IProjectData
```
### getProjectDataFromContent
Returns an IProjectData object that is initialized with the provided package.json content, nsconfig.json content and `projectDir`.
* Definition:
```TypeScript
/**
* Returns an initialized IProjectData object containing data about the NativeScript project in the provided projectDir
* @param {string} packageJsonContent The content of the project.json file in the root of the project
* @param {string} nsconfigContent The content of the nsconfig.json file in the root of the project
* @param {string} projectDir The path to the project
* @returns {IProjectData} Information about the NativeScript project
*/
getProjectDataFromContent(packageJsonContent: string, nsconfigContent: string, projectDir?: string): IProjectData
```
## extensibilityService
`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.
Expand Down
1 change: 1 addition & 0 deletions test/nativescript-cli-lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ describe("nativescript-cli-lib", () => {
settingsService: ["setSettings"],
deviceEmitter: null,
projectService: ["createProject", "isValidNativeScriptProject"],
projectDataService: ["getProjectData", "getProjectDataFromContent"],
localBuildService: ["build"],
deviceLogProvider: null,
npm: ["install", "uninstall", "view", "search"],
Expand Down

0 comments on commit b96a8cc

Please sign in to comment.