MCPcopy Create free account
hub / github.com/angular/dev-infra / main

Function main

bazel/rules/rules_angular/src/ng_package/packager/index.ts:47–414  ·  view source on GitHub ↗
(args: string[])

Source from the content-addressed store, hash-verified

45main(process.argv.slice(2));
46
47function main(args: string[]): void {
48 // This utility expects all of its arguments to be specified in a params file generated by
49 // bazel (see https://docs.bazel.build/versions/master/skylark/lib/Args.html#use_param_file).
50 const paramFilePath = args[0];
51
52 // Bazel params may be surrounded with quotes
53 function unquoteParameter(s: string) {
54 return s.replace(/^'(.*)'$/, '$1');
55 }
56
57 // Parameters are specified in the file one per line.
58 const params = fs.readFileSync(paramFilePath, 'utf-8').split('\n').map(unquoteParameter);
59
60 const [
61 // Output directory for the npm package.
62 outputDirExecPath,
63
64 // The package segment of the ng_package rule's label (e.g. 'package/common').
65 owningPackageName,
66
67 // JSON data capturing metadata of the package being built. See `PackageMetadata`.
68 metadataArg,
69
70 // Path to the package's README.md.
71 readmeMd,
72
73 // Path to the package's LICENSE file.
74 licenseFile,
75
76 // List of individual ES2022 modules
77 esm2022Arg,
78
79 // List of static files that should be copied into the package.
80 staticFilesArg,
81
82 // List of side-effectful entry-points
83 sideEffectEntryPointsArg,
84 ] = params;
85
86 const esm2022 = JSON.parse(esm2022Arg) as BazelFileInfo[];
87 const staticFiles = JSON.parse(staticFilesArg) as BazelFileInfo[];
88 const metadata = JSON.parse(metadataArg) as PackageMetadata;
89 const sideEffectEntryPoints = JSON.parse(sideEffectEntryPointsArg) as string[];
90
91 if (readmeMd) {
92 copyFile(readmeMd, 'README.md');
93 }
94
95 if (licenseFile) {
96 copyFile(licenseFile, 'LICENSE');
97 }
98
99 /**
100 * Writes a file with the specified content into the package output.
101 * @param outputRelativePath Relative path in the output directory where the
102 * file is written to.
103 * @param fileContent Content of the file.
104 */

Callers 1

index.tsFile · 0.70

Calls 8

copyFileFunction · 0.85
updatePrimaryPackageJsonFunction · 0.85
writeFileFunction · 0.85
errorMethod · 0.45
stringifyMethod · 0.45

Tested by

no test coverage detected