-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: NodeJS WASM CLI parity with native binary
- Loading branch information
1 parent
2f8be1d
commit c455989
Showing
14 changed files
with
201 additions
and
116 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,10 +5,10 @@ license = "GPL-3.0-only" | |
homepage = "https://github.com/mpalmer/action-validator" | ||
repository = "https://github.com/mpalmer/action-validator" | ||
include = [ | ||
"/LICENCE", | ||
"/src/*.rs", | ||
"/src/schemastore/src/schemas/json/github-workflow.json", | ||
"/src/schemastore/src/schemas/json/github-action.json" | ||
"/LICENCE", | ||
"/src/*.rs", | ||
"/src/schemastore/src/schemas/json/github-workflow.json", | ||
"/src/schemastore/src/schemas/json/github-action.json", | ||
] | ||
version = "0.0.0-git" | ||
authors = ["Matt Palmer <[email protected]>"] | ||
|
@@ -31,18 +31,19 @@ serde_yaml = "0.9.17" | |
# Install 4.x once published to crates.io | ||
valico = "4.0.0-rc.0" | ||
|
||
wasm-bindgen = "0.2.63" | ||
wasm-bindgen = "0.2.84" | ||
|
||
# The `console_error_panic_hook` crate provides better debugging of panics by | ||
# logging them with `console.error`. This is great for development, but requires | ||
# all the `std::fmt` and `std::panicking` infrastructure, so isn't great for | ||
# code size when deploying. | ||
console_error_panic_hook = { version = "0.1.6", optional = true } | ||
console_error_panic_hook = { version = "0.1.7", optional = true } | ||
|
||
serde-wasm-bindgen = "0.4.5" | ||
js-sys = "0.3.77" | ||
|
||
[dev-dependencies] | ||
wasm-bindgen-test = "0.3.13" | ||
wasm-bindgen-test = "0.3.34" | ||
|
||
[profile.release] | ||
# Tell `rustc` to optimize for small code size. | ||
|
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,56 +1,6 @@ | ||
#!/usr/bin/env node | ||
// @ts-check | ||
|
||
import chalk from "chalk"; | ||
import fs from "fs"; | ||
import * as actionValidator from "@action-validator/core"; | ||
|
||
function usage(exitCode = 0) { | ||
console.log( | ||
[ | ||
`${chalk.underline("Usage:")} action-validator <path_to_action_yaml>`, | ||
"", | ||
`${chalk.underline("Arguments:")}`, | ||
" <path_to_action_yaml> Input file", | ||
].join("\n") | ||
); | ||
|
||
process.exit(exitCode); | ||
} | ||
|
||
const args = process.argv.slice(2); | ||
if (args.length !== 1) { | ||
usage(1); | ||
} | ||
|
||
if (args[0] === "--help" || args[0] === "-h") { | ||
usage(); | ||
} | ||
|
||
const pathToActionYaml = args[0]; | ||
|
||
if (!fs.existsSync(pathToActionYaml)) { | ||
console.error(`File not found: ${pathToActionYaml}`); | ||
process.exit(1); | ||
} | ||
|
||
const contents = fs.readFileSync(pathToActionYaml, "utf8"); | ||
const actionType = | ||
pathToActionYaml.endsWith("action.yml") || | ||
pathToActionYaml.endsWith("action.yaml") | ||
? "action" | ||
: "workflow"; | ||
|
||
const result = (() => { | ||
switch (actionType) { | ||
case "action": | ||
return actionValidator.validateAction(contents); | ||
case "workflow": | ||
return actionValidator.validateWorkflow(contents); | ||
} | ||
})(); | ||
|
||
if (result.errors.length > 0) { | ||
console.error(JSON.stringify(result, null, 2)); | ||
process.exit(1); | ||
} | ||
actionValidator.main(process.argv.slice(1)); |
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,3 +1,4 @@ | ||
/node_modules | ||
/snippets | ||
action_validator_bg.wasm | ||
action_validator.js |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
npx wasm-pack build --out-dir target/wasm-pack/build --no-typescript --target nodejs --features js | ||
rm -rf packages/core/snippets | ||
cp -R target/wasm-pack/build/snippets packages/core/snippets | ||
cp target/wasm-pack/build/action_validator_bg.wasm packages/core/ | ||
cp target/wasm-pack/build/action_validator.js packages/core/ |
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,7 @@ | ||
const console = require('node:console'); | ||
const fs = require('node:fs'); | ||
const process = require('node:process'); | ||
|
||
module.exports.console = console; | ||
module.exports.fs = fs; | ||
module.exports.process = process; |
Oops, something went wrong.