refactor(@angular-devkit/schematics-cli): rename schematic template files with a template extension

Files that contain template instructions should include a `.template` extension to prevent them from
being treated as TypeScript/JSON/etc. files. Not doing so can result in parse errors or other failures
when the files are incorrectly processed by other tools.
This commit is contained in:
Charles Lyding 2024-02-12 15:08:57 -05:00 committed by Alan Agius
parent a5e8ac5821
commit 275b5e7480
8 changed files with 8 additions and 5 deletions

View File

@ -13,10 +13,10 @@ import {
SchematicsException,
Tree,
apply,
applyTemplates,
chain,
mergeWith,
move,
template,
url,
} from '@angular-devkit/schematics';
import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';
@ -63,7 +63,7 @@ export default function (options: Schema): Rule {
} catch {}
let source = apply(url('./schematic-files'), [
template({
applyTemplates({
...options,
coreVersion,
schematicsVersion,
@ -77,7 +77,8 @@ export default function (options: Schema): Rule {
if (!collectionPath) {
collectionPath = normalize('/' + options.name + '/src/collection.json');
source = apply(url('./project-files'), [
template({
move('package.json', 'package.json.template'),
applyTemplates({
...(options as object),
coreVersion,
schematicsVersion,

View File

@ -10,10 +10,10 @@ import { strings } from '@angular-devkit/core';
import {
Rule,
apply,
applyTemplates,
mergeWith,
move,
partitionApplyMerge,
template,
url,
} from '@angular-devkit/schematics';
import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';
@ -28,9 +28,11 @@ export default function (options: Schema): Rule {
return mergeWith(
apply(url('./files'), [
// The `package.json` name is kept to allow renovate to update the dependency versions
move('package.json', 'package.json.template'),
partitionApplyMerge(
(p) => !/\/src\/.*?\/files\//.test(p),
template({
applyTemplates({
...options,
coreVersion,
schematicsVersion,