-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(ghjk.ts): replace secureConfig with hack.ts
- Loading branch information
Showing
20 changed files
with
554 additions
and
324 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
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 |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
}, | ||
"fmt": { | ||
"exclude": [ | ||
"*.md", | ||
"**/*.md", | ||
".ghjk/**", | ||
".deno-dir/**", | ||
|
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
export { sophon } from "../../hack.ts"; | ||
import { config, env, install, task } from "../../hack.ts"; | ||
import * as ports from "../../ports/mod.ts"; | ||
|
||
config({ | ||
// we can change which environment | ||
// is activated by default for example | ||
// when we enter the directory | ||
defaultEnv: "main", | ||
// set the env all others envs will by | ||
// default inherit from | ||
defaultBaseEnv: "main", | ||
}); | ||
|
||
env("test", { | ||
installs: [ports.unzip()], | ||
}); | ||
|
||
env("ci") | ||
.install(ports.opentofu_ghrel()); | ||
|
||
// top level `install` calls just | ||
// go to an enviroment called "main" | ||
install(ports.protoc()); | ||
|
||
// we can modify "main" directly | ||
env("main") | ||
// hooks execute when environments are | ||
// activated/deactivated in interactive shells | ||
.onEnter(task(($) => $`echo enter`)) | ||
.onExit(task(($) => $`echo exit`)); |
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 |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import { stdDeps } from "../../files/mod.ts"; | ||
import { file } from "../../mod.ts"; | ||
import * as ports from "../../ports/mod.ts"; | ||
|
||
const ghjk = file({ | ||
// configre an empty env so that no ports are avail by default in our workdir | ||
defaultEnv: "empty", | ||
envs: [{ name: "empty", inherit: false }], | ||
// we wan't all other envs to start from empty unless they opt otherwise | ||
defaultBaseEnv: "empty", | ||
|
||
// we won't use the following for now | ||
// but they pretty much configure the "main" env | ||
allowedBuildDeps: [], | ||
installs: [], | ||
stdDeps: true, | ||
enableRuntimes: true, | ||
// tasks aren't attached to envs | ||
// but have their own env | ||
tasks: [], | ||
}); | ||
|
||
// we need this export for this file to be a valid ghjkfile | ||
// it's the one thing used by the ghjk host implementation to | ||
// interact with your ghjkfile | ||
export const sophon = ghjk.sophon; | ||
|
||
const { install, env, task } = ghjk; | ||
|
||
// we can configure main like this as well | ||
env("main") | ||
// provision env vars to be acccessbile in the env | ||
.var("RUST_LOG", "info,actix=warn") | ||
// provision programs to be avail in the env | ||
.install(ports.jq_ghrel()) | ||
.allowedBuildDeps([ | ||
// ports can use the following installs at build time | ||
// very WIP mechanism but this is meant to prevent ports from | ||
// pulling whatever dependency they want at build time unless | ||
// explicityl allowed to do so | ||
ports.cpy_bs({ version: "3.8.18", releaseTag: "20240224" }), | ||
ports.node({}), | ||
ports.rust({ version: "stable" }), | ||
// add the std deps including the runtime ports. | ||
// These includes node and python but still, precedence is given | ||
// to our configuration of those ports above | ||
...stdDeps({ enableRuntimes: true }), | ||
]); | ||
|
||
// these top level installs go to the main env as well | ||
install( | ||
ports.rust({ version: "stable" }), | ||
ports.protoc(), | ||
); | ||
|
||
const ci = env("ci", { | ||
// this inherits from main so it gets protoc and curl | ||
inherit: "main", | ||
// extra installs | ||
installs: [ports.jq_ghrel()], | ||
// it has extra allowed deps | ||
allowedBuildDeps: [ports.node()], | ||
// more env vars | ||
vars: { | ||
CI: 1, | ||
}, | ||
desc: "do ci stuff", | ||
}); | ||
|
||
// tasks are invocable from the cli | ||
task("install-app", ($) => $`cargo fetch`); | ||
|
||
task("build-app", { | ||
dependsOn: "install-app", | ||
// the task's env inherits from ci | ||
inherit: ci.name, | ||
// it can add more items to that env | ||
installs: [], | ||
// vars | ||
vars: { | ||
RUST_BACKTRACE: 1, | ||
}, | ||
// allowed build deps | ||
allowedBuildDeps: [ports.zstd()], | ||
desc: "build the app", | ||
fn: async ($) => { | ||
await $`cargo build -p app`; | ||
// we can access tar here from the ci env | ||
await $`tar xcv ./target/debug/app -o app.tar.gz`; | ||
}, | ||
}); | ||
|
||
env("dev") | ||
.inherit("main") | ||
// we can set tasks to run on activation/decativation | ||
.onEnter(task(($) => $`echo enter`)) | ||
.onEnter(task({ | ||
workingDir: "..", | ||
fn: ($) => $`ls`, | ||
})); |
This file was deleted.
Oops, something went wrong.
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.