-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #290 from ordo-pink/drop-react
Drop react in Ordo core
- Loading branch information
Showing
246 changed files
with
11,802 additions
and
10,504 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,39 @@ | ||
// SPDX-FileCopyrightText: Copyright 2024, 谢尔盖||↓ and the Ordo.pink contributors | ||
// SPDX-License-Identifier: Unlicense | ||
|
||
import { Oath, invokers0, ops0 } from "@ordo-pink/oath" | ||
import { | ||
checkFilesExist0, | ||
createProgress, | ||
direntsToDirs, | ||
getExistingPaths, | ||
getNames, | ||
runBunCommand0, | ||
check_files_exist, | ||
create_progress, | ||
dirents_to_dirs, | ||
get_dirent_names, | ||
get_existing_paths, | ||
run_bun_command, | ||
} from "@ordo-pink/binutil" | ||
import { Oath } from "@ordo-pink/oath" | ||
import { readdir0 } from "@ordo-pink/fs" | ||
|
||
export const compile = () => | ||
readdir0("./srv", { withFileTypes: true }) | ||
.map(direntsToDirs) | ||
.map(getNames) | ||
.map(namesToCompileScriptPaths) | ||
.chain(checkFilesExist0) | ||
.map(getExistingPaths) | ||
.tap(startProgress) | ||
.chain(runCompileScripts) | ||
.map(finishProgress) | ||
.orElse(console.error) | ||
.pipe(ops0.map(dirents_to_dirs)) | ||
.pipe(ops0.map(get_dirent_names)) | ||
.pipe(ops0.map(names_to_compile_script_paths)) | ||
.pipe(ops0.chain(check_files_exist)) | ||
.pipe(ops0.map(get_existing_paths)) | ||
.pipe(ops0.tap(start_progress)) | ||
.pipe(ops0.chain(run_compile_scripts)) | ||
.pipe(ops0.map(finish_progress)) | ||
.invoke(invokers0.or_else(console.error)) | ||
|
||
// --- Internal --- | ||
|
||
const progress = createProgress() | ||
const progress = create_progress() | ||
|
||
const startProgress = () => progress.start("Compiling binaries") | ||
const start_progress = () => progress.start("Compiling binaries") | ||
const incProgress = () => progress.inc() | ||
const finishProgress = () => progress.finish() | ||
const finish_progress = () => progress.finish() | ||
|
||
const namesToCompileScriptPaths = (names: string[]) => | ||
const names_to_compile_script_paths = (names: string[]) => | ||
names.map(name => `./srv/${name}/bin/compile.ts`) | ||
const runCompileScript = (path: string) => | ||
runBunCommand0(`run ${path}`, { stdout: "pipe", stderr: "pipe" }).tap(incProgress) | ||
const runCompileScripts = (paths: string[]) => Oath.all(paths.map(runCompileScript)) | ||
run_bun_command(`run ${path}`, { stdout: "pipe", stderr: "pipe" }).pipe(ops0.tap(incProgress)) | ||
const run_compile_scripts = (paths: string[]) => Oath.Merge(paths.map(runCompileScript)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,49 @@ | ||
// SPDX-FileCopyrightText: Copyright 2024, 谢尔盖||↓ and the Ordo.pink contributors | ||
// SPDX-License-Identifier: Unlicense | ||
|
||
import { Oath } from "@ordo-pink/oath" | ||
import { Oath, invokers0, ops0 } from "@ordo-pink/oath" | ||
import { dir_exists0 } from "@ordo-pink/fs" | ||
import { runAsyncCommand0 } from "@ordo-pink/binutil" | ||
import { run_async_command } from "@ordo-pink/binutil" | ||
|
||
export const exec = (location?: string, command?: string) => | ||
Oath.fromNullable(location) | ||
.map(location => (location.startsWith("./") ? location.slice(2) : location)) | ||
.rejectedMap(() => "Location not provided") | ||
.chain(location => | ||
Oath.fromBoolean( | ||
() => location.startsWith("lib") || location.startsWith("srv"), | ||
() => location, | ||
() => | ||
`Provided location "${location}" is invalid. Only "lib/*" or "srv/*" locations are supported.`, | ||
Oath.FromNullable(location) | ||
.pipe(ops0.map(location => (location.startsWith("./") ? location.slice(2) : location))) | ||
.pipe(ops0.rejected_map(() => "Location not provided")) | ||
.pipe( | ||
ops0.chain(location => | ||
Oath.If(location.startsWith("lib") || location.startsWith("srv"), { | ||
T: () => location, | ||
F: () => | ||
`Provided location "${location}" is invalid. Only "lib/*" or "srv/*" locations are supported.`, | ||
}), | ||
), | ||
) | ||
.chain(location => | ||
Oath.fromNullable(command) | ||
.rejectedMap(() => "Command not provided") | ||
.chain(command => | ||
dir_exists0(location).chain(exists => | ||
Oath.fromBoolean( | ||
() => exists, | ||
() => ({ location, command }), | ||
() => `Path "${location}" does not exist`, | ||
.pipe( | ||
ops0.chain(location => | ||
Oath.FromNullable(command) | ||
.pipe(ops0.rejected_map(() => "Command not provided")) | ||
.pipe( | ||
ops0.chain(command => | ||
dir_exists0(location).pipe( | ||
ops0.chain(exists => | ||
Oath.If(exists, { | ||
T: () => ({ location, command }), | ||
F: () => `Path "${location}" does not exist`, | ||
}), | ||
), | ||
), | ||
), | ||
), | ||
), | ||
), | ||
) | ||
.chain(({ location, command }) => | ||
runAsyncCommand0(command, { cwd: location, stdin: "pipe", stdout: "pipe", stderr: "pipe" }), | ||
.pipe( | ||
ops0.chain(({ location, command }) => | ||
run_async_command(command, { | ||
cwd: location, | ||
stdin: "pipe", | ||
stdout: "pipe", | ||
stderr: "pipe", | ||
}), | ||
), | ||
) | ||
.orElse(console.error) | ||
.invoke(invokers0.or_else(console.error)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.