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

fix(@schematics/update): show warning for allowOutsideOutDir assets #850

Merged
merged 1 commit into from
May 17, 2018
Merged
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
24 changes: 17 additions & 7 deletions packages/schematics/angular/migrations/update-6/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
JsonParseMode,
Path,
join,
logging,
normalize,
parseJson,
parseJsonAst,
Expand Down Expand Up @@ -89,7 +90,7 @@ function migrateKarmaConfiguration(config: CliConfig): Rule {
};
}

function migrateConfiguration(oldConfig: CliConfig): Rule {
function migrateConfiguration(oldConfig: CliConfig, logger: logging.LoggerApi): Rule {
return (host: Tree, context: SchematicContext) => {
const oldConfigPath = getConfigPath(host);
const configPath = normalize('angular.json');
Expand All @@ -98,7 +99,7 @@ function migrateConfiguration(oldConfig: CliConfig): Rule {
'$schema': './node_modules/@angular/cli/lib/config/schema.json',
version: 1,
newProjectRoot: 'projects',
projects: extractProjectsConfig(oldConfig, host),
projects: extractProjectsConfig(oldConfig, host, logger),
};
const defaultProject = extractDefaultProject(oldConfig);
if (defaultProject !== null) {
Expand Down Expand Up @@ -210,7 +211,9 @@ function extractArchitectConfig(_config: CliConfig): JsonObject | null {
return null;
}

function extractProjectsConfig(config: CliConfig, tree: Tree): JsonObject {
function extractProjectsConfig(
config: CliConfig, tree: Tree, logger: logging.LoggerApi,
): JsonObject {
const builderPackage = '@angular-devkit/build-angular';
const defaultAppNamePrefix = getDefaultAppNamePrefix(config);

Expand Down Expand Up @@ -255,7 +258,14 @@ function extractProjectsConfig(config: CliConfig, tree: Tree): JsonObject {
if (typeof asset === 'string') {
return normalize(appRoot + '/' + asset);
} else {
if (asset.output) {
if (asset.allowOutsideOutDir) {
logger.warn(tags.oneLine`
Asset with input '${asset.input}' was not migrated because it
uses the 'allowOutsideOutDir' option which is not supported in Angular CLI 6.
`);

return null;
} else if (asset.output) {
return {
glob: asset.glob,
input: normalize(appRoot + '/' + asset.input),
Expand Down Expand Up @@ -407,7 +417,7 @@ function extractProjectsConfig(config: CliConfig, tree: Tree): JsonObject {
};
}

buildOptions.assets = (app.assets || []).map(_mapAssets);
buildOptions.assets = (app.assets || []).map(_mapAssets).filter(x => !!x);
buildOptions.styles = (app.styles || []).map(_extraEntryMapper);
buildOptions.scripts = (app.scripts || []).map(_extraEntryMapper);
architect.build = {
Expand Down Expand Up @@ -453,7 +463,7 @@ function extractProjectsConfig(config: CliConfig, tree: Tree): JsonObject {
}
testOptions.scripts = (app.scripts || []).map(_extraEntryMapper);
testOptions.styles = (app.styles || []).map(_extraEntryMapper);
testOptions.assets = (app.assets || []).map(_mapAssets);
testOptions.assets = (app.assets || []).map(_mapAssets).filter(x => !!x);

if (karmaConfig) {
architect.test = {
Expand Down Expand Up @@ -750,7 +760,7 @@ export default function (): Rule {

return chain([
migrateKarmaConfiguration(config),
migrateConfiguration(config),
migrateConfiguration(config, context.logger),
updateSpecTsConfig(config),
updatePackageJson(config),
updateTsLintConfig(),
Expand Down
6 changes: 6 additions & 0 deletions packages/schematics/angular/migrations/update-6/index_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ describe('Migration to v6', () => {
'favicon.ico',
{ glob: '**/*', input: './assets/', output: './assets/' },
{ glob: 'favicon.ico', input: './', output: './' },
{
'glob': '**/*.*',
'input': '../server/',
'output': '../',
'allowOutsideOutDir': true,
},
],
index: 'index.html',
main: 'main.ts',
Expand Down