Skip to content

Commit 9205739

Browse files
committed
Refactor RemoteSpecification
2 parents c65a05b + 60a9052 commit 9205739

97 files changed

Lines changed: 731 additions & 377 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.changeset/new-sails-relate.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/theme': minor
3+
---
4+
5+
Add --json flag to theme preview to configure a json output

docs-shopify.dev/commands/interfaces/theme-preview.interface.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ export interface themepreview {
66
*/
77
'-e, --environment <value>'?: string
88

9+
/**
10+
* Output the preview URL and identifier as JSON.
11+
* @environment SHOPIFY_FLAG_JSON
12+
*/
13+
'--json'?: ''
14+
915
/**
1016
* Disable color output.
1117
* @environment SHOPIFY_FLAG_NO_COLOR

docs-shopify.dev/generated/generated_docs_data.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7195,6 +7195,15 @@
71957195
"name": "themepreview",
71967196
"description": "",
71977197
"members": [
7198+
{
7199+
"filePath": "docs-shopify.dev/commands/interfaces/theme-preview.interface.ts",
7200+
"syntaxKind": "PropertySignature",
7201+
"name": "--json",
7202+
"value": "\"\"",
7203+
"description": "Output the preview URL and identifier as JSON.",
7204+
"isOptional": true,
7205+
"environmentValue": "SHOPIFY_FLAG_JSON"
7206+
},
71987207
{
71997208
"filePath": "docs-shopify.dev/commands/interfaces/theme-preview.interface.ts",
72007209
"syntaxKind": "PropertySignature",
@@ -7284,7 +7293,7 @@
72847293
"environmentValue": "SHOPIFY_FLAG_THEME_ID"
72857294
}
72867295
],
7287-
"value": "export interface themepreview {\n /**\n * The environment to apply to the current command.\n * @environment SHOPIFY_FLAG_ENVIRONMENT\n */\n '-e, --environment <value>'?: string\n\n /**\n * Disable color output.\n * @environment SHOPIFY_FLAG_NO_COLOR\n */\n '--no-color'?: ''\n\n /**\n * Automatically launch the theme preview in your default web browser.\n * @environment SHOPIFY_FLAG_OPEN\n */\n '--open'?: ''\n\n /**\n * Path to a JSON overrides file.\n * @environment SHOPIFY_FLAG_OVERRIDES\n */\n '--overrides <value>': string\n\n /**\n * Password generated from the Theme Access app or an Admin API token.\n * @environment SHOPIFY_CLI_THEME_TOKEN\n */\n '--password <value>'?: string\n\n /**\n * The path where you want to run the command. Defaults to the current working directory.\n * @environment SHOPIFY_FLAG_PATH\n */\n '--path <value>'?: string\n\n /**\n * An existing preview identifier to update instead of creating a new preview.\n * @environment SHOPIFY_FLAG_PREVIEW_ID\n */\n '--preview-id <value>'?: string\n\n /**\n * Store URL. It can be the store prefix (example) or the full myshopify.com URL (example.myshopify.com, https://example.myshopify.com).\n * @environment SHOPIFY_FLAG_STORE\n */\n '-s, --store <value>'?: string\n\n /**\n * Theme ID or name of the remote theme.\n * @environment SHOPIFY_FLAG_THEME_ID\n */\n '-t, --theme <value>': string\n\n /**\n * Increase the verbosity of the output.\n * @environment SHOPIFY_FLAG_VERBOSE\n */\n '--verbose'?: ''\n}"
7296+
"value": "export interface themepreview {\n /**\n * The environment to apply to the current command.\n * @environment SHOPIFY_FLAG_ENVIRONMENT\n */\n '-e, --environment <value>'?: string\n\n /**\n * Output the preview URL and identifier as JSON.\n * @environment SHOPIFY_FLAG_JSON\n */\n '--json'?: ''\n\n /**\n * Disable color output.\n * @environment SHOPIFY_FLAG_NO_COLOR\n */\n '--no-color'?: ''\n\n /**\n * Automatically launch the theme preview in your default web browser.\n * @environment SHOPIFY_FLAG_OPEN\n */\n '--open'?: ''\n\n /**\n * Path to a JSON overrides file.\n * @environment SHOPIFY_FLAG_OVERRIDES\n */\n '--overrides <value>': string\n\n /**\n * Password generated from the Theme Access app or an Admin API token.\n * @environment SHOPIFY_CLI_THEME_TOKEN\n */\n '--password <value>'?: string\n\n /**\n * The path where you want to run the command. Defaults to the current working directory.\n * @environment SHOPIFY_FLAG_PATH\n */\n '--path <value>'?: string\n\n /**\n * An existing preview identifier to update instead of creating a new preview.\n * @environment SHOPIFY_FLAG_PREVIEW_ID\n */\n '--preview-id <value>'?: string\n\n /**\n * Store URL. It can be the store prefix (example) or the full myshopify.com URL (example.myshopify.com, https://example.myshopify.com).\n * @environment SHOPIFY_FLAG_STORE\n */\n '-s, --store <value>'?: string\n\n /**\n * Theme ID or name of the remote theme.\n * @environment SHOPIFY_FLAG_THEME_ID\n */\n '-t, --theme <value>': string\n\n /**\n * Increase the verbosity of the output.\n * @environment SHOPIFY_FLAG_VERBOSE\n */\n '--verbose'?: ''\n}"
72887297
}
72897298
}
72907299
}

