Skip to content

Commit

Permalink
Merge pull request #38 from fluentci-io/fix/wasm-publish-1
Browse files Browse the repository at this point in the history
fix publish --wasm command
  • Loading branch information
tsirysndr authored Apr 18, 2024
2 parents 850b5c8 + e139509 commit 6a3b771
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 24 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ fluentci # Run the pipeline
fluentci --help

Usage: fluentci [pipeline] [jobs...]
Version: 0.12.8
Version: 0.12.9

Description:

Expand Down
22 changes: 7 additions & 15 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

packages.default = pkgs.deno2nix.mkExecutable {
pname = "fluentci";
version = "0.12.6";
version = "0.12.9";

src = ./.;
lockfile = "./deno.lock";
Expand Down
20 changes: 14 additions & 6 deletions src/cmd/publish.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { readAllSync, toml } from "../../deps.ts";
import { walk, ZipWriter, BlobWriter, brightGreen, wait } from "../../deps.ts";
import { currentPluginDirExists } from "../utils.ts";
import { isLogged, getAccessToken, setupRust } from "../utils.ts";
import { validatePackage, validateConfigFiles } from "../validate.ts";
import "https://deno.land/x/xhr@0.1.0/mod.ts";
Expand Down Expand Up @@ -32,7 +33,7 @@ const publish = async (
});
}

if (paths.length === 0) {
if (paths.length === 0 && !options.wasm) {
console.error("No files found in the current directory");
Deno.exit(1);
}
Expand All @@ -46,7 +47,7 @@ const publish = async (
Deno.exit(1);
}

if (!validatePackage(paths.map((x) => x.path))) {
if (!validatePackage(paths.map((x) => x.path)) && !options.wasm) {
console.error(
`A valid FluentCI package must contain ${brightGreen(
"mod.ts"
Expand All @@ -55,7 +56,9 @@ const publish = async (
Deno.exit(1);
}

validateConfigFiles();
if (!options.wasm) {
validateConfigFiles();
}

if (options.wasm) {
await publishWasm();
Expand Down Expand Up @@ -125,6 +128,11 @@ const parseIgnoredFiles = () => {
};

const publishWasm = async () => {
let pluginDir = ".";
if (await currentPluginDirExists()) {
pluginDir = "plugin";
}

await setupRust();

const wasm32 = new Deno.Command("rustup", {
Expand All @@ -138,12 +146,12 @@ const publishWasm = async () => {
args: ["-c", "cargo build --target wasm32-unknown-unknown --release"],
stderr: "inherit",
stdout: "inherit",
cwd: "plugin",
cwd: pluginDir,
});
await spawnCommand(build);

const cargoToml = toml.parse(
Deno.readTextFileSync("plugin/Cargo.toml")
Deno.readTextFileSync(`${pluginDir}/Cargo.toml`)
// deno-lint-ignore no-explicit-any
) as Record<string, any>;

Expand All @@ -152,7 +160,7 @@ const publishWasm = async () => {
const ls = new Deno.Command("bash", {
args: [
"-c",
`ls plugin/target/wasm32-unknown-unknown/release/${cargoToml.package.name.replaceAll(
`ls ${pluginDir}/target/wasm32-unknown-unknown/release/${cargoToml.package.name.replaceAll(
"-",
"_"
)}.wasm`,
Expand Down
2 changes: 1 addition & 1 deletion src/consts.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { dir } from "../deps.ts";

export const VERSION = "0.12.8";
export const VERSION = "0.12.9";

export const BASE_URL = "https://api.fluentci.io/v1";

Expand Down
10 changes: 10 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ export async function fluentciDirExists(): Promise<boolean> {
}
}

export async function currentPluginDirExists(): Promise<boolean> {
try {
const fluentciDir = await Deno.stat("plugin");
await Deno.stat("plugin/Cargo.toml");
return fluentciDir.isDirectory;
} catch (_) {
return false;
}
}

export async function verifyRequiredDependencies(
dependencies = ["deno", "dagger", "docker"]
) {
Expand Down

0 comments on commit 6a3b771

Please sign in to comment.