1 | # csproj2ts
|
2 |
|
3 | Queries a Visual Studio project file (.csproj, .vbproj, .njsproj, etc.) for TypeScript configuration information. Will also find default config in a `Microsoft.TypeScript.Default.props` file, if referenced by the project.
|
4 |
|
5 | Visual Studio TypeScript settings are documented on the TypeScript wiki [here](http://www.typescriptlang.org/docs/handbook/compiler-options-in-msbuild.html).
|
6 |
|
7 | Tested with latest project configuration settings in TypeScript 2.7.
|
8 |
|
9 | ## Install
|
10 |
|
11 | To install, run `npm install csproj2ts`.
|
12 |
|
13 | This module only *collects* the information. What you do with it after is up to you.
|
14 |
|
15 | ## Example Usage:
|
16 | ```javascript
|
17 |
|
18 | var csproj2ts = require('csproj2ts');
|
19 |
|
20 | var vsProjInfo = {
|
21 | ProjectFileName: "path/to/my/project.csproj", // the name and path to the project file
|
22 | ActiveConfiguration: "Release" // the MSBuild config to query
|
23 | }
|
24 |
|
25 | csproj2ts.getTypeScriptSettings(vsProjInfo).then(function (settings) {
|
26 | console.log(settings.files); // will output the array of files
|
27 | console.log(settings.RemoveComments); // will output true or false.
|
28 | console.log(settings.OutDir); // will output the OutDir string or undefined.
|
29 | console.log(settings); // will output all identified configuration.
|
30 | });
|
31 |
|
32 | ```
|
33 |
|
34 | ## Developing:
|
35 |
|
36 | You must run `npm install` to fetch dependencies prior to developing or testing csproj2ts.
|
37 |
|
38 | To build, run `grunt`.
|
39 |
|
40 | To build and run tests with nodeunit, run `grunt test`.
|
41 |
|
42 | To build, run tests, and launch the demo script, run `grunt demo`. (You can also run `node demo.js` directly (assumes `csproj2ts.csproj` in current folder).)
|
43 |
|
44 | ## Publishing:
|
45 |
|
46 | * Ensure `grunt test` comes back clean.
|
47 | * Update the `package.json` with the new version number.
|
48 | * Merge work to `master` on GitHub.
|
49 | * Run `npm publish`.
|
50 |
|
51 | ### Quickstart for debugging with Node Inspector
|
52 |
|
53 | Install [Node Inspector](https://github.com/node-inspector/node-inspector) via npm:
|
54 |
|
55 | `npm install -g node-inspector`
|
56 |
|
57 | Example command-line to debug a particular test ("test_run_at_all") on Windows:
|
58 |
|
59 | `node-debug --debug-brk "./node_modules/grunt-contrib-nodeunit/node_modules/nodeunit/bin/nodeunit" "tests/tests.js" -t "tests_run_at_all"`
|
60 |
|
61 | Set breakpoints in the Chrome dev tools, or use `debugger;` where needed.
|
62 |
|
63 |
|
64 | ## API:
|
65 |
|
66 | The main function of csproj2ts, getTypeScriptSettings(), returns a promise.
|
67 |
|
68 | In the then() result of the promise, the returned settings object has the following documented properties:
|
69 |
|
70 | * files: string[] - This is an array of the files that will be compiled.
|
71 | * VSProjectDetails - This object has the following properties which correspond to what was passed-in to csproj2ts (not what was found in the project file):
|
72 | * ProjectFileName: string
|
73 | * MSBuildExtensionsPath32: string
|
74 | * VisualStudioVersion: string
|
75 | * TypeScriptVersion: string
|
76 | * ActiveConfiguration: string
|
77 | * ActivePlatform: string
|
78 | * DefaultProjectConfiguration?: string;
|
79 | * DefaultProjectPlatform?: string;
|
80 | * DefaultVisualStudioVersion?: string;
|
81 | * TypeScriptDefaultPropsFilePath: string;
|
82 | * TypeScriptDefaultConfiguration: - this property has the settings (seen below) that correspond to the defaults on the referenced .props file.
|
83 |
|
84 |
|
85 | The returned settings object also has the following properties that correspond to the TypeScript configuration settings found in the project file:
|
86 |
|
87 | * AdditionalFlags?: string;
|
88 | * AllowJS?: boolean;
|
89 | * AllowSyntheticDefaultImports?: boolean;
|
90 | * AllowUnusedLabels?: boolean;
|
91 | * AllowUnreachableCode?: boolean;
|
92 | * AlwaysStrict?: boolean;
|
93 | * Charset?: string;
|
94 | * CheckJs?: boolean;
|
95 | * CodePage?: string;
|
96 | * CompileBlocked?: boolean;
|
97 | * CompileOnSaveEnabled?: boolean;
|
98 | * DownlevelIteration?: boolean;
|
99 | * EmitBOM?: boolean;
|
100 | * EmitDecoratorMetadata?: boolean;
|
101 | * ExperimentalAsyncFunctions?: boolean;
|
102 | * ExperimentalDecorators?: boolean;
|
103 | * ForceConsistentCasingInFileNames?: boolean;
|
104 | * GeneratesDeclarations?: boolean;
|
105 | * ImportHelpers?: boolean;
|
106 | * InlineSourceMap?: boolean;
|
107 | * InlineSources?: boolean;
|
108 | * IsolatedModules?: boolean;
|
109 | * JSXEmit?: string;
|
110 | * JSXFactory?: string;
|
111 | * Lib?: string;
|
112 | * MapRoot?: string;
|
113 | * ModuleKind?: string;
|
114 | * ModuleResolution?: string;
|
115 | * NewLine?: string;
|
116 | * NoEmitOnError?: boolean;
|
117 | * NoEmitHelpers?: boolean;
|
118 | * NoFallthroughCasesInSwitch?: boolean;
|
119 | * NoImplicitAny?: boolean;
|
120 | * NoImplicitUseStrict?: boolean;
|
121 | * NoLib?: boolean;
|
122 | * NoResolve?: boolean;
|
123 | * NoStrictGenericChecks?: boolean;
|
124 | * OutFile?: string;
|
125 | * OutDir?: string;
|
126 | * PreserveConstEnums?: boolean;
|
127 | * PreserveSymlinks?: boolean;
|
128 | * PreferredUILang?: string;
|
129 | * ReactNamespace?: string;
|
130 | * RemoveComments?: boolean;
|
131 | * RootDir?: boolean;
|
132 | * SkipDefaultLibCheck?: boolean;
|
133 | * SourceMap?: boolean;
|
134 | * SourceRoot?: string;
|
135 | * SuppressImplicitAnyIndexErrors?: boolean;
|
136 | * SuppressExcessPropertyErrors?: boolean;
|
137 | * Target?: string;
|