Skip to content

Commit

Permalink
Merge pull request #543 from Shopify/apply-presets-to-apps
Browse files Browse the repository at this point in the history
Apply presets to apps and themes
  • Loading branch information
amcaplan committed Oct 23, 2022
2 parents 5806a14 + 96d5b17 commit 8687463
Show file tree
Hide file tree
Showing 20 changed files with 545 additions and 24 deletions.
7 changes: 7 additions & 0 deletions .changeset/dirty-moose-learn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@shopify/app': minor
'@shopify/cli-kit': minor
'@shopify/theme': minor
---

Enable experimental presets feature for apps and themes
7 changes: 7 additions & 0 deletions .changeset/thick-wasps-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@shopify/app': minor
'@shopify/cli-kit': minor
'@shopify/theme': minor
---

Add experimental preset flag for pre-specifying command line flags
1 change: 1 addition & 0 deletions configurations/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"@shopify/cli-kit": ["../packages/cli-kit/src/index.ts"],
"@shopify/cli-kit/common/array": ["../packages/cli-kit/src/public/common/array.ts"],
"@shopify/cli-kit/node/ui": ["../packages/cli-kit/src/public/node/ui.tsx"],
"@shopify/cli-kit/node/presets": ["../packages/cli-kit/src/public/node/presets.ts"],
"@shopify/cli-kit/node/*": ["../packages/cli-kit/src/node/*.ts"],
"@shopify/cli-kit/common/*": ["../packages/cli-kit/src/common/*.ts"],
"@shopify/cli-kit/typing/*": ["../packages/cli-kit/src/typing/*.ts"],
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/cli/commands/app/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import {appFlags} from '../../flags.js'
import {AppInterface} from '../../models/app/app.js'
import {load as loadApp} from '../../models/app/loader.js'
import build from '../../services/build.js'
import Command from '../../utilities/app-command.js'
import {Flags} from '@oclif/core'
import Command from '@shopify/cli-kit/node/base-command'
import {path, cli, metadata} from '@shopify/cli-kit'

export default class Build extends Command {
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/cli/commands/app/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import {appFlags} from '../../flags.js'
import {deploy} from '../../services/deploy.js'
import {AppInterface} from '../../models/app/app.js'
import {load as loadApp} from '../../models/app/loader.js'
import Command from '../../utilities/app-command.js'
import {Flags} from '@oclif/core'
import Command from '@shopify/cli-kit/node/base-command'
import {path, cli, metadata} from '@shopify/cli-kit'

export default class Deploy extends Command {
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/cli/commands/app/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import {appFlags} from '../../flags.js'
import {AppInterface} from '../../models/app/app.js'
import dev from '../../services/dev.js'
import {load as loadApp} from '../../models/app/loader.js'
import Command from '../../utilities/app-command.js'
import {Flags} from '@oclif/core'
import Command from '@shopify/cli-kit/node/base-command'
import {path, string, cli, metadata} from '@shopify/cli-kit'

export default class Dev extends Command {
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/cli/commands/app/env/pull.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import {appFlags} from '../../../flags.js'
import {AppInterface} from '../../../models/app/app.js'
import {load as loadApp} from '../../../models/app/loader.js'
import {pullEnv} from '../../../services/app/env/pull.js'
import Command from '../../../utilities/app-command.js'
import {Flags} from '@oclif/core'
import {output, path, cli} from '@shopify/cli-kit'
import Command from '@shopify/cli-kit/node/base-command'

export default class EnvPull extends Command {
static description = 'Pull app and extensions environment variables'
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/cli/commands/app/env/show.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import {appFlags} from '../../../flags.js'
import {AppInterface} from '../../../models/app/app.js'
import {load as loadApp} from '../../../models/app/loader.js'
import {showEnv} from '../../../services/app/env/show.js'
import Command from '../../../utilities/app-command.js'
import {output, path, cli} from '@shopify/cli-kit'
import Command from '@shopify/cli-kit/node/base-command'

export default class EnvShow extends Command {
static description = 'Display app and extensions environment variables'
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/cli/commands/app/generate/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ import {
mapExtensionTypeToExternalExtensionType,
} from '../../../utilities/extensions/name-mapper.js'
import metadata from '../../../metadata.js'
import Command from '../../../utilities/app-command.js'
import {output, path, cli, error, environment} from '@shopify/cli-kit'
import {Flags} from '@oclif/core'
import {PackageManager} from '@shopify/cli-kit/node/node-package-manager'
import Command from '@shopify/cli-kit/node/base-command'

export default class AppScaffoldExtension extends Command {
static description = 'Scaffold an Extension'
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/cli/commands/app/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import {appFlags} from '../../flags.js'
import {AppInterface} from '../../models/app/app.js'
import {Format, info} from '../../services/info.js'
import {load as loadApp} from '../../models/app/loader.js'
import Command from '../../utilities/app-command.js'
import {Flags} from '@oclif/core'
import {output, path, cli} from '@shopify/cli-kit'
import Command from '@shopify/cli-kit/node/base-command'

export default class AppInfo extends Command {
static description = 'Print basic information about your app and extensions'
Expand Down
18 changes: 18 additions & 0 deletions packages/app/src/cli/utilities/app-command.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import {configurationFileNames} from '../constants.js'
import Command from '@shopify/cli-kit/node/base-command'
import {path} from '@shopify/cli-kit'

export default abstract class AppCommand extends Command {
async presetsPath(rawFlags: {path?: string}): Promise<string> {
const specifiedPath = rawFlags.path ? rawFlags.path : process.cwd()
const appTOML = await path.findUp(configurationFileNames.app, {
cwd: specifiedPath,
type: 'file',
})
return appTOML ? path.dirname(appTOML) : specifiedPath
}

findUpForPresets(): boolean {
return false
}
}
4 changes: 4 additions & 0 deletions packages/cli-kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
"import": "./dist/public/node/ui.js",
"types": "./dist/public/node/ui.d.ts"
},
"./node/presets": {
"import": "./dist/public/node/presets.js",
"types": "./dist/public/node/presets.d.ts"
},
"./node/*": {
"node": "./dist/node/*.js",
"types": "./dist/node/*.d.ts"
Expand Down
5 changes: 5 additions & 0 deletions packages/cli-kit/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import {Flags} from '@oclif/core'
* are shared across all the commands.
*/
export const globalFlags = {
preset: Flags.string({
hidden: true,
description: 'The preset to apply to the current command.',
env: 'SHOPIFY_FLAG_PRESET',
}),
verbose: Flags.boolean({
hidden: false,
description: 'Increase the verbosity of the logs.',
Expand Down

0 comments on commit 8687463

Please sign in to comment.