Improve flake-dirs handling logic

This commit is contained in:
Luc Perkins 2024-05-23 15:48:19 -03:00
parent c7eb3f32c9
commit b6aab91cde
No known key found for this signature in database
GPG key ID: 16DB1108FB591835
3 changed files with 28 additions and 14 deletions

19
dist/index.js vendored
View file

@ -94781,29 +94781,36 @@ var UpdateFlakeLockAction = class extends DetSysAction {
this.flakeInputs = inputs_exports.getArrayOfStrings("inputs", "space");
this.nixOptions = inputs_exports.getArrayOfStrings("nix-options", "space");
this.pathToFlakeDir = inputs_exports.getStringOrNull("path-to-flake-dir");
this.flakeDirs = inputs_exports.getArrayOfStrings("flake-dirs", "space");
this.validateInputs();
}
async main() {
await this.update();
await this.updateFlakeLock();
}
// No post phase
async post() {
}
async update() {
get flakeDirs() {
const flakeDirs = inputs_exports.getStringOrNull("flake-dirs");
if (flakeDirs !== null) {
return flakeDirs.trim().split(" ");
} else {
return null;
}
}
async updateFlakeLock() {
if (this.flakeDirs !== null && this.flakeDirs.length > 0) {
core.debug(
`Running flake lock update in multiple directories: ${this.flakeDirs.map((dir) => `\`${dir}\``).join(" ")}`
);
for (const directory of this.flakeDirs) {
await this.updateFlake(directory);
await this.updateFlakeInDirectory(directory);
}
} else {
const flakeDir = this.pathToFlakeDir ?? ".";
await this.updateFlake(flakeDir);
await this.updateFlakeInDirectory(flakeDir);
}
}
async updateFlake(flakeDir) {
async updateFlakeInDirectory(flakeDir) {
this.ensureDirectoryExists(flakeDir);
this.ensureDirectoryIsFlake(flakeDir);
core.debug(`Running flake lock update in directory \`${flakeDir}\``);

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View file

@ -11,7 +11,6 @@ class UpdateFlakeLockAction extends DetSysAction {
private nixOptions: string[];
private flakeInputs: string[];
private pathToFlakeDir: string | null;
private flakeDirs: string[] | null;
constructor() {
super({
@ -24,35 +23,43 @@ class UpdateFlakeLockAction extends DetSysAction {
this.flakeInputs = inputs.getArrayOfStrings("inputs", "space");
this.nixOptions = inputs.getArrayOfStrings("nix-options", "space");
this.pathToFlakeDir = inputs.getStringOrNull("path-to-flake-dir");
this.flakeDirs = inputs.getArrayOfStrings("flake-dirs", "space");
this.validateInputs();
}
async main(): Promise<void> {
await this.update();
await this.updateFlakeLock();
}
// No post phase
async post(): Promise<void> {}
async update(): Promise<void> {
private get flakeDirs(): string[] | null {
const flakeDirs = inputs.getStringOrNull("flake-dirs");
if (flakeDirs !== null) {
return flakeDirs.trim().split(" ");
} else {
return null;
}
}
async updateFlakeLock(): Promise<void> {
if (this.flakeDirs !== null && this.flakeDirs.length > 0) {
actionsCore.debug(
`Running flake lock update in multiple directories: ${this.flakeDirs.map((dir) => `\`${dir}\``).join(" ")}`,
);
for (const directory of this.flakeDirs) {
await this.updateFlake(directory);
await this.updateFlakeInDirectory(directory);
}
} else {
// Set directory to root if not specified
const flakeDir = this.pathToFlakeDir ?? ".";
await this.updateFlake(flakeDir);
await this.updateFlakeInDirectory(flakeDir);
}
}
private async updateFlake(flakeDir: string): Promise<void> {
private async updateFlakeInDirectory(flakeDir: string): Promise<void> {
this.ensureDirectoryExists(flakeDir);
this.ensureDirectoryIsFlake(flakeDir);