Skip to content

Commit b857f4e

Browse files
author
Angular Builds
committed
d23a168b8 feat(@angular-devkit/build-angular): validate file extensions for scripts and styles options
1 parent 0d1abdb commit b857f4e

File tree

10 files changed

+170
-86
lines changed

10 files changed

+170
-86
lines changed

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
"builders": "builders.json",
88
"dependencies": {
99
"@ampproject/remapping": "2.0.0",
10-
"@angular-devkit/architect": "github:angular/angular-devkit-architect-builds#ed1322217",
11-
"@angular-devkit/build-webpack": "github:angular/angular-devkit-build-webpack-builds#ed1322217",
12-
"@angular-devkit/core": "github:angular/angular-devkit-core-builds#ed1322217",
10+
"@angular-devkit/architect": "github:angular/angular-devkit-architect-builds#d23a168b8",
11+
"@angular-devkit/build-webpack": "github:angular/angular-devkit-build-webpack-builds#d23a168b8",
12+
"@angular-devkit/core": "github:angular/angular-devkit-core-builds#d23a168b8",
1313
"@babel/core": "7.16.12",
1414
"@babel/generator": "7.16.8",
1515
"@babel/helper-annotate-as-pure": "7.16.7",
@@ -20,7 +20,7 @@
2020
"@babel/runtime": "7.16.7",
2121
"@babel/template": "7.16.7",
2222
"@discoveryjs/json-ext": "0.5.6",
23-
"@ngtools/webpack": "github:angular/ngtools-webpack-builds#ed1322217",
23+
"@ngtools/webpack": "github:angular/ngtools-webpack-builds#d23a168b8",
2424
"ansi-colors": "4.1.1",
2525
"babel-loader": "8.2.3",
2626
"babel-plugin-istanbul": "6.1.1",

src/builders/browser/schema.d.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ export interface Schema {
126126
/**
127127
* Global scripts to be included in the build.
128128
*/
129-
scripts?: ExtraEntryPoint[];
129+
scripts?: ScriptElement[];
130130
/**
131131
* Generates a service worker config for production builds.
132132
*/
@@ -154,7 +154,7 @@ export interface Schema {
154154
/**
155155
* Global styles to be included in the build.
156156
*/
157-
styles?: ExtraEntryPoint[];
157+
styles?: StyleElement[];
158158
/**
159159
* Enables the use of subresource integrity validation.
160160
*/
@@ -366,8 +366,8 @@ export declare enum OutputHashing {
366366
Media = "media",
367367
None = "none"
368368
}
369-
export declare type ExtraEntryPoint = ExtraEntryPointClass | string;
370-
export interface ExtraEntryPointClass {
369+
export declare type ScriptElement = ScriptClass | string;
370+
export interface ScriptClass {
371371
/**
372372
* The bundle name for this extra entry point.
373373
*/
@@ -413,3 +413,18 @@ export interface StylePreprocessorOptions {
413413
*/
414414
includePaths?: string[];
415415
}
416+
export declare type StyleElement = StyleClass | string;
417+
export interface StyleClass {
418+
/**
419+
* The bundle name for this extra entry point.
420+
*/
421+
bundleName?: string;
422+
/**
423+
* If the bundle will be referenced in the HTML file.
424+
*/
425+
inject?: boolean;
426+
/**
427+
* The file to include.
428+
*/
429+
input: string;
430+
}

src/builders/browser/schema.json

Lines changed: 58 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,71 @@
2929
"type": "array",
3030
"default": [],
3131
"items": {
32-
"$ref": "#/definitions/extraEntryPoint"
32+
"oneOf": [
33+
{
34+
"type": "object",
35+
"properties": {
36+
"input": {
37+
"type": "string",
38+
"description": "The file to include.",
39+
"pattern": "\\.[cm]?jsx?$"
40+
},
41+
"bundleName": {
42+
"type": "string",
43+
"pattern": "^[\\w\\-.]*$",
44+
"description": "The bundle name for this extra entry point."
45+
},
46+
"inject": {
47+
"type": "boolean",
48+
"description": "If the bundle will be referenced in the HTML file.",
49+
"default": true
50+
}
51+
},
52+
"additionalProperties": false,
53+
"required": ["input"]
54+
},
55+
{
56+
"type": "string",
57+
"description": "The file to include.",
58+
"pattern": "\\.[cm]?jsx?$"
59+
}
60+
]
3361
}
3462
},
3563
"styles": {
3664
"description": "Global styles to be included in the build.",
3765
"type": "array",
3866
"default": [],
3967
"items": {
40-
"$ref": "#/definitions/extraEntryPoint"
68+
"oneOf": [
69+
{
70+
"type": "object",
71+
"properties": {
72+
"input": {
73+
"type": "string",
74+
"description": "The file to include.",
75+
"pattern": "\\.(?:css|scss|sass|less|styl)$"
76+
},
77+
"bundleName": {
78+
"type": "string",
79+
"pattern": "^[\\w\\-.]*$",
80+
"description": "The bundle name for this extra entry point."
81+
},
82+
"inject": {
83+
"type": "boolean",
84+
"description": "If the bundle will be referenced in the HTML file.",
85+
"default": true
86+
}
87+
},
88+
"additionalProperties": false,
89+
"required": ["input"]
90+
},
91+
{
92+
"type": "string",
93+
"description": "The file to include.",
94+
"pattern": "\\.(?:css|scss|sass|less|styl)$"
95+
}
96+
]
4197
}
4298
},
4399
"inlineStyleLanguage": {
@@ -437,35 +493,6 @@
437493
}
438494
]
439495
},
440-
"extraEntryPoint": {
441-
"oneOf": [
442-
{
443-
"type": "object",
444-
"properties": {
445-
"input": {
446-
"type": "string",
447-
"description": "The file to include."
448-
},
449-
"bundleName": {
450-
"type": "string",
451-
"pattern": "^[\\w\\-.]*$",
452-
"description": "The bundle name for this extra entry point."
453-
},
454-
"inject": {
455-
"type": "boolean",
456-
"description": "If the bundle will be referenced in the HTML file.",
457-
"default": true
458-
}
459-
},
460-
"additionalProperties": false,
461-
"required": ["input"]
462-
},
463-
{
464-
"type": "string",
465-
"description": "The file to include."
466-
}
467-
]
468-
},
469496
"budget": {
470497
"type": "object",
471498
"properties": {

src/builders/karma/schema.d.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export interface Schema {
6767
/**
6868
* Global scripts to be included in the build.
6969
*/
70-
scripts?: ExtraEntryPoint[];
70+
scripts?: ScriptElement[];
7171
/**
7272
* Output source maps for scripts and styles. For more information, see
7373
* https://angular.io/guide/workspace-config#source-map-configuration.
@@ -80,7 +80,7 @@ export interface Schema {
8080
/**
8181
* Global styles to be included in the build.
8282
*/
83-
styles?: ExtraEntryPoint[];
83+
styles?: StyleElement[];
8484
/**
8585
* The name of the TypeScript configuration file.
8686
*/
@@ -128,8 +128,8 @@ export declare enum InlineStyleLanguage {
128128
Sass = "sass",
129129
Scss = "scss"
130130
}
131-
export declare type ExtraEntryPoint = ExtraEntryPointClass | string;
132-
export interface ExtraEntryPointClass {
131+
export declare type ScriptElement = ScriptClass | string;
132+
export interface ScriptClass {
133133
/**
134134
* The bundle name for this extra entry point.
135135
*/
@@ -171,3 +171,18 @@ export interface StylePreprocessorOptions {
171171
*/
172172
includePaths?: string[];
173173
}
174+
export declare type StyleElement = StyleClass | string;
175+
export interface StyleClass {
176+
/**
177+
* The bundle name for this extra entry point.
178+
*/
179+
bundleName?: string;
180+
/**
181+
* If the bundle will be referenced in the HTML file.
182+
*/
183+
inject?: boolean;
184+
/**
185+
* The file to include.
186+
*/
187+
input: string;
188+
}

src/builders/karma/schema.json

Lines changed: 58 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,71 @@
3333
"type": "array",
3434
"default": [],
3535
"items": {
36-
"$ref": "#/definitions/extraEntryPoint"
36+
"oneOf": [
37+
{
38+
"type": "object",
39+
"properties": {
40+
"input": {
41+
"type": "string",
42+
"description": "The file to include.",
43+
"pattern": "\\.[cm]?jsx?$"
44+
},
45+
"bundleName": {
46+
"type": "string",
47+
"pattern": "^[\\w\\-.]*$",
48+
"description": "The bundle name for this extra entry point."
49+
},
50+
"inject": {
51+
"type": "boolean",
52+
"description": "If the bundle will be referenced in the HTML file.",
53+
"default": true
54+
}
55+
},
56+
"additionalProperties": false,
57+
"required": ["input"]
58+
},
59+
{
60+
"type": "string",
61+
"description": "The file to include.",
62+
"pattern": "\\.[cm]?jsx?$"
63+
}
64+
]
3765
}
3866
},
3967
"styles": {
4068
"description": "Global styles to be included in the build.",
4169
"type": "array",
4270
"default": [],
4371
"items": {
44-
"$ref": "#/definitions/extraEntryPoint"
72+
"oneOf": [
73+
{
74+
"type": "object",
75+
"properties": {
76+
"input": {
77+
"type": "string",
78+
"description": "The file to include.",
79+
"pattern": "\\.(?:css|scss|sass|less|styl)$"
80+
},
81+
"bundleName": {
82+
"type": "string",
83+
"pattern": "^[\\w\\-.]*$",
84+
"description": "The bundle name for this extra entry point."
85+
},
86+
"inject": {
87+
"type": "boolean",
88+
"description": "If the bundle will be referenced in the HTML file.",
89+
"default": true
90+
}
91+
},
92+
"additionalProperties": false,
93+
"required": ["input"]
94+
},
95+
{
96+
"type": "string",
97+
"description": "The file to include.",
98+
"pattern": "\\.(?:css|scss|sass|less|styl)$"
99+
}
100+
]
45101
}
46102
},
47103
"inlineStyleLanguage": {
@@ -218,35 +274,6 @@
218274
"type": "string"
219275
}
220276
]
221-
},
222-
"extraEntryPoint": {
223-
"oneOf": [
224-
{
225-
"type": "object",
226-
"properties": {
227-
"input": {
228-
"type": "string",
229-
"description": "The file to include."
230-
},
231-
"bundleName": {
232-
"type": "string",
233-
"pattern": "^[\\w\\-.]*$",
234-
"description": "The bundle name for this extra entry point."
235-
},
236-
"inject": {
237-
"type": "boolean",
238-
"description": "If the bundle will be referenced in the HTML file.",
239-
"default": true
240-
}
241-
},
242-
"additionalProperties": false,
243-
"required": ["input"]
244-
},
245-
{
246-
"type": "string",
247-
"description": "The file to include."
248-
}
249-
]
250277
}
251278
}
252279
}

src/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88
export * from './transforms';
9-
export { AssetPattern, AssetPatternClass as AssetPatternObject, Budget, CrossOrigin, ExtraEntryPoint, ExtraEntryPointClass as ExtraEntryPointObject, FileReplacement, OptimizationClass as OptimizationObject, OptimizationUnion, OutputHashing, Schema as BrowserBuilderOptions, SourceMapClass as SourceMapObject, SourceMapUnion, StylePreprocessorOptions, Type, } from './builders/browser/schema';
9+
export { AssetPattern, AssetPatternClass as AssetPatternObject, Budget, CrossOrigin, FileReplacement, OptimizationClass as OptimizationObject, OptimizationUnion, OutputHashing, Schema as BrowserBuilderOptions, SourceMapClass as SourceMapObject, SourceMapUnion, StylePreprocessorOptions, Type, } from './builders/browser/schema';
1010
export { buildWebpackBrowser as executeBrowserBuilder, BrowserBuilderOutput, } from './builders/browser';
1111
export { serveWebpackBrowser as executeDevServerBuilder, DevServerBuilderOptions, DevServerBuilderOutput, } from './builders/dev-server';
1212
export { execute as executeExtractI18nBuilder, ExtractI18nBuilderOptions, } from './builders/extract-i18n';

src/utils/build-options.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88
import { logging } from '@angular-devkit/core';
99
import type { ParsedConfiguration } from '@angular/compiler-cli';
10-
import { AssetPatternClass, Budget, CrossOrigin, ExtraEntryPoint, I18NTranslation, IndexUnion, InlineStyleLanguage, Localize, SourceMapClass } from '../builders/browser/schema';
10+
import { AssetPatternClass, Budget, CrossOrigin, I18NTranslation, IndexUnion, InlineStyleLanguage, Localize, ScriptElement, SourceMapClass, StyleElement } from '../builders/browser/schema';
1111
import { Schema as DevServerSchema } from '../builders/dev-server/schema';
1212
import { NormalizedCachedOptions } from './normalize-cache';
1313
import { NormalizedFileReplacement } from './normalize-file-replacements';
@@ -49,8 +49,8 @@ export interface BuildOptions {
4949
polyfills?: string;
5050
budgets: Budget[];
5151
assets: AssetPatternClass[];
52-
scripts: ExtraEntryPoint[];
53-
styles: ExtraEntryPoint[];
52+
scripts: ScriptElement[];
53+
styles: StyleElement[];
5454
stylePreprocessorOptions?: {
5555
includePaths: string[];
5656
};

src/utils/package-chunk-sort.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
* Use of this source code is governed by an MIT-style license that can be
66
* found in the LICENSE file at https://angular.io/license
77
*/
8-
import { ExtraEntryPoint } from '../builders/browser/schema';
8+
import { ScriptElement, StyleElement } from '../builders/browser/schema';
99
export declare type EntryPointsType = [name: string, isModule: boolean];
1010
export declare function generateEntryPoints(options: {
11-
styles: ExtraEntryPoint[];
12-
scripts: ExtraEntryPoint[];
11+
styles: StyleElement[];
12+
scripts: ScriptElement[];
1313
isHMREnabled?: boolean;
1414
}): EntryPointsType[];

0 commit comments

Comments
 (0)