Skip to content

Static config #20

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 1 commit into from
Aug 6, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ $injector.requireCommand("build", "./commands/build");

$injector.require("npm", "./node-package-manager");
$injector.require("propertiesParser", "./properties-parser");
$injector.require("config", "./config");
16 changes: 16 additions & 0 deletions lib/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
///<reference path=".d.ts"/>

import path = require("path");

export class StaticConfig implements IStaticConfig {
public PROJECT_FILE_NAME = ".tnsproject";
public CLIENT_NAME = "tns";
public ANALYTICS_API_KEY = "";

public version = require("../package.json").version;

public get helpTextPath() {
return path.join(__dirname, "../resources/help.txt");
}
}
$injector.register("staticConfig", StaticConfig);
4 changes: 3 additions & 1 deletion lib/declarations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ interface INodePackageManager {

interface IPropertiesParser {
createEditor(filePath: string): IFuture<any>;
}
}

interface IStaticConfig extends Config.IStaticConfig { }
8 changes: 2 additions & 6 deletions lib/nativescript-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,8 @@ import errors = require("./common/errors");
errors.installUncaughtExceptionListener();

$injector.register("config", {
CI_LOGGER1: false,
PROJECT_FILE_NAME: ".tnsproject",
DEBUG: process.env.NATIVESCRIPT_DEBUG,
version: require("../package.json").version,
helpTextPath: path.join(__dirname, "../resources/help.txt"),
client: "tns"
CI_LOGGER: false,
DEBUG: process.env.NATIVESCRIPT_DEBUG
});

var dispatcher = $injector.resolve("dispatcher");
Expand Down
8 changes: 4 additions & 4 deletions lib/services/project-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ProjectData implements IProjectData {
constructor(private $fs: IFileSystem,
private $errors: IErrors,
private $projectHelper: IProjectHelper,
private $config: IConfig) {
private $staticConfig: IStaticConfig) {
this.initializeProjectData().wait();
}

Expand All @@ -30,7 +30,7 @@ class ProjectData implements IProjectData {
this.projectDir = projectDir;
this.projectName = path.basename(projectDir);
this.platformsDir = path.join(projectDir, "platforms");
this.projectFilePath = path.join(projectDir, this.$config.PROJECT_FILE_NAME);
this.projectFilePath = path.join(projectDir, this.$staticConfig.PROJECT_FILE_NAME);

if (this.$fs.exists(this.projectFilePath).wait()) {
var fileContent = this.$fs.readJson(this.projectFilePath).wait();
Expand All @@ -50,7 +50,7 @@ export class ProjectService implements IProjectService {
private $fs: IFileSystem,
private $projectTemplatesService: IProjectTemplatesService,
private $projectHelper: IProjectHelper,
private $config) { }
private $staticConfig: IStaticConfig) { }

public createProject(projectName: string, projectId: string): IFuture<void> {
return(() => {
Expand Down Expand Up @@ -128,7 +128,7 @@ export class ProjectService implements IProjectService {
this.$fs.createDirectory(path.join(projectDir, "hooks")).wait();

var projectData = { id: projectId };
this.$fs.writeFile(path.join(projectDir, this.$config.PROJECT_FILE_NAME), JSON.stringify(projectData)).wait();
this.$fs.writeFile(path.join(projectDir, this.$staticConfig.PROJECT_FILE_NAME), JSON.stringify(projectData)).wait();
}).future<void>()();
}

Expand Down