Skip to content
This repository was archived by the owner on Apr 8, 2020. It is now read-only.

Commit 0bcf4b0

Browse files
Further work on fix for #235 (solving additional problem that 'npm publish' is hardcoded to exclude node_modules dirs)
1 parent 5750c4a commit 0bcf4b0

File tree

9 files changed

+19
-10
lines changed

9 files changed

+19
-10
lines changed

.gitignore

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,6 @@ npm-debug.log
3434
# files with that name (https://github.com/npm/npm/issues/1862). So, each template instead has a template_gitignore
3535
# file which gets renamed after the files are copied. And so any files that need to be excluded in the source
3636
# repo have to be excluded here.
37-
38-
# Note that we need to exclude node_modules/** (i.e., subdirs, not the whole of node_modules) because we do need to
39-
# include the _placeholder.txt files, and can't do that using gitignore exclusion because developers aren't promoted to
40-
# commit files included that way. This is all a workaround for Workaround for https://github.com/aspnet/JavaScriptServices/issues/235
41-
/templates/*/node_modules/**
37+
/templates/*/node_modules/
4238
/templates/*/wwwroot/dist/
4339
.vscode/
44-
45-
# Workaround for https://github.com/aspnet/JavaScriptServices/issues/235
46-
!/templates/*/node_modules/_placeholder.txt
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

templates/package-builder/src/build/build.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,11 @@ function buildDotNetNewNuGetPackage() {
110110
const projectGuid = '00000000-0000-0000-0000-000000000000';
111111
const filenameReplacements = [
112112
{ from: /.*\.xproj$/, to: `${sourceProjectName}.xproj` },
113-
{ from: /\btemplate_gitignore$/, to: '.gitignore' }
113+
{ from: /\btemplate_gitignore$/, to: '.gitignore' },
114+
115+
// Workaround for https://github.com/aspnet/JavaScriptServices/issues/235
116+
// For details, see the comment in ../yeoman/app/index.ts
117+
{ from: /\btemplate_nodemodules_placeholder.txt$/, to: 'node_modules/_placeholder.txt' }
114118
];
115119
const contentReplacements = [
116120
{ from: /<ProjectGuid>[0-9a-f\-]{36}<\/ProjectGuid>/g, to: `<ProjectGuid>${projectGuid}</ProjectGuid>` },

templates/package-builder/src/yeoman/app/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,18 @@ class MyGenerator extends yeoman.Base {
5252
outputFn = path.join(path.dirname(fn), '.gitignore');
5353
}
5454

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

templates/package-builder/src/yeoman/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "generator-aspnetcore-spa",
3-
"version": "0.2.5",
3+
"version": "0.2.6",
44
"description": "Single-Page App templates for ASP.NET Core",
55
"author": "Microsoft",
66
"license": "Apache-2.0",

0 commit comments

Comments
 (0)