mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-21 14:02:43 +08:00
refactor(@angular/pwa): remove @angular-devkit/core
dependency
The `@angular-devkit/core` dependency was only used for two path manipulation functions. Since this schematic already uses Node.js builtins, the `path` builtin can also be used to provide equivalent function without the need for an additional dependency.
This commit is contained in:
parent
e310a748dc
commit
8185558e79
packages/angular/pwa
@ -38,12 +38,10 @@ ts_library(
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
deps = [
|
deps = [
|
||||||
"//packages/angular_devkit/core",
|
|
||||||
"//packages/angular_devkit/schematics",
|
"//packages/angular_devkit/schematics",
|
||||||
"//packages/schematics/angular",
|
"//packages/schematics/angular",
|
||||||
"@npm//@types/node",
|
"@npm//@types/node",
|
||||||
"@npm//@types/parse5-html-rewriting-stream",
|
"@npm//@types/parse5-html-rewriting-stream",
|
||||||
"@npm//rxjs",
|
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
"save": false
|
"save": false
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@angular-devkit/core": "0.0.0",
|
|
||||||
"@angular-devkit/schematics": "0.0.0",
|
"@angular-devkit/schematics": "0.0.0",
|
||||||
"@schematics/angular": "0.0.0",
|
"@schematics/angular": "0.0.0",
|
||||||
"parse5-html-rewriting-stream": "6.0.1"
|
"parse5-html-rewriting-stream": "6.0.1"
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
* Use of this source code is governed by an MIT-style license that can be
|
* Use of this source code is governed by an MIT-style license that can be
|
||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
import { join, normalize } from '@angular-devkit/core';
|
|
||||||
import {
|
import {
|
||||||
Rule,
|
Rule,
|
||||||
SchematicsException,
|
SchematicsException,
|
||||||
@ -19,6 +18,7 @@ import {
|
|||||||
url,
|
url,
|
||||||
} from '@angular-devkit/schematics';
|
} from '@angular-devkit/schematics';
|
||||||
import { getWorkspace, updateWorkspace } from '@schematics/angular/utility/workspace';
|
import { getWorkspace, updateWorkspace } from '@schematics/angular/utility/workspace';
|
||||||
|
import { posix } from 'path';
|
||||||
import { Readable, Writable } from 'stream';
|
import { Readable, Writable } from 'stream';
|
||||||
import { Schema as PwaOptions } from './schema';
|
import { Schema as PwaOptions } from './schema';
|
||||||
|
|
||||||
@ -117,7 +117,10 @@ export default function(options: PwaOptions): Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add manifest to asset configuration
|
// Add manifest to asset configuration
|
||||||
const assetEntry = join(normalize(project.root), 'src', 'manifest.webmanifest');
|
const assetEntry = posix.join(
|
||||||
|
project.sourceRoot ?? posix.join(project.root, 'src'),
|
||||||
|
'manifest.webmanifest',
|
||||||
|
);
|
||||||
for (const target of [...buildTargets, ...testTargets]) {
|
for (const target of [...buildTargets, ...testTargets]) {
|
||||||
if (target.options) {
|
if (target.options) {
|
||||||
if (Array.isArray(target.options.assets)) {
|
if (Array.isArray(target.options.assets)) {
|
||||||
@ -149,7 +152,7 @@ export default function(options: PwaOptions): Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Setup sources for the assets files to add to the project
|
// Setup sources for the assets files to add to the project
|
||||||
const sourcePath = normalize(project.sourceRoot ?? 'src');
|
const sourcePath = project.sourceRoot ?? posix.join(project.root, 'src');
|
||||||
|
|
||||||
// Setup service worker schematic options
|
// Setup service worker schematic options
|
||||||
const { title, ...swOptions } = options;
|
const { title, ...swOptions } = options;
|
||||||
@ -163,7 +166,7 @@ export default function(options: PwaOptions): Rule {
|
|||||||
])),
|
])),
|
||||||
mergeWith(apply(url('./files/assets'), [
|
mergeWith(apply(url('./files/assets'), [
|
||||||
template({ ...options }),
|
template({ ...options }),
|
||||||
move(join(sourcePath, 'assets')),
|
move(posix.join(sourcePath, 'assets')),
|
||||||
])),
|
])),
|
||||||
...[...indexFiles].map(path => updateIndexFile(path)),
|
...[...indexFiles].map(path => updateIndexFile(path)),
|
||||||
]);
|
]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user