Skip to content

Commit 6a3b771

Browse files
authored
Merge pull request #38 from fluentci-io/fix/wasm-publish-1
fix publish --wasm command
2 parents 850b5c8 + e139509 commit 6a3b771

File tree

6 files changed

+34
-24
lines changed

6 files changed

+34
-24
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ fluentci # Run the pipeline
8080
fluentci --help
8181

8282
Usage: fluentci [pipeline] [jobs...]
83-
Version: 0.12.8
83+
Version: 0.12.9
8484

8585
Description:
8686

deno.lock

Lines changed: 7 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
packages.default = pkgs.deno2nix.mkExecutable {
2727
pname = "fluentci";
28-
version = "0.12.6";
28+
version = "0.12.9";
2929

3030
src = ./.;
3131
lockfile = "./deno.lock";

src/cmd/publish.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { readAllSync, toml } from "../../deps.ts";
22
import { walk, ZipWriter, BlobWriter, brightGreen, wait } from "../../deps.ts";
3+
import { currentPluginDirExists } from "../utils.ts";
34
import { isLogged, getAccessToken, setupRust } from "../utils.ts";
45
import { validatePackage, validateConfigFiles } from "../validate.ts";
56
import "https://deno.land/x/xhr@0.1.0/mod.ts";
@@ -32,7 +33,7 @@ const publish = async (
3233
});
3334
}
3435

35-
if (paths.length === 0) {
36+
if (paths.length === 0 && !options.wasm) {
3637
console.error("No files found in the current directory");
3738
Deno.exit(1);
3839
}
@@ -46,7 +47,7 @@ const publish = async (
4647
Deno.exit(1);
4748
}
4849

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

58-
validateConfigFiles();
59+
if (!options.wasm) {
60+
validateConfigFiles();
61+
}
5962

6063
if (options.wasm) {
6164
await publishWasm();
@@ -125,6 +128,11 @@ const parseIgnoredFiles = () => {
125128
};
126129

127130
const publishWasm = async () => {
131+
let pluginDir = ".";
132+
if (await currentPluginDirExists()) {
133+
pluginDir = "plugin";
134+
}
135+
128136
await setupRust();
129137

130138
const wasm32 = new Deno.Command("rustup", {
@@ -138,12 +146,12 @@ const publishWasm = async () => {
138146
args: ["-c", "cargo build --target wasm32-unknown-unknown --release"],
139147
stderr: "inherit",
140148
stdout: "inherit",
141-
cwd: "plugin",
149+
cwd: pluginDir,
142150
});
143151
await spawnCommand(build);
144152

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

@@ -152,7 +160,7 @@ const publishWasm = async () => {
152160
const ls = new Deno.Command("bash", {
153161
args: [
154162
"-c",
155-
`ls plugin/target/wasm32-unknown-unknown/release/${cargoToml.package.name.replaceAll(
163+
`ls ${pluginDir}/target/wasm32-unknown-unknown/release/${cargoToml.package.name.replaceAll(
156164
"-",
157165
"_"
158166
)}.wasm`,

src/consts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { dir } from "../deps.ts";
22

3-
export const VERSION = "0.12.8";
3+
export const VERSION = "0.12.9";
44

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

src/utils.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,16 @@ export async function fluentciDirExists(): Promise<boolean> {
8585
}
8686
}
8787

88+
export async function currentPluginDirExists(): Promise<boolean> {
89+
try {
90+
const fluentciDir = await Deno.stat("plugin");
91+
await Deno.stat("plugin/Cargo.toml");
92+
return fluentciDir.isDirectory;
93+
} catch (_) {
94+
return false;
95+
}
96+
}
97+
8898
export async function verifyRequiredDependencies(
8999
dependencies = ["deno", "dagger", "docker"]
90100
) {

0 commit comments

Comments
 (0)