Skip to content

Commit

Permalink
Minor fixes (#2023)
Browse files Browse the repository at this point in the history
* Fix quickstart values for booleans

* Remove styling flag

* Throw error in debug:cpu for Vite projects

* Update oclif manifest

* Changesets
  • Loading branch information
frandiox authored Apr 19, 2024
1 parent e842f68 commit 0af624d
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 55 deletions.
9 changes: 9 additions & 0 deletions .changeset/dry-roses-wink.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@shopify/cli-hydrogen': patch
---

Fix `--quickstart` flag to support overwritting it with other flags. Example: `h2 init --quickstart --no-install-deps`.

Show error in `h2 debug cpu` command for Vite projects until we support it.

Remove deprecated `--styling` flag from the `h2 init` command.
16 changes: 0 additions & 16 deletions packages/cli/oclif.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -1195,14 +1195,6 @@
"allowNo": false,
"type": "boolean"
},
"styling": {
"description": "Sets the styling strategy to use. One of `tailwind`, `css-modules`, `vanilla-extract`, `postcss`, `none`.",
"env": "SHOPIFY_HYDROGEN_FLAG_STYLING",
"name": "styling",
"hasDynamicHelp": false,
"multiple": false,
"type": "option"
},
"markets": {
"description": "Sets the URL structure to support multiple markets. Must be one of: `subfolders`, `domains`, `subdomains`, `none`. Example: `--markets subfolders`.",
"env": "SHOPIFY_HYDROGEN_FLAG_I18N",
Expand Down Expand Up @@ -1531,14 +1523,6 @@
"allowNo": false,
"type": "boolean"
},
"styling": {
"description": "Sets the styling strategy to use. One of `tailwind`, `css-modules`, `vanilla-extract`, `postcss`, `none`.",
"env": "SHOPIFY_HYDROGEN_FLAG_STYLING",
"name": "styling",
"hasDynamicHelp": false,
"multiple": false,
"type": "option"
},
"markets": {
"description": "Sets the URL structure to support multiple markets. Must be one of: `subfolders`, `domains`, `subdomains`, `none`. Example: `--markets subfolders`.",
"env": "SHOPIFY_HYDROGEN_FLAG_I18N",
Expand Down
8 changes: 8 additions & 0 deletions packages/cli/src/commands/hydrogen/debug/cpu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import Command from '@shopify/cli-kit/node/base-command';
import {outputInfo, outputWarn} from '@shopify/cli-kit/node/output';
import colors from '@shopify/cli-kit/node/colors';
import {writeFile} from '@shopify/cli-kit/node/fs';
import {AbortError} from '@shopify/cli-kit/node/error';
import ansiEscapes from 'ansi-escapes';
import {
type RemixConfig,
getProjectPaths,
getRemixConfig,
handleRemixImportFail,
type ServerMode,
hasRemixConfigFile,
} from '../../../lib/remix-config.js';
import {createRemixLogger, muteDevLogs} from '../../../lib/log.js';
import {commonFlags, flagsToCamelObject} from '../../../lib/flags.js';
Expand Down Expand Up @@ -61,6 +63,12 @@ async function runDebugCpu({

const {root, buildPathWorkerFile} = getProjectPaths(appPath);

if (!(await hasRemixConfigFile(root))) {
throw new AbortError(
'No remix.config.js file found. This command is not supported in Vite projects.',
);
}

outputInfo(
'⏳️ Starting profiler for CPU startup... Profile will be written to:\n' +
colors.dim(output),
Expand Down
36 changes: 9 additions & 27 deletions packages/cli/src/commands/hydrogen/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ import {
flagsToCamelObject,
} from '../../lib/flags.js';
import {checkHydrogenVersion} from '../../lib/check-version.js';
import {
STYLING_CHOICES,
type StylingChoice,
} from './../../lib/setups/css/index.js';
import {I18N_CHOICES, type I18nChoice} from '../../lib/setups/i18n/index.js';
import {supressNodeExperimentalWarnings} from '../../lib/process.js';
import {
Expand Down Expand Up @@ -47,10 +43,8 @@ export default class Init extends Command {
...commonFlags.installDeps,
'mock-shop': Flags.boolean({
description: 'Use mock.shop as the data source for the storefront.',
default: false,
env: 'SHOPIFY_HYDROGEN_FLAG_MOCK_DATA',
}),
...commonFlags.styling,
...commonFlags.markets,
...commonFlags.shortcut,
routes: Flags.boolean({
Expand Down Expand Up @@ -107,33 +101,21 @@ export async function runInit(
);
}

if (
options.styling &&
!STYLING_CHOICES.includes(options.styling as StylingChoice)
) {
throw new AbortError(
`Invalid styling strategy: ${
options.styling
}. Must be one of ${STYLING_CHOICES.join(', ')}`,
);
}

options.git ??= true;

/**
* Quickstart options. A set of sensible defaults to streamline documentation.
* Logical OR assignment means you can still override individual options by flag:
* $ h2 init --quickstart --language ts
* Nullish coalescing assignment means you can still override individual options by flag:
* $ h2 init --quickstart --language ts --no-install-deps
*/
if (options.quickstart) {
options.i18n ||= 'none';
options.installDeps ||= true;
options.language ||= 'js';
options.mockShop ||= true;
options.path ||= './hydrogen-quickstart';
options.routes ||= true;
options.shortcut ||= true;
options.styling ||= 'tailwind';
options.i18n ??= 'none';
options.installDeps ??= true;
options.language ??= 'js';
options.mockShop ??= true;
options.path ??= './hydrogen-quickstart';
options.routes ??= true;
options.shortcut ??= true;
}

const showUpgrade = await checkHydrogenVersion(
Expand Down
2 changes: 0 additions & 2 deletions packages/cli/src/commands/hydrogen/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export default class Setup extends Command {
static flags = {
...commonFlags.path,
...commonFlags.force,
...commonFlags.styling,
...commonFlags.markets,
...commonFlags.shortcut,
...overrideFlag(commonFlags.installDeps, {
Expand All @@ -51,7 +50,6 @@ export default class Setup extends Command {
type RunSetupOptions = {
directory: string;
installDeps: boolean;
styling?: string;
markets?: string;
shortcut?: boolean;
};
Expand Down
10 changes: 0 additions & 10 deletions packages/cli/src/lib/flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {renderInfo} from '@shopify/cli-kit/node/ui';
import {normalizeStoreFqdn} from '@shopify/cli-kit/node/context/fqdn';
import colors from '@shopify/cli-kit/node/colors';
import type {CamelCasedProperties, PartialDeep} from 'type-fest';
import {STYLING_CHOICES} from './setups/css/index.js';
import {I18N_CHOICES} from './setups/i18n/index.js';

export const DEFAULT_APP_PORT = 3000;
Expand Down Expand Up @@ -102,15 +101,6 @@ export const commonFlags = {
dependsOn: ['codegen'],
}),
},
styling: {
styling: Flags.string({
description: `Sets the styling strategy to use. One of ${STYLING_CHOICES.map(
(item) => `\`${item}\``,
).join(', ')}.`,
choices: STYLING_CHOICES,
env: 'SHOPIFY_HYDROGEN_FLAG_STYLING',
}),
},
markets: {
markets: Flags.string({
description: `Sets the URL structure to support multiple markets. Must be one of: ${I18N_CHOICES.map(
Expand Down

0 comments on commit 0af624d

Please sign in to comment.