nx.json

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,25 @@
11
{
22
"targetDefaults": {
33
"clean": {
4-
"dependsOn": [
5-
"^clean"
6-
]
4+
"dependsOn": ["^clean"]
75
},
86
"build": {
9-
"dependsOn": [
10-
"^build"
11-
],
12-
"inputs": [
13-
"production",
14-
"^production"
15-
]
7+
"dependsOn": ["^build"],
8+
"inputs": ["production", "^production"]
169
},
1710
"refresh-manifests": {
18-
"dependsOn": [
19-
"build",
20-
"refresh-readme"
21-
]
11+
"dependsOn": ["build", "refresh-readme"]
2212
},
2313
"refresh-readme": {
24-
"dependsOn": [
25-
"build"
26-
]
14+
"dependsOn": ["build"]
2715
},
2816
"lint": {},
2917
"lint:fix": {},
3018
"type-check": {
31-
"dependsOn": [
32-
"^build"
33-
]
19+
"dependsOn": ["^build"]
3420
},
3521
"bundle": {
36-
"dependsOn": [
37-
"build"
38-
]
22+
"dependsOn": ["build"]
3923
}
4024
},
4125
"extends": "@nx/workspace/presets/npm.json",
@@ -65,16 +49,12 @@
6549
"defaultBase": "main",
6650
"$schema": "./node_modules/nx/schemas/nx-schema.json",
6751
"namedInputs": {
68-
"default": [
69-
"{projectRoot}/**/*",
70-
"sharedGlobals"
71-
],
52+
"default": ["{projectRoot}/**/*", "sharedGlobals"],
7253
"sharedGlobals": [],
73-
"production": [
74-
"default"
75-
]
54+
"production": ["default"]
7655
},
7756
"tui": {
7857
"autoExit": true
79-
}
58+
},
59+
"analytics": false
8060
}

packages/app/src/cli/api/graphql/extension_specifications.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,13 @@ export interface RemoteSpecification {
4040
managementExperience: 'cli' | 'custom' | 'dashboard'
4141
registrationLimit: number
4242
uidStrategy: 'single' | 'dynamic' | 'uuid'
43+
surface?: string
4344
validationSchema?: {
4445
jsonSchema: string
4546
} | null
4647
}
4748

