Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@factorialco/gat

Package Overview
Dependencies
Maintainers
3
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@factorialco/gat - npm Package Compare versions

Comparing version 1.5.0 to 2.0.0

38

dist/cli.js

@@ -12,14 +12,7 @@ #!/usr/bin/env node

const util_1 = require("util");
const debounce_1 = __importDefault(require("lodash/debounce"));
const execPromise = (0, util_1.promisify)(child_process_1.exec);
const writeFilePromise = (0, util_1.promisify)(fs_1.default.writeFile);
const folder = path_1.default.join(process.cwd(), ".github", "templates");
const parseFile = async (templateFile) => {
// NOTE: can we improve this using ts-node or typescript programatically?
const { stdout } = await execPromise(`npx ts-node ${process.env["GAT_BUILD_FLAGS"] ?? "--swc -T"} ${templateFile}`);
await writeFilePromise(path_1.default.join(process.cwd(), ".github", "workflows", templateFile.split("/").at(-1).replace(".ts", ".yml")), stdout);
};
const cli = new commander_1.Command();
cli
.version("1.0.0")
.version("2.0.0")
.description("Write your GitHub Actions workflows using TypeScript");

@@ -29,34 +22,9 @@ cli

.description("Transpile all Gat templates into GitHub Actions workflows.")
.argument("[file]", "(Optional) A Gat template file")
.action(async (file) => {
.action(async () => {
if (!fs_1.default.existsSync(path_1.default.join(folder, "..", "workflows"))) {
fs_1.default.mkdirSync(path_1.default.join(folder, "..", "workflows"));
}
if (file !== undefined) {
await parseFile(file);
}
else {
await Promise.all(fs_1.default.readdirSync(folder).map(async (templateFile) => {
if (!templateFile.match(/^shared$/)) {
await parseFile(`${path_1.default.join(folder, templateFile)}`);
}
}));
}
await execPromise(`npx ts-node ${process.env["GAT_BUILD_FLAGS"] ?? "--swc -T"} ${path_1.default.join(folder, "index.ts")}`);
process.exit(0);
});
cli
.command("watch")
.description("Watch file changes in your Gat templates folder and transpile them automatically.")
.action(async () => {
const parseWatchedFile = (0, debounce_1.default)(async (fileName) => {
const start = process.hrtime.bigint();
process.stdout.write(`😸 Detected change on file ${fileName}. Transpiling... `);
await parseFile(path_1.default.join(folder, fileName.toString()));
console.log(`Done in ${(Number(process.hrtime.bigint() - start) / 1000000).toFixed(2)}ms`);
}, 1000);
console.log(`😼 Watching file changes on ${folder}...`);
fs_1.default.watch(folder).on("change", (_eventName, fileName) => {
parseWatchedFile(fileName);
});
});
cli.parse(process.argv);

2

dist/workflow.d.ts

@@ -27,4 +27,4 @@ import { ConcurrencyGroup, Job, JobOptions, StringWithNoSpaces } from "./job";

private assignRunner;
compile(): string;
compile(filepath?: string): string | Promise<void>;
}
export {};

@@ -9,2 +9,6 @@ "use strict";

const kebabCase_1 = __importDefault(require("lodash/kebabCase"));
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const util_1 = require("util");
const writeFilePromise = (0, util_1.promisify)(fs_1.default.writeFile);
const DEFAULT_RUNNERS = ["ubuntu-22.04"];

@@ -47,3 +51,3 @@ class Workflow {

}
compile() {
compile(filepath) {
const result = {

@@ -87,6 +91,11 @@ name: this.name,

"fail-fast": false,
matrix: typeof matrix === 'string' ? matrix : {
...Object.fromEntries(matrix.elements.map(({ id, options }) => [id, options])),
include: matrix.extra,
},
matrix: typeof matrix === "string"
? matrix
: {
...Object.fromEntries(matrix.elements.map(({ id, options }) => [
id,
options,
])),
include: matrix.extra,
},
}

@@ -120,6 +129,7 @@ : undefined,

})}`;
console.log(compiled);
return compiled;
if (!filepath)
return compiled;
return writeFilePromise(path_1.default.join(process.cwd(), ".github", "workflows", filepath), compiled);
}
}
exports.Workflow = Workflow;
{
"name": "@factorialco/gat",
"version": "1.5.0",
"version": "2.0.0",
"description": "Write your GitHub Actions workflows using TypeScript",

@@ -5,0 +5,0 @@ "bin": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc