-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Angular: Fix missing architect properties #9390
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,6 +50,7 @@ export function getAngularCliConfig(dirToSearch: string) { | |
const fname = path.join(dirToSearch, 'angular.json'); | ||
|
||
if (!fs.existsSync(fname)) { | ||
logger.error(`Could not find angular.json using ${fname}`); | ||
return undefined; | ||
} | ||
|
||
|
@@ -67,9 +68,26 @@ export function getLeadingAngularCliProject(ngCliConfig: any) { | |
throw new Error('angular.json must have projects entry.'); | ||
} | ||
|
||
const fallbackProject = defaultProject && projects[defaultProject]; | ||
const firstProject = projects[Object.keys(projects)[0]]; | ||
return projects.storybook || fallbackProject || firstProject; | ||
let projectName; | ||
const firstProjectName = Object.keys(projects)[0]; | ||
if (projects.storybook) { | ||
projectName = 'storybook'; | ||
} else if (defaultProject && projects[defaultProject]) { | ||
projectName = defaultProject; | ||
} else if (projects[firstProjectName]) { | ||
projectName = firstProjectName; | ||
} | ||
|
||
const project = projects[projectName]; | ||
if (!project) { | ||
logger.error(`Could not find angular project '${projectName}' in angular.json.`); | ||
} else { | ||
logger.info(`=> Using angular project '${projectName}' for configuring Storybook.`); | ||
} | ||
if (!project.architect.build) { | ||
logger.error(`architect.build is not defined for project '${projectName}'.`); | ||
} | ||
return project; | ||
} | ||
|
||
export function getAngularCliWebpackConfigOptions(dirToSearch: Path) { | ||
|
@@ -90,6 +108,9 @@ export function getAngularCliWebpackConfigOptions(dirToSearch: Path) { | |
const tsConfigPath = path.resolve(dirToSearch, projectOptions.tsConfig) as Path; | ||
const tsConfig = getTsConfigOptions(tsConfigPath); | ||
const budgets = projectOptions.budgets || []; | ||
const scripts = projectOptions.scripts || []; | ||
const outputPath = projectOptions.outputPath || 'dist/storybook-angular'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what's the output path? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Storybook does not need it and usually it is already set in |
||
const styles = projectOptions.styles || []; | ||
|
||
return { | ||
root: dirToSearch, | ||
|
@@ -102,7 +123,10 @@ export function getAngularCliWebpackConfigOptions(dirToSearch: Path) { | |
optimization: {}, | ||
...projectOptions, | ||
assets: normalizedAssets, | ||
budgets | ||
budgets, | ||
scripts, | ||
styles, | ||
outputPath, | ||
}, | ||
}; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is
projects
guaranteed to have at least one key?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It must, or else we are speaking of an empty project.
A couple of lines earlier there's also a check for making sure there is at least one project
storybook/app/angular/src/server/angular-cli_config.ts
Line 67 in f419b7f