Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure no unstaged changes after expanding liquid #514

Merged
merged 1 commit into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/javascript.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
- name: Install dependencies
run: yarn
- name: Expand liquid
run: yarn expand-liquid vanilla-js
run: CI=1 yarn expand-liquid vanilla-js
- name: Install workspace dependencies
run: yarn
- name: Generate types
run: yarn typegen
- name: Test
run: yarn test-js
run: yarn workspaces run test run
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Install node dependencies
run: yarn
- name: Expand liquid
run: yarn expand-liquid rust
run: CI=1 yarn expand-liquid rust
- name: Run cargo fmt
run: cargo fmt --check
- name: Run clippy
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/typescript.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
- name: Install dependencies
run: yarn
- name: Expand liquid
run: yarn expand-liquid typescript
run: CI=1 yarn expand-liquid typescript
- name: Install workspace dependencies
run: yarn
- name: Generate types
run: yarn typegen
- name: Test
run: yarn test-ts
run: yarn workspaces run test run
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ node_modules
.env
.DS_Store
.yalc
yarn.lock

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

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"scripts": {
"expand-liquid": "node ./util/expand-liquid.js",
"typegen": "yarn workspaces run graphql-code-generator --config package.json",
"test-js": "yarn expand-liquid vanilla-js && yarn workspaces run test run",
"test-ts": "yarn expand-liquid typescript && yarn workspaces run test run"
"test-js": "yarn expand-liquid vanilla-js && yarn && yarn typegen && yarn workspaces run test run",
"test-ts": "yarn expand-liquid typescript && yarn && yarn typegen && yarn workspaces run test run"
},
"private": true,
"workspaces": [
Expand Down
27 changes: 26 additions & 1 deletion util/expand-liquid.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import path from 'path';
import fs from 'node:fs/promises';
import { existsSync } from 'fs';
import toml from '@iarna/toml';
import { exec } from 'child_process';

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

function ensureNoGitChanges() {
exec('git status --porcelain', (error, stdout, _stderr) => {
if (error) {
console.error(`error calling \`git status\`: ${error}`);
process.exit(1);;
}
if (stdout) {
console.error('Untracked files detected:\n', stdout);
exec('git diff', (error, stdout, _stderr) => {
if (error) {
console.error(`error calling \`git diff\`: ${error}`);
} else {
console.log(`Git diff:\n${stdout}`);
}
process.exit(1);
});
}
});
}

const flavor = process.argv[2] || "vanilla-js";

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

console.log('The above files should be added to .gitignore if they have not already been added.');
console.log('The above files should be added to .gitignore if they have not already been added.\n');

if (process.env.CI) {
ensureNoGitChanges();
}
Loading