Permalink
Browse files

🎨 Add unstable NuGet config option. Closes #183

- add conditional option to NuGet subgenerator
- update tests to cover unstable feed generation
- update tests helper to support no-content assertion
- update documention and usage files

With this commit the users will be able to generate NuGet config file
with unstable feed to support pre-release development - e.g. when updating
this generator :)
  • Loading branch information...
1 parent 4877e5c commit 314fbce2530212ac03645d658f0e551debec3368 @peterblazejewicz peterblazejewicz committed Nov 23, 2015
Showing with 38 additions and 9 deletions.
  1. +4 −3 README.md
  2. +7 −1 nuget/index.js
  3. +2 −5 templates/_nuget.config
  4. +11 −0 test/subgenerators.js
  5. +14 −0 test/test-utility.js
View
@@ -460,15 +460,16 @@ Produces `/ContactView.cshtml`
### nuget
-Creates a new `NuGet.config` file
+Creates a new `NuGet.config` file. The support for unstable development
+feed is provided by `--unstable` option.
Example:
```
-yo aspnet:nuget
+yo aspnet:nuget --unstable
```
-Produces `NuGet.config`
+Produces `NuGet.config` with unstable NuGet feed
[Return to top](#top)
View
@@ -9,5 +9,11 @@ var Generator = module.exports = function Generator() {
util.inherits(Generator, ScriptBase);
Generator.prototype.createItem = function() {
- this.generateStandardFile('_nuget.config', 'NuGet.config');
+ // supports unstable feed via optional --unstable cli argument
+ this.generateTemplateFile(
+ '_nuget.config',
+ 'NuGet.config', {
+ unstable: (this.options.unstable ? this.options.unstable : false)
+ }
+ );
};
@@ -3,10 +3,7 @@
<packageSources>
<!--To inherit the global NuGet package sources remove the <clear /> line below -->
<clear />
- <add key="api.nuget.org" value="https://api.nuget.org/v3/index.json" />
- <!-- uncomment to use another feed for prerelease packages -->
- <!--
- <add key="aspnetrelease" value="https://myget.org/f/aspnetrc1/api/v2" />
- -->
+ <add key="api.nuget.org" value="https://api.nuget.org/v3/index.json" /><% if(unstable){ %>
+ <add key="aspnetrelease" value="https://myget.org/f/aspnetrc1/api/v2" /><% } %>
</packageSources>
</configuration>
View
@@ -97,11 +97,22 @@ describe('Subgenerators without arguments tests', function() {
util.fileContentCheck(filename, 'Check file content', /api\.nuget\.org/);
});
+ // unstable feed cannot be found in generated file
describe('aspnet:nuget', function() {
util.goCreate('nuget');
var filename = 'NuGet.config';
util.fileCheck('should create NuGet configuration file', filename);
util.fileContentCheck(filename, 'Check file content', /api\.nuget\.org/);
+ util.noFileContentCheck(filename, 'Check file content for no unstable feed', /https:\/\/myget\.org\/f\/aspnetrc1\/api\/v2/);
+ });
+
+ // unstable feed should be found in generated file
+ describe('aspnet:nuget --unstable', function() {
+ var arg = '--unstable';
+ var filename = 'NuGet.config';
+ util.goCreateWithArgs('nuget', [arg]);
+ util.fileCheck('should create ' + filename + ' file with unstable feed', filename);
+ util.fileContentCheck(filename, 'Check file content for unstable feed', /https:\/\/myget\.org\/f\/aspnetrc1\/api\/v2/);
});
});
View
@@ -158,6 +158,19 @@ var util = (function() {
});
}
+ /**
+ * The opposite function: specific content cannot be found
+ * in a file assertion
+ * @param {String} file
+ * @param {String} message
+ * @param {String} content
+ * @return {Boolean} true if condition is met
+ */
+ function noFileContentCheck(file, message, content) {
+ it(message, function() {
+ assert.noFileContent(file, content);
+ });
+ }
var methods = {
goCreateApplication: goCreateApplication,
@@ -169,6 +182,7 @@ var util = (function() {
dirCheck: dirCheck,
dirsCheck: dirsCheck,
fileContentCheck: fileContentCheck,
+ noFileContentCheck: noFileContentCheck,
makeTempDir: makeTempDir
};

0 comments on commit 314fbce

Please sign in to comment.