Skip to content

Commit

Permalink
chore: Merge branch 'experimental' into fd-vite-rsc-consume-response
Browse files Browse the repository at this point in the history
  • Loading branch information
jplhomer committed Jan 19, 2022
2 parents 593d1db + d8c87eb commit f7adeb8
Show file tree
Hide file tree
Showing 106 changed files with 729 additions and 938 deletions.
1 change: 1 addition & 0 deletions .alexignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ docs/code_of_conduct.md
packages/hydrogen/src/docs/hooks.md
packages/hydrogen/src/docs/components.md
packages/hydrogen/src/docs/hydrogen-sdk.md
packages/hydrogen/src/framework/docs/css-support.md
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,6 @@ Learn more about [getting started with Hydrogen](https://shopify.dev/custom-stor

- [`@shopify/hydrogen`](https://www.npmjs.com/package/@shopify/hydrogen)
- [`@shopify/hydrogen-cli`](https://www.npmjs.com/package/@shopify/hydrogen-cli)
- [`@shopify/hydrogen-plugin-sanity`](https://www.npmjs.com/package/@shopify/hydrogen-plugin-sanity)
- [`create-hydrogen-app`](https://www.npmjs.com/package/create-hydrogen-app)
- [`eslint-plugin-hydrogen`](https://www.npmjs.com/package/eslint-plugin-hydrogen)
- [`hydrogen-plugin-sanity`](https://www.npmjs.com/package/hydrogen-plugin-sanity)
4 changes: 2 additions & 2 deletions examples/template-hydrogen-default/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "hydrogen-template-default",
"description": "This the default template for Hydrogen",
"version": "0.8.2",
"version": "0.8.3",
"license": "MIT",
"private": true,
"scripts": {
Expand Down Expand Up @@ -33,7 +33,7 @@
},
"dependencies": {
"@headlessui/react": "^1.4.1",
"@shopify/hydrogen": "^0.8.2",
"@shopify/hydrogen": "^0.8.3",
"compression": "^1.7.4",
"express": "^4.17.1",
"graphql-tag": "^2.12.4",
Expand Down
5 changes: 1 addition & 4 deletions examples/template-hydrogen-default/src/entry-client.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import renderHydrogen from '@shopify/hydrogen/entry-client';
import {setShopifyConfig} from '@shopify/hydrogen/client';
import shopifyConfig from '../shopify.config';

setShopifyConfig(shopifyConfig);

function ClientApp({children}) {
return children;
}

export default renderHydrogen(ClientApp);
export default renderHydrogen(ClientApp, {shopifyConfig});
7 changes: 1 addition & 6 deletions examples/template-hydrogen-default/src/entry-server.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import renderHydrogen from '@shopify/hydrogen/entry-server';
import {setShopifyConfig} from '@shopify/hydrogen';
import shopifyConfig from '../shopify.config';

setShopifyConfig(shopifyConfig);

import App from './App.server';

export default renderHydrogen(App, () => {
// Custom hook
});
export default renderHydrogen(App, {shopifyConfig});
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"packages": [
"packages/*"
],
"version": "0.8.2",
"version": "0.8.3",
"npmClient": "yarn",
"useWorkspaces": true,
"command": {}
Expand Down
4 changes: 3 additions & 1 deletion packages/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## Unreleased
<!-- ## Unreleased -->

## 0.8.3 - 2022-01-13

- New command: `check`, for running audits on the current project to look for common problems
- New command: add, to run an atomic change to a project (ie: `hydrogen add lint`)
Expand Down
5 changes: 3 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@shopify/hydrogen-cli",
"version": "0.8.1",
"version": "0.8.3",
"description": "Command line interface for hydrogen",
"license": "MIT",
"engines": {
Expand Down Expand Up @@ -29,15 +29,16 @@
"directory": "packages/cli"
},
"dependencies": {
"@shopify/prettier-config": "^1.1.2",
"@shopify/ast-utilities": "^1.2.0",
"@shopify/prettier-config": "^1.1.2",
"@types/debug": "^4.1.7",
"chalk": "^4.1.2",
"change-case": "^4.1.2",
"cosmiconfig": "^7.0.1",
"debug": "^4.3.2",
"fs-extra": "^10.0.0",
"glob": "^7.2.0",
"glob-promise": "^4.2.2",
"inquirer": "^8.1.2",
"minimist": "^1.2.5",
"prettier": "^2.4.1"
Expand Down
73 changes: 73 additions & 0 deletions packages/cli/src/Command.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import {resolve, basename, extname} from 'path';
import debug from 'debug';

import {InputError, tree} from './utilities';
import {CONFIG_DIRECTORY} from './config';
import {Env} from './types';

interface ModuleType {
default: (env: Env) => Promise<void>;
}

export class Command {
private logger: debug.Debugger;
private module: ModuleType | null = null;
private modulePath: string | null = null;

constructor(public command: string) {
this.logger = debug(`hydrogen/${command}`);
}

async run(env: Env) {
this.logger(`Running ${this.command}`);

if (!this.modulePath) {
return;
}

try {
this.module = await import(this.modulePath);

if (!this.module) {
return;
}

await this.module.default({
...env,
logger: this.logger,
});
} catch (error) {
this.logger(error);
console.error(error);
env.ui.say(`Command module not found at ${this.modulePath} ${error}`, {
error: true,
});

throw new InputError();
}

this.logger(`Finished ${this.command}`);
}

async load() {
this.logger(`Loading ${this.command}`);

const localCommands = await tree(resolve(CONFIG_DIRECTORY, 'commands'));

this.modulePath =
[...localCommands.files, ...localCommands.directories].find(
matchCommand(this.command)
) || `./commands/${this.command}`;

this.logger(`Loaded ${this.modulePath}`);
}
}

function commandNameFromPath(path?: string) {
return path ? basename(path, extname(path)) : '';
}

function matchCommand(inputCommand: string) {
return (command: string) =>
inputCommand.split('/').includes(commandNameFromPath(command));
}

This file was deleted.

This file was deleted.

38 changes: 0 additions & 38 deletions packages/cli/src/commands/check/rules/node/tests/node.test.ts

This file was deleted.

5 changes: 5 additions & 0 deletions packages/cli/src/commands/check/tests/check.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import {withCli} from '../../../testing';

// Some tests in this file are finishing before
// the stream is closed. This is a known issue.
// We should investigate and remove this increase.
jest.setTimeout(30000);

describe('check', () => {
describe('eslint', () => {
it('fails in an empty project', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@ export default function ({ifFeature}: TemplateOptions) {
return `
import renderHydrogen from '@shopify/hydrogen/entry-client';
${ifFeature(Feature.Pwa, `import {registerSW} from 'virtual:pwa-register';`)}
import {setShopifyConfig} from '@shopify/hydrogen/client';
import shopifyConfig from '../shopify.config';
setShopifyConfig(shopifyConfig);
function ClientApp({children}) {
${ifFeature(Feature.Pwa, 'registerSW()')}
return children;
}
export default renderHydrogen(ClientApp);
export default renderHydrogen(ClientApp, {shopifyConfig});
`;
}
2 changes: 2 additions & 0 deletions packages/cli/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@ export async function loadConfig(
logger(error);
}
}

export const CONFIG_DIRECTORY = '.hydrogen';
Loading

0 comments on commit f7adeb8

Please sign in to comment.