Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
graygilmore committed Jan 28, 2025
1 parent e9754ba commit 38f8612
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 37 deletions.
10 changes: 5 additions & 5 deletions dist/index.js

Large diffs are not rendered by default.

57 changes: 25 additions & 32 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,52 +1,47 @@
import * as core from '@actions/core';
import { installCli } from './steps/installCli';
import { runChecksJson } from './steps/runChecksJson';
import { runChecksText } from './steps/runChecksText';
import { getConfigContents } from './steps/getConfigContents';
import { getFileDiff } from './steps/getFileDiff';
import { addAnnotations } from './addAnnotations';
import * as semver from 'semver';
import * as core from "@actions/core";
import { installCli } from "./steps/installCli";
import { runChecksJson } from "./steps/runChecksJson";
import { runChecksText } from "./steps/runChecksText";
import { getConfigContents } from "./steps/getConfigContents";
import { getFileDiff } from "./steps/getFileDiff";
import { addAnnotations } from "./addAnnotations";
import * as semver from "semver";
import { getExecOutput } from "@actions/exec";

async function run() {
const cwd = process.cwd();
const shopifyExecutable = `${cwd}/node_modules/.bin/shopify`;

// This is mockable with process.env.INPUT_ALL_CAPS_NAME
const themeRoot = core.getInput('theme_root') || cwd;
const version = core.getInput('version') || '';
const flags = core.getInput('flags') || '';
const ghToken = core.getInput('token');
const base = core.getInput('base');
const themeRoot = core.getInput("theme_root") || cwd;
const version = core.getInput("version") || "";
const flags = core.getInput("flags") || "";
const ghToken = core.getInput("token");
const base = core.getInput("base");
const devPreview = requiresDevPreview(version);

try {
const { exitCode, stdout, stderr } = await getExecOutput(
`npm list shopify`
);
console.log({ exitCode, stdout, stderr });
await installCli(version);
if (ghToken) {
const [{ report, exitCode }, configContent, fileDiff] =
await Promise.all([
runChecksJson(
themeRoot,
shopifyExecutable,
devPreview,
flags,
),
const [{ report, exitCode }, configContent, fileDiff] = await Promise.all(
[
runChecksJson(themeRoot, shopifyExecutable, devPreview, flags),
getConfigContents(themeRoot, shopifyExecutable, devPreview),
getFileDiff(base, cwd),
]);
await addAnnotations(
report,
exitCode,
configContent,
ghToken,
fileDiff,
]
);
await addAnnotations(report, exitCode, configContent, ghToken, fileDiff);
process.exit(exitCode);
} else {
const { exitCode } = await runChecksText(
themeRoot,
shopifyExecutable,
devPreview,
flags,
flags
);
process.exit(exitCode);
}
Expand All @@ -58,9 +53,7 @@ async function run() {

function requiresDevPreview(version: string) {
return (
!!version &&
semver.gte(version, '3.50.0') &&
semver.lt(version, '3.55.0')
!!version && semver.gte(version, "3.50.0") && semver.lt(version, "3.55.0")
);
}

Expand Down

0 comments on commit 38f8612

Please sign in to comment.