-
-
Notifications
You must be signed in to change notification settings - Fork 197
Add tracking for the project types that users are creating and working with #2492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { ProjectData } from "../lib/project-data"; | ||
import { Yok } from "../lib/common/yok"; | ||
import { assert } from "chai"; | ||
import * as stubs from "./stubs"; | ||
import * as path from "path"; | ||
|
||
describe("projectData", () => { | ||
const createTestInjector = (): IInjector => { | ||
const testInjector = new Yok(); | ||
|
||
testInjector.register("projectHelper", { | ||
projectDir: null, | ||
sanitizeName: (name: string) => name | ||
}); | ||
|
||
testInjector.register("fs", { | ||
exists: () => true, | ||
readJson: (): any => null | ||
}); | ||
|
||
testInjector.register("staticConfig", { | ||
CLIENT_NAME_KEY_IN_PROJECT_FILE: "nativescript", | ||
PROJECT_FILE_NAME: "package.json" | ||
}); | ||
|
||
testInjector.register("errors", stubs.ErrorsStub); | ||
|
||
testInjector.register("logger", stubs.LoggerStub); | ||
|
||
testInjector.register("options", {}); | ||
|
||
testInjector.register("projectData", ProjectData); | ||
|
||
return testInjector; | ||
}; | ||
|
||
describe("projectType", () => { | ||
|
||
const assertProjectType = (dependencies: any, devDependencies: any, expectedProjecType: string) => { | ||
const testInjector = createTestInjector(); | ||
const fs = testInjector.resolve("fs"); | ||
fs.exists = (filePath: string) => filePath && path.basename(filePath) === "package.json"; | ||
|
||
fs.readJson = () => ({ | ||
nativescript: {}, | ||
dependencies: dependencies, | ||
devDependencies: devDependencies | ||
}); | ||
|
||
const projectHelper: IProjectHelper = testInjector.resolve("projectHelper"); | ||
projectHelper.projectDir = "projectDir"; | ||
|
||
const projectData: IProjectData = testInjector.resolve("projectData"); | ||
assert.deepEqual(projectData.projectType, expectedProjecType); | ||
}; | ||
|
||
it("detects project as Angular when @angular/core exists as dependency", () => { | ||
assertProjectType({ "@angular/core": "*" }, null, "Angular"); | ||
}); | ||
|
||
it("detects project as Angular when nativescript-angular exists as dependency", () => { | ||
assertProjectType({ "nativescript-angular": "*" }, null, "Angular"); | ||
}); | ||
|
||
it("detects project as TypeScript when nativescript-dev-typescript exists as dependency", () => { | ||
assertProjectType(null, { "nativescript-dev-typescript": "*" }, "Pure TypeScript"); | ||
}); | ||
|
||
it("detects project as TypeScript when typescript exists as dependency", () => { | ||
assertProjectType(null, { "typescript": "*" }, "Pure TypeScript"); | ||
}); | ||
|
||
it("detects project as JavaScript when no other project type is detected", () => { | ||
assertProjectType(null, null, "Pure JavaScript"); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing case when template is case sensitive folder.
If the developer uses
App
asoriginalTemplateName
and then usesapp
these can be two different apps. I'm OK with us not supporting this scenario, and either way there aren't such tests, but thought you should know.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact the case is handled - when
originalTemplateName
isapp
, thename
variable will be set toapp
.At this point
templateName
will be set toapp
.At another point, when user passes
--template App
,originalTemplateName
will be set toApp
, thename
variable will be set toApp
and thetemplateName
will be set toApp
again.