Skip to content

Commit

Permalink
fix: fix typo (#32)
Browse files Browse the repository at this point in the history
* fix(install): typo in `install.sh`

* fix: fix typo

* fix(tasks): default allowedPortDeps

---------

Co-authored-by: Yohe-Am <[email protected]>
  • Loading branch information
Natoandro and Yohe-Am authored Jan 13, 2024
1 parent 2f6169c commit f380522
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ghjk /jk/ is a programmable runtime manager.
# stable
curl -fsSL https://raw.githubusercontent.com/metatypedev/ghjk/main/install.sh | bash
# latest (main)
curl -fsSL https://raw.githubusercontent.com/metatypedev/ghjk/main/install.sh | GHJK_VERISON=main bash
curl -fsSL https://raw.githubusercontent.com/metatypedev/ghjk/main/install.sh | GHJK_VERSION=main bash
```

In your project, create a configuration file `ghjk.ts`:
Expand Down
4 changes: 2 additions & 2 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fi
# if custom deno bin is not set, install one
if [ -z "${GHJK_INSTALL_DENO_EXEC+x}" ]; then

GHJK_INSTALL_DENO_EXEC="$GHJK_DIR/bin/deno"
GHJK_INSTALL_DENO_EXEC="$GHJK_SHARE_DIR/bin/deno"
if [ ! -f "$GHJK_INSTALL_DENO_EXEC" ] || [ "$DENO_VERSION" != "v$("$GHJK_INSTALL_DENO_EXEC" --version | head -n 1 | cut -d ' ' -f 2)" ]; then

echo "GHJK_INSTALL_DENO_EXEC not set, installing deno $DENO_VERSION for ghjk"
Expand All @@ -25,7 +25,7 @@ if [ -z "${GHJK_INSTALL_DENO_EXEC+x}" ]; then
exit 1
fi

curl -fsSL https://deno.land/x/install/install.sh | DENO_INSTALL="$GHJK_DIR" sh -s "$DENO_VERSION" >/dev/null
curl -fsSL https://deno.land/x/install/install.sh | DENO_INSTALL="$GHJK_SHARE_DIR" sh -s "$DENO_VERSION" >/dev/null
fi
fi

Expand Down
16 changes: 14 additions & 2 deletions mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,20 @@ export function install(...configs: InstallConfigFat[]) {
export type TaskDefNice =
& Omit<TaskFnDef, "env" | "name" | "dependsOn">
& Partial<Pick<TaskFnDef, "dependsOn">>
& Partial<TaskEnv>;
& Partial<Omit<TaskEnv, "allowedPortDeps">>
& { allowedPortDeps?: AllowedPortDep[] };
export function task(name: string, config: TaskDefNice) {
const allowedPortDeps = Object.fromEntries([
...(config.allowedPortDeps ??
// only add the stdDeps if the task specifies installs
(config.installs ? stdDeps() : []))
.map((dep) =>
[
dep.manifest.name,
portsValidators.allowedPortDep.parse(dep),
] as const
),
]);
tasks[name] = {
name,
fn: config.fn,
Expand All @@ -80,7 +92,7 @@ export function task(name: string, config: TaskDefNice) {
env: {
installs: config.installs ?? [],
env: config.env ?? {},
allowedPortDeps: config.allowedPortDeps ?? {},
allowedPortDeps,
},
};
return name;
Expand Down
12 changes: 11 additions & 1 deletion modules/tasks/exec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,17 @@ export async function execTask(
taskName,
args,
{
...installEnvs,
...Deno.env.toObject(),
...Object.fromEntries(
Object.entries(installEnvs).map(
(
[key, val],
) => [
key,
key.match(/PATH/i) ? `${val}:${Deno.env.get(key) ?? ""}` : val,
],
),
),
...taskEnv.env.env,
},
);
Expand Down
32 changes: 30 additions & 2 deletions tests/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {
type TaskDefTest,
tsGhjkFileFromInstalls,
} from "./utils.ts";
import { protoc } from "../ports/mod.ts";
import * as ghjk from "../mod.ts";
import * as ports from "../ports/mod.ts";

type CustomE2eTestCase = Omit<E2eTestCase, "ePoints" | "tsGhjkfileStr"> & {
ePoint: string;
Expand Down Expand Up @@ -47,7 +48,7 @@ test (ghjk x greet world) = 'Hello moon!'`,
name: "ports",
tasks: [{
name: "protoc",
installs: [protoc()],
installs: [ports.protoc()],
fn: async ({ $ }) => {
await $`protoc --version`;
},
Expand All @@ -56,6 +57,33 @@ test (ghjk x greet world) = 'Hello moon!'`,
stdin: `
ghjk x protoc`,
},
{
name: "port_deps",
tasks: [{
name: "test",
// node depends on tar_aa
installs: [...ports.pipi({ packageName: "pre-commit" })],
allowedPortDeps: ghjk.stdDeps({ enableRuntimes: true }),
fn: async ({ $ }) => {
await $`pre-commit --version`;
},
}],
ePoint: `fish`,
stdin: `ghjk x test`,
},
{
name: "default_port_deps",
tasks: [{
name: "test",
// node depends on tar_aa
installs: [ports.node()],
fn: async ({ $ }) => {
await $`node --version`;
},
}],
ePoint: `fish`,
stdin: `ghjk x test`,
},
{
name: "dependencies",
tasks: [
Expand Down

0 comments on commit f380522

Please sign in to comment.