Further work on fix for #235 (solving additional problem that 'npm publish' is hardcoded to exclude node_modules dirs)

This commit is contained in:
SteveSandersonMS
2016-09-08 15:58:47 +01:00
parent 5750c4aab7
commit 0bcf4b0700
9 changed files with 19 additions and 10 deletions

View File

@@ -110,7 +110,11 @@ function buildDotNetNewNuGetPackage() {
const projectGuid = '00000000-0000-0000-0000-000000000000';
const filenameReplacements = [
{ from: /.*\.xproj$/, to: `${sourceProjectName}.xproj` },
{ from: /\btemplate_gitignore$/, to: '.gitignore' }
{ from: /\btemplate_gitignore$/, to: '.gitignore' },
// Workaround for https://github.com/aspnet/JavaScriptServices/issues/235
// For details, see the comment in ../yeoman/app/index.ts
{ from: /\btemplate_nodemodules_placeholder.txt$/, to: 'node_modules/_placeholder.txt' }
];
const contentReplacements = [
{ from: /<ProjectGuid>[0-9a-f\-]{36}<\/ProjectGuid>/g, to: `<ProjectGuid>${projectGuid}</ProjectGuid>` },

View File

@@ -52,6 +52,18 @@ class MyGenerator extends yeoman.Base {
outputFn = path.join(path.dirname(fn), '.gitignore');
}
// Likewise, output template_nodemodules_placeholder.txt as node_modules/_placeholder.txt
// This is a workaround for https://github.com/aspnet/JavaScriptServices/issues/235. We need the new project
// to have a nonempty node_modules dir as far as *source control* is concerned. So, there's a gitignore
// rule that explicitly causes node_modules/_placeholder.txt to be tracked in source control. But how
// does that file get there in the first place? It's not enough for such a file to exist when the
// generator-aspnetcore-spa NPM package is published, because NPM doesn't allow any directories called
// node_modules to exist in the package. So we have a file with at a different location, and move it
// to node_modules as part of executing the template.
if (path.basename(fn) === 'template_nodemodules_placeholder.txt') {
outputFn = path.join(path.dirname(fn), 'node_modules', '_placeholder.txt');
}
this.fs.copyTpl(
path.join(templateRoot, fn),
this.destinationPath(outputFn),

View File

@@ -1,6 +1,6 @@
{
"name": "generator-aspnetcore-spa",
"version": "0.2.5",
"version": "0.2.6",
"description": "Single-Page App templates for ASP.NET Core",
"author": "Microsoft",
"license": "Apache-2.0",