mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-17 19:13:34 +08:00
This commit removes the need for the bootstrap-local logic and moves the scripts to` mts`
47 lines
1.6 KiB
TypeScript
47 lines
1.6 KiB
TypeScript
/**
|
|
* @license
|
|
* Copyright Google LLC All Rights Reserved.
|
|
*
|
|
* 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
|
|
*/
|
|
|
|
import template from 'lodash.template';
|
|
import * as fs from 'node:fs';
|
|
import * as path from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
import { releasePackages } from './packages.mjs';
|
|
|
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
|
|
async function _runTemplate(inputPath: string, outputPath: string) {
|
|
inputPath = path.resolve(__dirname, inputPath);
|
|
outputPath = path.resolve(__dirname, outputPath);
|
|
|
|
console.info(`Building ${path.relative(path.dirname(__dirname), outputPath)}...`);
|
|
|
|
// TODO(ESM): Consider making this an actual import statement.
|
|
const { COMMIT_TYPES, ScopeRequirement } = await new Function(
|
|
`return import('@angular/ng-dev');`,
|
|
)();
|
|
|
|
const monorepo = JSON.parse(fs.readFileSync('./.monorepo.json', 'utf-8'));
|
|
const content = template(fs.readFileSync(inputPath, 'utf-8'))({
|
|
monorepo,
|
|
packages: releasePackages.map(({ name }) => name),
|
|
encode: (x: string) => global.encodeURIComponent(x),
|
|
// Pass-through `ng-dev` ESM commit message information for the `contributing.ejs`
|
|
// template. EJS templates using the devkit template cannot use ESM.
|
|
COMMIT_TYPES: COMMIT_TYPES,
|
|
ScopeRequirement: ScopeRequirement,
|
|
});
|
|
fs.writeFileSync(outputPath, content, 'utf-8');
|
|
}
|
|
|
|
export default async function (_options: {}): Promise<number> {
|
|
await _runTemplate('./templates/readme.ejs', '../README.md');
|
|
await _runTemplate('./templates/contributing.ejs', '../CONTRIBUTING.md');
|
|
|
|
return 0;
|
|
}
|