Skip to content
This repository has been archived by the owner on Apr 9, 2022. It is now read-only.

Commit

Permalink
fix(@schematics/update): show warning for allowOutsideOutDir assets
Browse files Browse the repository at this point in the history
  • Loading branch information
filipesilva authored and clydin committed May 29, 2018
1 parent d8dda29 commit 65964e2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
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 @@ -11,6 +11,7 @@ import {
JsonParseMode,
Path,
join,
logging,
normalize,
parseJson,
parseJsonAst,
Expand Down Expand Up @@ -90,7 +91,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 @@ -99,7 +100,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 @@ -211,7 +212,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 @@ -256,7 +259,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 @@ -409,7 +419,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 @@ -455,7 +465,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 @@ -752,7 +762,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

0 comments on commit 65964e2

Please sign in to comment.