Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | 1x 1x | import fsp from 'node:fs/promises';
import path from 'node:path';
import type { BuildEnvironment } from './core';
import type { ParsedModuleConfig } from './module-config';
export interface ManifestJson {
/**
* Module name
*/
name: string;
/**
* Scope-specific import mappings
* Type: Record<scope name, import mappings within that scope>
*/
scopes: Record<string, Record<string, string>>;
/**
* Export item configuration
* Type: Record<export path, export item information>
*/
exports: ManifestJsonExports;
/**
* Build output files
*/
files: string[];
/**
* Compiled file information
* Type: Record<source file, compilation information>
*/
chunks: ManifestJsonChunks;
}
/**
* Export item configuration mapping
* Type: Record<export path, export item information>
*/
export type ManifestJsonExports = Record<string, ManifestJsonExport>;
/**
* Export item information
*/
export interface ManifestJsonExport {
/**
* Export item name
*/
name: string;
/**
* Whether to rewrite module import paths
* - true: Rewrite to '{serviceName}/{exportName}' format
* - false: Maintain original import paths
*/
pkg: boolean;
/**
* File path corresponding to the export item
*/
file: string;
/**
* Identifier for the export item
*/
identifier: string;
}
export type ManifestJsonChunks = Record<string, ManifestJsonChunk>;
export interface ManifestJsonChunk {
name: string;
/**
* Current compiled JS file.
*/
js: string;
/**
* Current compiled CSS files.
*/
css: string[];
/**
* Other resource files.
*/
resources: string[];
}
/**
* Get service manifest files
*/
export async function getManifestList(
env: BuildEnvironment,
moduleConfig: ParsedModuleConfig
): Promise<ManifestJson[]> {
return Promise.all(
Object.values(moduleConfig.links).map(async (item) => {
const filename = path.resolve(item[env], 'manifest.json');
try {
const data: ManifestJson = await JSON.parse(
await fsp.readFile(filename, 'utf-8')
);
data.name = item.name;
return data;
} catch (e) {
throw new Error(
`'${item.name}' service '${filename}' file read error on environment '${env}': ${e instanceof Error ? e.message : String(e)}`
);
}
})
);
}
|