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

(demo-store): Refactor Seo and implement ld+json structured data [Fixed] #660

Merged
merged 8 commits into from
Mar 7, 2023
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
5 changes: 5 additions & 0 deletions .changeset/silent-pianos-battle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/cli-hydrogen': patch
---

Fix bug in CLI not recognising the --install-deps flag when creating projects
22 changes: 12 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,18 @@ jobs:
- name: 📥 Install dependencies
run: npm ci

- name: 💾 Turbo cache
id: turbo-cache
uses: actions/cache@v3
with:
path: |
node_modules/.cache/turbo
**/.turbo
key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ github.sha }}
restore-keys: |
turbo-${{ github.job }}-${{ github.ref_name }}-
# Enabling the turbo cache causes deployments to fail intermittently.
# The build step fails with dependency issues. More investigation needed.
# - name: 💾 Turbo cache
# id: turbo-cache
# uses: actions/cache@v3
# with:
# path: |
# node_modules/.cache/turbo
# **/.turbo
# key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ github.sha }}
# restore-keys: |
# turbo-${{ github.job }}-${{ github.ref_name }}-

- name: 📦 Build packages
run: npm run build
Expand Down
22 changes: 12 additions & 10 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,18 @@ jobs:
- name: 📥 Install dependencies
run: npm ci

- name: 💾 Turbo cache
id: turbo-cache
uses: actions/cache@v3
with:
path: |
node_modules/.cache/turbo
**/.turbo
key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ github.sha }}
restore-keys: |
turbo-${{ github.job }}-${{ github.ref_name }}-
# Enabling the turbo cache causes deployments to fail intermittently.
# The build step fails with dependency issues. More investigation needed.
# - name: 💾 Turbo cache
# id: turbo-cache
# uses: actions/cache@v3
# with:
# path: |
# node_modules/.cache/turbo
# **/.turbo
# key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ github.sha }}
# restore-keys: |
# turbo-${{ github.job }}-${{ github.ref_name }}-

- name: 📦 Build packages
run: |
Expand Down
3 changes: 2 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

93 changes: 93 additions & 0 deletions packages/cli/src/commands/hydrogen/init.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import {describe, it, expect, vi, beforeEach} from 'vitest';
import {temporaryDirectoryTask} from 'tempy';
import {runInit} from './init.js';
import {ui} from '@shopify/cli-kit';
import {installNodeModules} from '@shopify/cli-kit/node/node-package-manager';

describe('init', () => {
beforeEach(() => {
vi.resetAllMocks();
vi.mock('@shopify/cli-kit');
vi.mock('../../utils/transpile-ts.js');
vi.mock('../../utils/template-downloader.js', async () => ({
getLatestTemplates: () => Promise.resolve({}),
}));
vi.mock('@shopify/cli-kit/node/node-package-manager');
vi.mocked(ui.prompt).mockImplementation(() =>
Promise.resolve({installDeps: 'false'}),
);
});

const defaultOptions = (stubs: Record<any, unknown>) => ({
template: 'hello-world',
language: 'js',
path: 'path/to/project',
...stubs,
});

describe('installDeps', () => {
it('prompts the user to install dependencies when installDeps is not passed', async () => {
await temporaryDirectoryTask(async (tmpDir) => {
// Given
const options = defaultOptions({path: tmpDir});

vi.mocked(ui.prompt).mockImplementation(() =>
Promise.resolve({installDeps: 'false'}),
);

// When
await runInit(options);

// Then
expect(ui.prompt).toHaveBeenCalledWith(
expect.arrayContaining([
expect.objectContaining({
name: 'installDeps',
}),
]),
);
expect(installNodeModules).not.toHaveBeenCalled();
});
});

it('does not prompt the user to install dependencies when installDeps is true', async () => {
await temporaryDirectoryTask(async (tmpDir) => {
// Given
const options = defaultOptions({installDeps: true, path: tmpDir});

// When
await runInit(options);

// Then
expect(ui.prompt).not.toHaveBeenCalledWith(
expect.arrayContaining([
expect.objectContaining({
name: 'installDeps',
}),
]),
);
expect(installNodeModules).toHaveBeenCalled();
});
});

it('does not show a prompt to install dependencies when installDeps is false', async () => {
await temporaryDirectoryTask(async (tmpDir) => {
// Given
const options = defaultOptions({installDeps: false, path: tmpDir});

// When
await runInit(options);

// Then
expect(ui.prompt).not.toHaveBeenCalledWith(
expect.arrayContaining([
expect.objectContaining({
name: 'installDeps',
}),
]),
);
expect(installNodeModules).not.toHaveBeenCalled();
});
});
});
});
8 changes: 6 additions & 2 deletions packages/cli/src/commands/hydrogen/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import {
import {renderFatalError} from '@shopify/cli-kit/node/ui';
import Flags from '@oclif/core/lib/flags.js';
import {output, path} from '@shopify/cli-kit';
import {commonFlags, parseProcessFlags} from '../../utils/flags.js';
import {
commonFlags,
parseProcessFlags,
flagsToCamelObject,
} from '../../utils/flags.js';
import {transpileProject} from '../../utils/transpile-ts.js';
import {getLatestTemplates} from '../../utils/template-downloader.js';
import {checkHydrogenVersion} from '../../utils/check-version.js';
Expand Down Expand Up @@ -46,7 +50,7 @@ export default class Init extends Command {
// @ts-ignore
const {flags} = await this.parse(Init);

await runInit({...flags});
await runInit(flagsToCamelObject(flags));
}
}

Expand Down
1 change: 1 addition & 0 deletions templates/demo-store/app/components/Hero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export function Hero({
widths={[450, 700]}
width={375}
data={spreadSecondary.reference as Media}
loading={loading}
/>
</div>
)}
Expand Down
Loading