-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import {renderConfirmationPrompt} from '@shopify/cli-kit/node/ui' | ||
Check failure on line 1 in packages/app/src/cli/services/generate/workflows/discount-details-function-settings-collection.ts GitHub Actions / ESLint Report Analysispackages/app/src/cli/services/generate/workflows/discount-details-function-settings-collection.ts#L1
|
||
import {Workflow} from './registry.js' | ||
import {generateExtensionTemplate} from '../extension.js' | ||
import {generateExtensionPrompts} from '../../../prompts/generate/extension.js' | ||
Check failure on line 4 in packages/app/src/cli/services/generate/workflows/discount-details-function-settings-collection.ts GitHub Actions / ESLint Report Analysispackages/app/src/cli/services/generate/workflows/discount-details-function-settings-collection.ts#L4
|
||
import {buildGenerateOptions, renderSuccessMessage, buildPromptOptions} from '../../generate.js' | ||
import {GenerateExtensionPromptOutput} from '../../../prompts/generate/extension.js' | ||
Check failure on line 6 in packages/app/src/cli/services/generate/workflows/discount-details-function-settings-collection.ts GitHub Actions / ESLint Report Analysispackages/app/src/cli/services/generate/workflows/discount-details-function-settings-collection.ts#L6
Check failure on line 6 in packages/app/src/cli/services/generate/workflows/discount-details-function-settings-collection.ts GitHub Actions / ESLint Report Analysispackages/app/src/cli/services/generate/workflows/discount-details-function-settings-collection.ts#L6
Check failure on line 6 in packages/app/src/cli/services/generate/workflows/discount-details-function-settings-collection.ts GitHub Actions / ESLint Report Analysispackages/app/src/cli/services/generate/workflows/discount-details-function-settings-collection.ts#L6
|
||
|
||
export const discountDetailsFunctionSettingsCollection: Workflow = { | ||
afterGenerate: async (options) => { | ||
const {app, developerPlatformClient, specifications} = options.generateOptions | ||
|
||
const shouldCreateFunction = await renderConfirmationPrompt({ | ||
message: 'Would you like to create a function for this extension?', | ||
defaultValue: true, | ||
}) | ||
|
||
if (shouldCreateFunction) { | ||
// create a function extension | ||
const extensionTemplates = options.extensionTemplates.filter( | ||
(template) => | ||
template.identifier === 'shipping_discounts' || | ||
template.identifier === 'product_discounts' || | ||
template.identifier === 'order_discounts' || | ||
template.identifier == 'discounts_allocator', | ||
Check failure on line 24 in packages/app/src/cli/services/generate/workflows/discount-details-function-settings-collection.ts GitHub Actions / ESLint Report Analysispackages/app/src/cli/services/generate/workflows/discount-details-function-settings-collection.ts#L24
|
||
) | ||
|
||
const promptOptions = await buildPromptOptions(extensionTemplates, specifications, app, options.generateOptions) | ||
const promptAnswers = await generateExtensionPrompts(promptOptions) | ||
|
||
const generateExtensionOptions = buildGenerateOptions( | ||
promptAnswers, | ||
app, | ||
options.generateOptions, | ||
developerPlatformClient, | ||
) | ||
const generatedExtension = await generateExtensionTemplate(generateExtensionOptions) | ||
renderSuccessMessage(generatedExtension, app.packageManager) | ||
} | ||
}, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import {renderConfirmationPrompt} from '@shopify/cli-kit/node/ui' | ||
Check failure on line 1 in packages/app/src/cli/services/generate/workflows/product-discount-function-collection.ts GitHub Actions / ESLint Report Analysispackages/app/src/cli/services/generate/workflows/product-discount-function-collection.ts#L1
|
||
import {Workflow} from './registry.js' | ||
import {generateExtensionTemplate} from '../extension.js' | ||
Check failure on line 3 in packages/app/src/cli/services/generate/workflows/product-discount-function-collection.ts GitHub Actions / ESLint Report Analysispackages/app/src/cli/services/generate/workflows/product-discount-function-collection.ts#L3
|
||
import {generateExtensionPrompts} from '../../../prompts/generate/extension.js' | ||
Check failure on line 4 in packages/app/src/cli/services/generate/workflows/product-discount-function-collection.ts GitHub Actions / ESLint Report Analysispackages/app/src/cli/services/generate/workflows/product-discount-function-collection.ts#L4
Check failure on line 4 in packages/app/src/cli/services/generate/workflows/product-discount-function-collection.ts GitHub Actions / ESLint Report Analysispackages/app/src/cli/services/generate/workflows/product-discount-function-collection.ts#L4
|
||
import {buildGenerateOptions, renderSuccessMessage, buildPromptOptions} from '../../generate.js' | ||
Check failure on line 5 in packages/app/src/cli/services/generate/workflows/product-discount-function-collection.ts GitHub Actions / ESLint Report Analysispackages/app/src/cli/services/generate/workflows/product-discount-function-collection.ts#L5
|
||
import {GenerateExtensionPromptOutput} from '../../../prompts/generate/extension.js' | ||
Check failure on line 6 in packages/app/src/cli/services/generate/workflows/product-discount-function-collection.ts GitHub Actions / ESLint Report Analysispackages/app/src/cli/services/generate/workflows/product-discount-function-collection.ts#L6
Check failure on line 6 in packages/app/src/cli/services/generate/workflows/product-discount-function-collection.ts GitHub Actions / ESLint Report Analysispackages/app/src/cli/services/generate/workflows/product-discount-function-collection.ts#L6
Check failure on line 6 in packages/app/src/cli/services/generate/workflows/product-discount-function-collection.ts GitHub Actions / ESLint Report Analysispackages/app/src/cli/services/generate/workflows/product-discount-function-collection.ts#L6
Check failure on line 6 in packages/app/src/cli/services/generate/workflows/product-discount-function-collection.ts GitHub Actions / ESLint Report Analysispackages/app/src/cli/services/generate/workflows/product-discount-function-collection.ts#L6
|
||
import {patchAppConfigurationFile} from './patch-configuration-file.js' | ||
|
||
export const productDiscountFunctionCollection: Workflow = { | ||
afterGenerate: async (options) => { | ||
const {app, developerPlatformClient, specifications} = options.generateOptions | ||
const functionTomlFilePath = `${options.generatedExtension.directory}/shopify.extension.toml` | ||
|
||
const shouldLinkExtension = await renderConfirmationPrompt({ | ||
message: 'Would you like to create a UI extension for your function?', | ||
defaultValue: true, | ||
}) | ||
|
||
if (shouldLinkExtension) { | ||
// create a UI extension | ||
const extensionTemplates = options.extensionTemplates.filter( | ||
(template) => template.identifier === 'discount_details_function_settings', | ||
) | ||
|
||
const promptOptions = await buildPromptOptions(extensionTemplates, specifications, app, options.generateOptions) | ||
const promptAnswers = await generateExtensionPrompts(promptOptions) | ||
|
||
const generateExtensionOptions = buildGenerateOptions( | ||
promptAnswers, | ||
app, | ||
options.generateOptions, | ||
developerPlatformClient, | ||
) | ||
const generatedExtension = await generateExtensionTemplate(generateExtensionOptions) | ||
|
||
const patch = { | ||
extensions: [ | ||
{ | ||
ui: { | ||
handle: generatedExtension.handle, | ||
}, | ||
}, | ||
], | ||
} | ||
|
||
await patchAppConfigurationFile({ | ||
path: functionTomlFilePath, | ||
patch, | ||
}) | ||
renderSuccessMessage(generatedExtension, app.packageManager) | ||
} | ||
}, | ||
} |