48-
export interface PartnersRemoteSpecification {
49+
interface PartnersRemoteSpecification {
4950
name: string
5051
externalName: string
5152
identifier: string
@@ -55,8 +56,6 @@ export interface PartnersRemoteSpecification {
5556
options: {
5657
managementExperience: 'cli' | 'custom' | 'dashboard'
5758
registrationLimit: number
58-
uidIsClientProvided: boolean
59-
uidStrategy?: 'single' | 'dynamic' | 'uuid'
6059
}
6160
features?: {
6261
argo?: {
@@ -68,11 +67,6 @@ export interface PartnersRemoteSpecification {
6867
} | null
6968
}
7069

71-
export interface FlattenedRemoteSpecification extends RemoteSpecification {
72-
surface?: string
73-
registrationLimit: number
74-
}
75-
7670
export interface ExtensionSpecificationsQuerySchema {
7771
extensionSpecifications: PartnersRemoteSpecification[]
7872
}

packages/app/src/cli/commands/app/app-logs/sources.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ export default class Sources extends AppLinkedCommand {
2626
userProvidedConfigName: flags.config,
2727
})
2828

29-
if (!app.errors.isEmpty()) {
30-
process.exit(2)
31-
} else {
29+
if (app.errors.isEmpty()) {
3230
sources(app)
31+
} else {
32+
process.exit(2)
3333
}
3434
return {app}
3535
}

packages/app/src/cli/commands/app/function/run.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,15 @@ export default class FunctionRun extends AppUnlinkedCommand {
5656
if (targeting.length > 1 && isTTY({})) {
5757
const targets = targeting.map((target) => ({
5858
label: target.target,
59-
value: target.export || DEFAULT_FUNCTION_EXPORT,
59+
value: target.export || DEFAULT_FUNCTION_EXPORT, // eslint-disable-line @typescript-eslint/prefer-nullish-coalescing -- empty export should use default
6060
}))
6161

6262
functionExport = await renderAutocompletePrompt({
6363
message: `Which target would you like to execute?`,
6464
choices: targets,
6565
})
6666
} else {
67-
functionExport = targeting?.[0]?.export || DEFAULT_FUNCTION_EXPORT
67+
functionExport = targeting?.[0]?.export || DEFAULT_FUNCTION_EXPORT // eslint-disable-line @typescript-eslint/prefer-nullish-coalescing -- empty export should use default
6868
outputDebug(
6969
`Using export '${functionExport}'. Use the --export flag or an interactive terminal to select a different export.`,
7070
)

packages/app/src/cli/commands/app/webhook/trigger.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export default class WebhookTrigger extends AppLinkedCommand {
106106
deliveryMethod: flags['delivery-method'],
107107
address: flags.address,
108108
clientId: flags['client-id'],
109-
clientSecret: flags['client-secret'] || flags['shared-secret'],
109+
clientSecret: flags['client-secret'] || flags['shared-secret'], // eslint-disable-line @typescript-eslint/prefer-nullish-coalescing -- empty flag should try next
110110
path: flags.path,
111111
config: flags.config,
112112
organizationId: appContextResult.organization.id,

packages/app/src/cli/models/app/identifiers.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,9 @@ export async function updateAppIdentifiers(
5252
): Promise<AppInterface> {
5353
let dotenvFile = app.dotenv
5454

55-
if (!dotenvFile) {
56-
dotenvFile = {
57-
path: joinPath(app.directory, getDotEnvFileName(app.configPath)),
58-
variables: {},
59-
}
55+
dotenvFile ??= {
56+
path: joinPath(app.directory, getDotEnvFileName(app.configPath)),
57+
variables: {},
6058
}
6159
const updatedVariables: {[key: string]: string} = {...(app.dotenv?.variables ?? {})}
6260
if (!systemEnvironment[app.idEnvironmentVariableName]) {

packages/app/src/cli/models/extensions/extension-instance.test.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,3 +694,31 @@ describe('rescanImports', async () => {
694694
})
695695
})
696696
})
697+
698+
describe('SHOPIFY_CLI_DISABLE_IMPORT_SCANNING', () => {
699+
test('skips import scanning when env var is set', async () => {
700+
await inTemporaryDirectory(async (tmpDir) => {
701+
const extensionInstance = await testUIExtension({
702+
directory: tmpDir,
703+
entrySourceFilePath: joinPath(tmpDir, 'src', 'index.ts'),
704+
})
705+
706+
const srcDir = joinPath(tmpDir, 'src')
707+
await mkdir(srcDir)
708+
await writeFile(joinPath(srcDir, 'index.ts'), 'import "../shared"')
709+
710+
vi.mocked(extractImportPathsRecursively).mockReset()
711+
vi.mocked(extractImportPathsRecursively).mockReturnValue(['/some/external/file.ts'])
712+
713+
process.env.SHOPIFY_CLI_DISABLE_IMPORT_SCANNING = '1'
714+
try {
715+
const watched = extensionInstance.watchedFiles()
716+
expect(extractImportPathsRecursively).not.toHaveBeenCalled()
717+
expect(watched.some((file) => file.includes('external'))).toBe(false)
718+
} finally {
719+
delete process.env.SHOPIFY_CLI_DISABLE_IMPORT_SCANNING
720+
vi.mocked(extractImportPathsRecursively).mockReset()
721+
}
722+
})
723+
})
724+
})

0 commit comments

Comments
 (0)