Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ export class JsonFields {
return new JsonFields(Reflect.get(this.value, name), this.source, [...this.place, name]);
}

public field(name: string): unknown {
return Reflect.get(this.value, name);
Comment thread
rostislavrotaru marked this conversation as resolved.
Resolved
}

public toJson(): object {
return this.value;
}
Expand Down
13 changes: 11 additions & 2 deletions src/noldova.ui.components.angular/scripts/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ export class Build extends Script {
private static readonly INPUTS_OPTION: string = "--inputs";
private static readonly LIST_COPIES_END_LINE: string = "end of copies";
private static readonly WORKSPACE_FIELDS: readonly string[] = ["scripts", "devDependencies", "allowScripts"];
private static readonly VERSION_FIELD: string = "version";
private static readonly COMMIT_FIELD: string = "gitHead";

public override async runAsync(): Promise<void> {
const arguments_ = process.argv.slice(2);
Expand Down Expand Up @@ -281,8 +283,15 @@ export class Build extends Script {
}

private static stampManifest(text: string, version: string, commit: string | null): string {
const fields = Object.fromEntries(Object.entries(JSON.parse(text) as Readonly<Record<string, unknown>>).filter(([t]) => !Build.WORKSPACE_FIELDS.includes(t)));
return JSON.stringify({ ...fields, version, ...(commit === null ? {} : { gitHead: commit }) }, null, 2);
const manifest = JsonFields.parse(text, Build.PACKAGE_MANIFEST_FILE_NAME);
const fields = new Map<string, unknown>();
for (const name of manifest.names())
if (!Build.WORKSPACE_FIELDS.includes(name))
fields.set(name, manifest.field(name));
fields.set(Build.VERSION_FIELD, version);
if (commit !== null)
fields.set(Build.COMMIT_FIELD, commit);
return JSON.stringify(Object.fromEntries(fields), null, 2);
}

private static optionAlone(option: string): string {
Expand Down
Loading