Skip to content
Closed
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
7 changes: 5 additions & 2 deletions packages/@ngtools/webpack/src/entry_resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ function _symbolImportLookup(refactor: TypeScriptFileRefactor,
(decl.moduleSpecifier as ts.StringLiteral).text,
refactor.fileName, program.getCompilerOptions(), host);
if (!resolvedModule.resolvedModule || !resolvedModule.resolvedModule.resolvedFileName) {
throw new Error('Could not resolve module name. Is '
+ (decl.moduleSpecifier as ts.StringLiteral).text + ' installed?');
return null;
}

Expand Down Expand Up @@ -134,6 +136,7 @@ export function resolveEntryModuleFromMain(mainPath: string,
.map(node => node as ts.CallExpression)
.filter(call => {
const access = call.expression as ts.PropertyAccessExpression;

return access.kind == ts.SyntaxKind.PropertyAccessExpression
&& access.name.kind == ts.SyntaxKind.Identifier
&& (access.name.text == 'bootstrapModule'
Expand All @@ -145,7 +148,7 @@ export function resolveEntryModuleFromMain(mainPath: string,
if (bootstrap.length != 1) {
throw new Error('Tried to find bootstrap code, but could not. Specify either '
+ 'statically analyzable bootstrap code or pass in an entryModule '
+ 'to the plugins options.');
+ 'to the plugins options. I has ' + bootstrap.length + ' bootstraps muahahaha');
}
const bootstrapSymbolName = bootstrap[0].text;
const module = _symbolImportLookup(source, bootstrapSymbolName, host, program);
Expand All @@ -156,5 +159,5 @@ export function resolveEntryModuleFromMain(mainPath: string,
// shrug... something bad happened and we couldn't find the import statement.
throw new Error('Tried to find bootstrap code, but could not. Specify either '
+ 'statically analyzable bootstrap code or pass in an entryModule '
+ 'to the plugins options.');
+ 'to the plugins options. fell out');
}
3 changes: 3 additions & 0 deletions packages/angular-cli/lib/config/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@
"prefix": {
"type": "string"
},
"app": {
"type": "string"
},
"mobile": {
"type": "boolean"
},
Expand Down
14 changes: 8 additions & 6 deletions packages/angular-cli/utilities/dynamic-path-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,21 @@ var fs = require('fs');
module.exports = function dynamicPathParser(project, entityName) {
var projectRoot = project.root;
var sourceDir = project.ngConfig.apps[0].root;
var appRoot = path.join(sourceDir, 'app');

var appPart = project.ngConfig.apps[0].app || 'app'
var appRoot = path.join(sourceDir, appPart);
var cwd = process.env.PWD;

var rootPath = path.join(projectRoot, appRoot);

var outputPath = path.join(rootPath, entityName);

if (entityName.indexOf(path.sep) === 0) {
outputPath = path.join(rootPath, entityName.substr(1));
} else if (cwd.indexOf(rootPath) >= 0) {
outputPath = path.join(cwd, entityName);
}

if (!fs.existsSync(outputPath)) {
// Verify the path exists on disk.
var parsedOutputPath = path.parse(outputPath);
Expand All @@ -33,12 +35,12 @@ module.exports = function dynamicPathParser(project, entityName) {
} else if (fs.existsSync(withPlus)) {
return withPlus;
}

throw `Invalid path: "${withoutPlus}"" is not a valid path.`
}, parsedOutputPath.root);
outputPath = path.join(newPath, parsedOutputPath.name);
}

if (outputPath.indexOf(rootPath) < 0) {
throw `Invalid path: "${entityName}" cannot be ` +
`above the "${appRoot}" directory`;
Expand All @@ -47,7 +49,7 @@ module.exports = function dynamicPathParser(project, entityName) {
var adjustedPath = outputPath.replace(projectRoot, '');

var parsedPath = path.parse(adjustedPath);

if (parsedPath.dir.indexOf(path.sep) === 0) {
parsedPath.dir = parsedPath.dir.substr(1);
}
Expand Down
5 changes: 3 additions & 2 deletions packages/angular-cli/utilities/find-parent-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import * as path from 'path';
const SilentError = require('silent-error');

export default function findParentModule(project: any, currentDir: string): string {
const sourceRoot = path.join(project.root, project.ngConfig.apps[0].root, 'app');
const appPart = project.ngConfig.apps[0].app ? project.ngConfig.apps[0].app : 'app';
const sourceRoot = path.join(project.root, project.ngConfig.apps[0].root, appPart);

// trim currentDir
currentDir = currentDir.replace(path.join(project.ngConfig.apps[0].root, 'app'), '');
currentDir = currentDir.replace(path.join(project.ngConfig.apps[0].root, appPart), '');

let pathToCheck = path.join(sourceRoot, currentDir);

Expand Down