- Notifications
You must be signed in to change notification settings - Fork 12k
/
Copy pathtemplates.mts
48 lines (40 loc) · 1.66 KB
/
templates.mts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/**
* @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.dev/license
*/
importlodashfrom'lodash';
import*asfsfrom'node:fs';
import*aspathfrom'node:path';
import{fileURLToPath}from'node:url';
import{releasePackages}from'./packages.mjs';
const__dirname=path.dirname(fileURLToPath(import.meta.url));
asyncfunction_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 }=awaitnewFunction(
`return import('@angular/ng-dev');`,
)();
constmonorepo=JSON.parse(fs.readFileSync('./.monorepo.json','utf-8'));
constcontent=lodash.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');
}
exportdefaultasyncfunction(_options: {}): Promise<number>{
awaitPromise.all([
_runTemplate('./templates/readme.ejs','../README.md'),
_runTemplate('./templates/contributing.ejs','../CONTRIBUTING.md'),
]);
return0;
}