Skip to content

Commit 1c7c55e

Browse files
authored
Merge pull request #514 from Shopify/ap.expand-liquid-check-unstaged
Ensure no unstaged changes after expanding liquid
2 parents de24310 + 8f92311 commit 1c7c55e

File tree

7 files changed

+34
-3028
lines changed

7 files changed

+34
-3028
lines changed

.github/workflows/javascript.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ jobs:
1414
- name: Install dependencies
1515
run: yarn
1616
- name: Expand liquid
17-
run: yarn expand-liquid vanilla-js
17+
run: CI=1 yarn expand-liquid vanilla-js
1818
- name: Install workspace dependencies
1919
run: yarn
2020
- name: Generate types
2121
run: yarn typegen
2222
- name: Test
23-
run: yarn test-js
23+
run: yarn workspaces run test run

.github/workflows/rust.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- name: Install node dependencies
2020
run: yarn
2121
- name: Expand liquid
22-
run: yarn expand-liquid rust
22+
run: CI=1 yarn expand-liquid rust
2323
- name: Run cargo fmt
2424
run: cargo fmt --check
2525
- name: Run clippy

.github/workflows/typescript.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ jobs:
1414
- name: Install dependencies
1515
run: yarn
1616
- name: Expand liquid
17-
run: yarn expand-liquid typescript
17+
run: CI=1 yarn expand-liquid typescript
1818
- name: Install workspace dependencies
1919
run: yarn
2020
- name: Generate types
2121
run: yarn typegen
2222
- name: Test
23-
run: yarn test-ts
23+
run: yarn workspaces run test run

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ node_modules
44
.env
55
.DS_Store
66
.yalc
7+
yarn.lock
78

89
# These files are generated from Shopify CLI templating and should not be committed to this repo
910

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
"scripts": {
1515
"expand-liquid": "node ./util/expand-liquid.js",
1616
"typegen": "yarn workspaces run graphql-code-generator --config package.json",
17-
"test-js": "yarn expand-liquid vanilla-js && yarn workspaces run test run",
18-
"test-ts": "yarn expand-liquid typescript && yarn workspaces run test run"
17+
"test-js": "yarn expand-liquid vanilla-js && yarn && yarn typegen && yarn workspaces run test run",
18+
"test-ts": "yarn expand-liquid typescript && yarn && yarn typegen && yarn workspaces run test run"
1919
},
2020
"private": true,
2121
"workspaces": [

util/expand-liquid.js

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import path from 'path';
99
import fs from 'node:fs/promises';
1010
import { existsSync } from 'fs';
1111
import toml from '@iarna/toml';
12+
import { exec } from 'child_process';
1213

1314
async function expandLiquidTemplates(template, liquidData) {
1415
const entries = await glob([path.join(template, "**/*.liquid")], {
@@ -106,6 +107,26 @@ async function expandExtensionLiquidTemplates(domainName, flavor) {
106107
console.log();
107108
}
108109

110+
function ensureNoGitChanges() {
111+
exec('git status --porcelain', (error, stdout, _stderr) => {
112+
if (error) {
113+
console.error(`error calling \`git status\`: ${error}`);
114+
process.exit(1);;
115+
}
116+
if (stdout) {
117+
console.error('Untracked files detected:\n', stdout);
118+
exec('git diff', (error, stdout, _stderr) => {
119+
if (error) {
120+
console.error(`error calling \`git diff\`: ${error}`);
121+
} else {
122+
console.log(`Git diff:\n${stdout}`);
123+
}
124+
process.exit(1);
125+
});
126+
}
127+
});
128+
}
129+
109130
const flavor = process.argv[2] || "vanilla-js";
110131

111132
const SAMPLE_APP_DIR = 'sample-apps';
@@ -116,4 +137,8 @@ for (const domain of DOMAINS) {
116137
await expandExtensionLiquidTemplates(domain, flavor);
117138
}
118139

119-
console.log('The above files should be added to .gitignore if they have not already been added.');
140+
console.log('The above files should be added to .gitignore if they have not already been added.\n');
141+
142+
if (process.env.CI) {
143+
ensureNoGitChanges();
144+
}

0 commit comments

Comments
 (0)