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

Commit cffb225

Browse files
committed
fix(@schematics/update): show warning for allowOutsideOutDir assets
Fix angular/angular-cli#10647
1 parent 3e48344 commit cffb225

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

packages/schematics/angular/migrations/update-6/index.ts

+17-7
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
JsonParseMode,
1212
Path,
1313
join,
14+
logging,
1415
normalize,
1516
parseJson,
1617
parseJsonAst,
@@ -90,7 +91,7 @@ function migrateKarmaConfiguration(config: CliConfig): Rule {
9091
};
9192
}
9293

93-
function migrateConfiguration(oldConfig: CliConfig): Rule {
94+
function migrateConfiguration(oldConfig: CliConfig, logger: logging.LoggerApi): Rule {
9495
return (host: Tree, context: SchematicContext) => {
9596
const oldConfigPath = getConfigPath(host);
9697
const configPath = normalize('angular.json');
@@ -99,7 +100,7 @@ function migrateConfiguration(oldConfig: CliConfig): Rule {
99100
'$schema': './node_modules/@angular/cli/lib/config/schema.json',
100101
version: 1,
101102
newProjectRoot: 'projects',
102-
projects: extractProjectsConfig(oldConfig, host),
103+
projects: extractProjectsConfig(oldConfig, host, logger),
103104
};
104105
const defaultProject = extractDefaultProject(oldConfig);
105106
if (defaultProject !== null) {
@@ -211,7 +212,9 @@ function extractArchitectConfig(_config: CliConfig): JsonObject | null {
211212
return null;
212213
}
213214

214-
function extractProjectsConfig(config: CliConfig, tree: Tree): JsonObject {
215+
function extractProjectsConfig(
216+
config: CliConfig, tree: Tree, logger: logging.LoggerApi,
217+
): JsonObject {
215218
const builderPackage = '@angular-devkit/build-angular';
216219
const defaultAppNamePrefix = getDefaultAppNamePrefix(config);
217220

@@ -256,7 +259,14 @@ function extractProjectsConfig(config: CliConfig, tree: Tree): JsonObject {
256259
if (typeof asset === 'string') {
257260
return normalize(appRoot + '/' + asset);
258261
} else {
259-
if (asset.output) {
262+
if (asset.allowOutsideOutDir) {
263+
logger.warn(tags.oneLine`
264+
Asset with input '${asset.input}' was not migrated because it
265+
uses the 'allowOutsideOutDir' option which is not supported in Angular CLI 6.
266+
`);
267+
268+
return null;
269+
} else if (asset.output) {
260270
return {
261271
glob: asset.glob,
262272
input: normalize(appRoot + '/' + asset.input),
@@ -409,7 +419,7 @@ function extractProjectsConfig(config: CliConfig, tree: Tree): JsonObject {
409419
};
410420
}
411421

412-
buildOptions.assets = (app.assets || []).map(_mapAssets);
422+
buildOptions.assets = (app.assets || []).map(_mapAssets).filter(x => !!x);
413423
buildOptions.styles = (app.styles || []).map(_extraEntryMapper);
414424
buildOptions.scripts = (app.scripts || []).map(_extraEntryMapper);
415425
architect.build = {
@@ -455,7 +465,7 @@ function extractProjectsConfig(config: CliConfig, tree: Tree): JsonObject {
455465
}
456466
testOptions.scripts = (app.scripts || []).map(_extraEntryMapper);
457467
testOptions.styles = (app.styles || []).map(_extraEntryMapper);
458-
testOptions.assets = (app.assets || []).map(_mapAssets);
468+
testOptions.assets = (app.assets || []).map(_mapAssets).filter(x => !!x);
459469

460470
if (karmaConfig) {
461471
architect.test = {
@@ -752,7 +762,7 @@ export default function (): Rule {
752762

753763
return chain([
754764
migrateKarmaConfiguration(config),
755-
migrateConfiguration(config),
765+
migrateConfiguration(config, context.logger),
756766
updateSpecTsConfig(config),
757767
updatePackageJson(config),
758768
updateTsLintConfig(),

packages/schematics/angular/migrations/update-6/index_spec.ts

+6
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ describe('Migration to v6', () => {
4040
'favicon.ico',
4141
{ glob: '**/*', input: './assets/', output: './assets/' },
4242
{ glob: 'favicon.ico', input: './', output: './' },
43+
{
44+
'glob': '**/*.*',
45+
'input': '../server/',
46+
'output': '../',
47+
'allowOutsideOutDir': true,
48+
},
4349
],
4450
index: 'index.html',
4551
main: 'main.ts',

0 commit comments

Comments
 (0)