Skip to content

Commit 96d43fc

Browse files
committed
WIP
1 parent e9754ba commit 96d43fc

File tree

3 files changed

+42
-53
lines changed

3 files changed

+42
-53
lines changed

dist/index.js

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

+20-32
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,42 @@
1-
import * as core from '@actions/core';
2-
import { installCli } from './steps/installCli';
3-
import { runChecksJson } from './steps/runChecksJson';
4-
import { runChecksText } from './steps/runChecksText';
5-
import { getConfigContents } from './steps/getConfigContents';
6-
import { getFileDiff } from './steps/getFileDiff';
7-
import { addAnnotations } from './addAnnotations';
8-
import * as semver from 'semver';
1+
import * as core from "@actions/core";
2+
import { installCli } from "./steps/installCli";
3+
import { runChecksJson } from "./steps/runChecksJson";
4+
import { runChecksText } from "./steps/runChecksText";
5+
import { getConfigContents } from "./steps/getConfigContents";
6+
import { getFileDiff } from "./steps/getFileDiff";
7+
import { addAnnotations } from "./addAnnotations";
8+
import * as semver from "semver";
99

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

1414
// This is mockable with process.env.INPUT_ALL_CAPS_NAME
15-
const themeRoot = core.getInput('theme_root') || cwd;
16-
const version = core.getInput('version') || '';
17-
const flags = core.getInput('flags') || '';
18-
const ghToken = core.getInput('token');
19-
const base = core.getInput('base');
15+
const themeRoot = core.getInput("theme_root") || cwd;
16+
const version = core.getInput("version") || "";
17+
const flags = core.getInput("flags") || "";
18+
const ghToken = core.getInput("token");
19+
const base = core.getInput("base");
2020
const devPreview = requiresDevPreview(version);
2121

2222
try {
2323
await installCli(version);
2424
if (ghToken) {
25-
const [{ report, exitCode }, configContent, fileDiff] =
26-
await Promise.all([
27-
runChecksJson(
28-
themeRoot,
29-
shopifyExecutable,
30-
devPreview,
31-
flags,
32-
),
25+
const [{ report, exitCode }, configContent, fileDiff] = await Promise.all(
26+
[
27+
runChecksJson(themeRoot, shopifyExecutable, devPreview, flags),
3328
getConfigContents(themeRoot, shopifyExecutable, devPreview),
3429
getFileDiff(base, cwd),
35-
]);
36-
await addAnnotations(
37-
report,
38-
exitCode,
39-
configContent,
40-
ghToken,
41-
fileDiff,
30+
]
4231
);
32+
await addAnnotations(report, exitCode, configContent, ghToken, fileDiff);
4333
process.exit(exitCode);
4434
} else {
4535
const { exitCode } = await runChecksText(
4636
themeRoot,
4737
shopifyExecutable,
4838
devPreview,
49-
flags,
39+
flags
5040
);
5141
process.exit(exitCode);
5242
}
@@ -58,9 +48,7 @@ async function run() {
5848

5949
function requiresDevPreview(version: string) {
6050
return (
61-
!!version &&
62-
semver.gte(version, '3.50.0') &&
63-
semver.lt(version, '3.55.0')
51+
!!version && semver.gte(version, "3.50.0") && semver.lt(version, "3.55.0")
6452
);
6553
}
6654

src/steps/installCli.ts

+17-16
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,35 @@
1-
import { exec } from '@actions/exec';
2-
import * as semver from 'semver';
1+
import { exec } from "@actions/exec";
2+
import * as semver from "semver";
3+
import { runChecksJson } from "./runChecksJson";
34

4-
const MIN_VERSION = '3.50.0';
5-
const MAX_THEME_VERSION = '3.59.0';
5+
const MIN_VERSION = "3.50.0";
6+
const MAX_THEME_VERSION = "3.59.0";
67

78
export async function installCli(version?: string) {
8-
const versionSuffix = version ? `@${version}` : '';
9+
const versionSuffix = version ? `@${version}` : "";
910

1011
if (!isValidVersion(version)) {
1112
throw new Error(
12-
`Shopify CLI version: ${version} is invalid or smaller than ${MIN_VERSION}`,
13+
`Shopify CLI version: ${version} is invalid or smaller than ${MIN_VERSION}`
1314
);
1415
}
1516

17+
const waiting = await exec(`npm list shopify`);
18+
console.log({ waiting });
1619
await exec(
17-
'npm',
20+
"npm",
1821
[
19-
'install',
20-
'--no-package-lock',
21-
'--no-save',
22+
"install",
23+
"--no-package-lock",
24+
"--no-save",
2225
`@shopify/cli${versionSuffix}`,
23-
shouldIncludeTheme(version)
24-
? `@shopify/theme${versionSuffix}`
25-
: '',
26-
].filter(Boolean),
26+
shouldIncludeTheme(version) ? `@shopify/theme${versionSuffix}` : "",
27+
].filter(Boolean)
2728
);
2829
}
2930

3031
function shouldIncludeTheme(version?: string) {
31-
if (!version || version.includes('experimental')) {
32+
if (!version || version.includes("experimental")) {
3233
return false;
3334
}
3435

@@ -47,7 +48,7 @@ function shouldIncludeTheme(version?: string) {
4748
}
4849

4950
function isValidVersion(version?: string): boolean {
50-
if (!version || version.includes('experimental')) {
51+
if (!version || version.includes("experimental")) {
5152
return true;
5253
}
5354

0 commit comments

Comments
 (0)