@shopify/shop-minis-cli 0.0.103 → 0.0.105-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/commands/create-extension/constants.d.ts +24 -0
- package/build/commands/create-extension/constants.js +41 -0
- package/build/commands/create-extension/constants.js.map +1 -0
- package/build/commands/create-extension/index.d.ts +2 -0
- package/build/commands/create-extension/index.js +106 -0
- package/build/commands/create-extension/index.js.map +1 -0
- package/build/commands/create-extension/types.d.ts +9 -0
- package/build/commands/create-extension/types.js +6 -0
- package/build/commands/create-extension/types.js.map +1 -0
- package/build/commands/create-extension/utils/add-target-to-config.d.ts +2 -0
- package/build/commands/create-extension/utils/add-target-to-config.js +56 -0
- package/build/commands/create-extension/utils/add-target-to-config.js.map +1 -0
- package/build/commands/create-extension/utils/create-from-template.d.ts +2 -0
- package/build/commands/create-extension/utils/create-from-template.js +29 -0
- package/build/commands/create-extension/utils/create-from-template.js.map +1 -0
- package/build/commands/create-extension/utils/install-shop-minis-ui-extensions.d.ts +1 -0
- package/build/commands/create-extension/utils/install-shop-minis-ui-extensions.js +9 -0
- package/build/commands/create-extension/utils/install-shop-minis-ui-extensions.js.map +1 -0
- package/build/commands/generate-graphql-types/index.js +11 -9
- package/build/commands/generate-graphql-types/index.js.map +1 -1
- package/build/commands/submit/submit.js +5 -2
- package/build/commands/submit/submit.js.map +1 -1
- package/build/constants/extensions.d.ts +18 -0
- package/build/constants/extensions.js +23 -0
- package/build/constants/extensions.js.map +1 -0
- package/build/index.js +10 -8
- package/build/index.js.map +1 -1
- package/build/schemas/manifest.schema.json +0 -1
- package/build/utils/codemod.d.ts +65 -0
- package/build/utils/codemod.js +121 -0
- package/build/utils/codemod.js.map +1 -0
- package/build/utils/extensions.d.ts +3 -0
- package/build/utils/extensions.js +3 -0
- package/build/utils/extensions.js.map +1 -0
- package/package.json +2 -2
- package/templates/__template_common/.eslintrc.js +0 -3
- package/templates/__template_common/.graphqlrc.js +1 -0
- package/templates/extensions/__template_product-page.above-variants-picker+bundle-selector/input.graphql +6 -0
- package/templates/extensions/__template_product-page.above-variants-picker+bundle-selector/input.graphql.d.ts +26 -0
- package/templates/extensions/__template_product-page.above-variants-picker+bundle-selector/render.tsx +49 -0
- package/templates/extensions/__template_product-page.above-variants-picker+bundle-selector/seed.ts +66 -0
- package/build/utils/extension-targets.d.ts +0 -3
- package/build/utils/extension-targets.js +0 -4
- package/build/utils/extension-targets.js.map +0 -1
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ExtensionTarget, ExtensionType } from '../../constants/extensions.js';
|
|
2
|
+
import { ExtensionPage } from './types.js';
|
|
3
|
+
export declare const DEFAULT_OUTPUT_DIR = "src/targets";
|
|
4
|
+
export declare const EXTENSION_TYPE_CONFIG: Record<ExtensionType, {
|
|
5
|
+
label: string;
|
|
6
|
+
}>;
|
|
7
|
+
export declare const EXTENSION_PAGE_CONFIG: Record<ExtensionPage, {
|
|
8
|
+
templates: ExtensionType[];
|
|
9
|
+
}>;
|
|
10
|
+
export declare const EXTENSION_TARGET_CONFIG: {
|
|
11
|
+
"shop.product.variants.render-before": {
|
|
12
|
+
label: string;
|
|
13
|
+
page: ExtensionPage;
|
|
14
|
+
};
|
|
15
|
+
"store-page": {
|
|
16
|
+
label: string;
|
|
17
|
+
page: ExtensionPage;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export declare const EXTENSION_TARGETS_WITH_TEMPLATES: Record<ExtensionTarget, {
|
|
21
|
+
label: string;
|
|
22
|
+
page: ExtensionPage;
|
|
23
|
+
}>;
|
|
24
|
+
export declare const EXTENSION_TARGETS_WITH_TEMPLATES_KEYS: ExtensionTarget[];
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ExtensionTarget, ExtensionType } from '../../constants/extensions.js';
|
|
2
|
+
import { ExtensionPage } from './types.js';
|
|
3
|
+
export const DEFAULT_OUTPUT_DIR = 'src/targets';
|
|
4
|
+
export const EXTENSION_TYPE_CONFIG = {
|
|
5
|
+
[ExtensionType.VIDEO_COLLECTION]: {
|
|
6
|
+
label: 'Video Collection',
|
|
7
|
+
},
|
|
8
|
+
[ExtensionType.IMAGE_COLLECTION]: {
|
|
9
|
+
label: 'Image Collection',
|
|
10
|
+
},
|
|
11
|
+
[ExtensionType.BUNDLE_SELECTOR]: {
|
|
12
|
+
label: 'Bundle Selector',
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
// Add to this as new templates are created and they will appear in the CLI as options automatically
|
|
16
|
+
export const EXTENSION_PAGE_CONFIG = {
|
|
17
|
+
[ExtensionPage.PRODUCT_PAGE]: {
|
|
18
|
+
templates: [ExtensionType.BUNDLE_SELECTOR],
|
|
19
|
+
},
|
|
20
|
+
[ExtensionPage.STORE_PAGE]: {
|
|
21
|
+
templates: [],
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
export const EXTENSION_TARGET_CONFIG = {
|
|
25
|
+
[ExtensionTarget['shop.product.variants.render-before']]: {
|
|
26
|
+
label: 'Product Page - Above Variants Picker',
|
|
27
|
+
page: ExtensionPage.PRODUCT_PAGE,
|
|
28
|
+
},
|
|
29
|
+
[ExtensionTarget['store-page']]: {
|
|
30
|
+
label: 'Store Page',
|
|
31
|
+
page: ExtensionPage.STORE_PAGE,
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
export const EXTENSION_TARGETS_WITH_TEMPLATES = Object.entries(EXTENSION_TARGET_CONFIG).reduce((acc, [key, value]) => {
|
|
35
|
+
if (EXTENSION_PAGE_CONFIG[value.page].templates.length > 0) {
|
|
36
|
+
acc[key] = value;
|
|
37
|
+
}
|
|
38
|
+
return acc;
|
|
39
|
+
}, {});
|
|
40
|
+
export const EXTENSION_TARGETS_WITH_TEMPLATES_KEYS = Object.keys(EXTENSION_TARGETS_WITH_TEMPLATES);
|
|
41
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","source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,CAAC,MAAM,GAAG,CAAC,EAAE;QAC1D,GAAG,CAAC,GAAsB,CAAC,GAAG,KAAK,CAAA;KACpC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC,EAAE,EAAmE,CAAC,CAAA;AAEvE,MAAM,CAAC,MAAM,qCAAqC,GAAG,MAAM,CAAC,IAAI,CAC9D,gCAAgC,CACZ,CAAA"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { AbortError, handler as handleError } from '@shopify/cli-kit/node/error';
|
|
3
|
+
import { outputDebug } from '@shopify/cli-kit/node/output';
|
|
4
|
+
import { renderSelectPrompt, renderSuccess } from '@shopify/cli-kit/node/ui';
|
|
5
|
+
import { Command, Option } from 'commander';
|
|
6
|
+
import { ExtensionTarget } from '../../constants/extensions.js';
|
|
7
|
+
import { getMiniManifest } from '../../utils/minis-manifest.js';
|
|
8
|
+
import { DEFAULT_OUTPUT_DIR, EXTENSION_PAGE_CONFIG, EXTENSION_TARGETS_WITH_TEMPLATES, EXTENSION_TARGETS_WITH_TEMPLATES_KEYS, EXTENSION_TYPE_CONFIG, } from './constants.js';
|
|
9
|
+
import { addTargetToConfig } from './utils/add-target-to-config.js';
|
|
10
|
+
import { createExtensionFromTemplate } from './utils/create-from-template.js';
|
|
11
|
+
import { installShopMinisUiExtensions } from './utils/install-shop-minis-ui-extensions.js';
|
|
12
|
+
function isExtensionTarget(value) {
|
|
13
|
+
return Object.values(ExtensionTarget).includes(value);
|
|
14
|
+
}
|
|
15
|
+
export function loadCommand(parentProgram) {
|
|
16
|
+
const command = new Command()
|
|
17
|
+
.name('create-extension')
|
|
18
|
+
.description('add an extension to your mini')
|
|
19
|
+
.addOption(new Option('--target <extension target>', 'the location of the extension').choices(EXTENSION_TARGETS_WITH_TEMPLATES_KEYS))
|
|
20
|
+
.option('--verbose', 'print debugging messages') // compatible with cli-kit
|
|
21
|
+
.action(async (args) => {
|
|
22
|
+
outputDebug(`create-extension args ${JSON.stringify(args)}`);
|
|
23
|
+
const manifest = getMiniManifest();
|
|
24
|
+
const resolvedOutputDir = path.resolve(process.cwd(), DEFAULT_OUTPUT_DIR);
|
|
25
|
+
let target = isExtensionTarget(args.target)
|
|
26
|
+
? args.target
|
|
27
|
+
: null;
|
|
28
|
+
if (!target || !EXTENSION_TARGETS_WITH_TEMPLATES[target]) {
|
|
29
|
+
if (Object.keys(EXTENSION_TARGETS_WITH_TEMPLATES).length > 1) {
|
|
30
|
+
target = (await renderSelectPrompt({
|
|
31
|
+
message: 'Select the extension target where your Mini will be shown',
|
|
32
|
+
choices: Object.entries(EXTENSION_TARGETS_WITH_TEMPLATES).map(([key, { label }]) => ({
|
|
33
|
+
label,
|
|
34
|
+
value: key,
|
|
35
|
+
})),
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
target = Object.keys(EXTENSION_TARGETS_WITH_TEMPLATES)[0];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const targetConfig = EXTENSION_TARGETS_WITH_TEMPLATES[target];
|
|
43
|
+
const possibleExtensionTypes = EXTENSION_PAGE_CONFIG[targetConfig.page].templates;
|
|
44
|
+
let extensionType = possibleExtensionTypes[0];
|
|
45
|
+
if (possibleExtensionTypes.length > 1) {
|
|
46
|
+
extensionType = (await renderSelectPrompt({
|
|
47
|
+
message: 'Select the type of extension you want to create',
|
|
48
|
+
choices: possibleExtensionTypes.map(type => ({
|
|
49
|
+
label: EXTENSION_TYPE_CONFIG[type].label,
|
|
50
|
+
value: type,
|
|
51
|
+
})),
|
|
52
|
+
}));
|
|
53
|
+
}
|
|
54
|
+
outputDebug(`create-extension target: "${target}", type: "${extensionType}", output: ${resolvedOutputDir}`);
|
|
55
|
+
try {
|
|
56
|
+
await createExtensionFromTemplate(manifest.name, target, extensionType, resolvedOutputDir);
|
|
57
|
+
renderSuccess({
|
|
58
|
+
headline: 'Extension created successfully',
|
|
59
|
+
body: [
|
|
60
|
+
'Your extension was created at:',
|
|
61
|
+
{
|
|
62
|
+
bold: path.relative(process.cwd(), path.join(resolvedOutputDir, target)),
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
handleError(error);
|
|
69
|
+
return process.exit(1);
|
|
70
|
+
}
|
|
71
|
+
try {
|
|
72
|
+
await addTargetToConfig(target);
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
const wrappedError = new AbortError('Could not automatically link your new extension', `Failed to update your mini config: ${error}`, [
|
|
76
|
+
[
|
|
77
|
+
'Manually add your new',
|
|
78
|
+
{
|
|
79
|
+
command: target,
|
|
80
|
+
},
|
|
81
|
+
'extension to your mini config file',
|
|
82
|
+
],
|
|
83
|
+
]);
|
|
84
|
+
handleError(wrappedError);
|
|
85
|
+
return process.exit(1);
|
|
86
|
+
}
|
|
87
|
+
try {
|
|
88
|
+
await installShopMinisUiExtensions();
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
const wrappedError = new AbortError('Could not install `@shopify/shop-minis-ui-extensions`', `${error}`, [
|
|
92
|
+
[
|
|
93
|
+
'Manually install',
|
|
94
|
+
{
|
|
95
|
+
command: '@shopify/shop-minis-ui-extensions',
|
|
96
|
+
},
|
|
97
|
+
'before trying to run your extension',
|
|
98
|
+
],
|
|
99
|
+
]);
|
|
100
|
+
handleError(wrappedError);
|
|
101
|
+
return process.exit(1);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
parentProgram.addCommand(command, { hidden: true });
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/create-extension/index.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,OAAO,EAAC,UAAU,EAAE,OAAO,IAAI,WAAW,EAAC,MAAM,6BAA6B,CAAA;A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AAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;SACvB;IACH,CAAC,CAAC,CAAA;IAEJ,aAAa,CAAC,UAAU,CAAC,OAAO,EAAE,EAAC,MAAM,EAAE,IAAI,EAAC,CAAC,CAAA;AACnD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/commands/create-extension/types.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,8CAA6B,CAAA;IAC7B,0CAAyB,CAAA;AAC3B,CAAC,EAHW,aAAa,KAAb,aAAa,QAGxB"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { readFile, writeFile } from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { outputDebug } from '@shopify/cli-kit/node/output';
|
|
4
|
+
import _ from 'lodash';
|
|
5
|
+
import { ensureImportOf, ensureObjectProperty, findObjectExpression, j, } from '../../../utils/codemod.js';
|
|
6
|
+
import { execAsync } from '../../../utils/exec-async-child-process.js';
|
|
7
|
+
import { getRunBinCommand } from '../../../utils/package-manager.js';
|
|
8
|
+
const runCodemod = (fileContents, target) => {
|
|
9
|
+
const root = j(fileContents);
|
|
10
|
+
const targetPascalCase = _.startCase(target).replace(/ /g, '');
|
|
11
|
+
const importPath = `./targets/${target}/render`;
|
|
12
|
+
const originalImportName = 'Render';
|
|
13
|
+
const importName = `RenderIn${targetPascalCase}`;
|
|
14
|
+
const configObject = findObjectExpression(root, 'config');
|
|
15
|
+
if (!configObject) {
|
|
16
|
+
throw new Error('Could not find config object');
|
|
17
|
+
}
|
|
18
|
+
ensureImportOf(root, importPath, originalImportName, importName);
|
|
19
|
+
const targetsObject = ensureObjectProperty({
|
|
20
|
+
obj: configObject,
|
|
21
|
+
key: 'Targets',
|
|
22
|
+
defaultValue: j.objectExpression([]),
|
|
23
|
+
});
|
|
24
|
+
const targetsValue = targetsObject.value;
|
|
25
|
+
if (targetsValue.type !== 'ObjectExpression') {
|
|
26
|
+
throw new Error(`Unexpected type for Targets. Expected: ObjectExpression, Found: ${targetsValue.type}`);
|
|
27
|
+
}
|
|
28
|
+
ensureObjectProperty({
|
|
29
|
+
obj: targetsValue,
|
|
30
|
+
key: target,
|
|
31
|
+
defaultValue: j.identifier(importName),
|
|
32
|
+
overwrite: true,
|
|
33
|
+
});
|
|
34
|
+
return root.toSource();
|
|
35
|
+
};
|
|
36
|
+
export async function addTargetToConfig(target) {
|
|
37
|
+
const configFilePath = path.join(process.cwd(), 'src', 'index.tsx');
|
|
38
|
+
outputDebug(`Adding ${target} target to ${configFilePath}`);
|
|
39
|
+
const configFile = await readFile(configFilePath, 'utf8');
|
|
40
|
+
if (!configFile || !configFile.includes('MiniAppConfig')) {
|
|
41
|
+
throw new Error(`Couldn't find a config in ${configFilePath}`);
|
|
42
|
+
}
|
|
43
|
+
const result = runCodemod(configFile, target);
|
|
44
|
+
if (result === configFile) {
|
|
45
|
+
outputDebug(`No changes made to ${configFilePath}`);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
outputDebug(`Saving changes to ${configFilePath}`);
|
|
49
|
+
await writeFile(configFilePath, result, 'utf8');
|
|
50
|
+
const prettierCmd = await getRunBinCommand(`prettier -w ${configFilePath}`);
|
|
51
|
+
outputDebug(`Running ${prettierCmd}`);
|
|
52
|
+
await execAsync({
|
|
53
|
+
cmd: prettierCmd,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=add-target-to-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-target-to-config.js","sourceRoot":"","sources":["../../../../src/commands/create-extension/utils/add-target-to-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,SAAS,EAAC,MAAM,kBAAkB,CAAA;AACpD,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,OAAO,EAAC,WAAW,EAAC,MAAM,8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|
+
import path from 'path';
|
|
5
|
+
import { copy } from 'fs-extra';
|
|
6
|
+
import _ from 'lodash';
|
|
7
|
+
import { replaceStringsInTemplate } from '../../../utils/replace-strings-in-template.js';
|
|
8
|
+
const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
|
|
9
|
+
export async function createExtensionFromTemplate(miniName, extensionTarget, extensionType, outputDir) {
|
|
10
|
+
const combinedTemplateName = `${extensionTarget}+${extensionType}`;
|
|
11
|
+
const tmpDir = await mkdtemp(path.join(os.tmpdir(), `${combinedTemplateName}-`));
|
|
12
|
+
const templateDir = path.join(__dirname, '../../../../templates/extensions');
|
|
13
|
+
const extensionTemplateDir = path.join(templateDir, `__template_${combinedTemplateName}`);
|
|
14
|
+
const extensionDestinationDir = path.join(outputDir, extensionTarget);
|
|
15
|
+
const stringsToReplace = {
|
|
16
|
+
__MINI_APP_NAME_PASCAL_CASE__: _.startCase(miniName).replace(/ /g, ''),
|
|
17
|
+
__EXTENSION_TARGET_PASCAL_CASE__: _.startCase(extensionTarget).replace(/ /g, ''),
|
|
18
|
+
};
|
|
19
|
+
try {
|
|
20
|
+
await stat(extensionTemplateDir);
|
|
21
|
+
}
|
|
22
|
+
catch (_err) {
|
|
23
|
+
throw new Error(`Template not found: ${extensionTemplateDir}`);
|
|
24
|
+
}
|
|
25
|
+
await copy(extensionTemplateDir, tmpDir);
|
|
26
|
+
await replaceStringsInTemplate(tmpDir, stringsToReplace);
|
|
27
|
+
await copy(tmpDir, extensionDestinationDir);
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=create-from-template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-from-template.js","sourceRoot":"","sources":["../../../../src/commands/create-extension/utils/create-from-template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,IAAI,EAAC,MAAM,kBAAkB,CAAA;AAC9C,OAAO,GAAG,MAAM,UAAU,CAAA;AAC1B,OAAO,EAAE,MAAM,IAAI,CAA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CAAA;KAC/D;IAED,MAAM,IAAI,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAA;IACxC,MAAM,wBAAwB,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAA;IACxD,MAAM,IAAI,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAA;AAC7C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function installShopMinisUiExtensions(): Promise<void>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { outputDebug } from '@shopify/cli-kit/node/output';
|
|
2
|
+
import { execAsync } from '../../../utils/exec-async-child-process.js';
|
|
3
|
+
import { getUpgradePackageCommand } from '../../../utils/package-manager.js';
|
|
4
|
+
export async function installShopMinisUiExtensions() {
|
|
5
|
+
const command = await getUpgradePackageCommand('@shopify/shop-minis-ui-extensions');
|
|
6
|
+
outputDebug(`Running install command: ${command}`);
|
|
7
|
+
await execAsync(command);
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=install-shop-minis-ui-extensions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install-shop-minis-ui-extensions.js","sourceRoot":"","sources":["../../../../src/commands/create-extension/utils/install-shop-minis-ui-extensions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAA;AAExD,OAAO,EAAC,SAAS,EAAC,MAAM,4CAA4C,CAAA;AACpE,OAAO,EAAC,wBAAwB,EAAC,MAAM,mCAAmC,CAAA;AAE1E,MAAM,CAAC,KAAK,UAAU,4BAA4B;IAChD,MAAM,OAAO,GAAG,MAAM,wBAAwB,CAC5C,mCAAmC,CACpC,CAAA;IAED,WAAW,CAAC,4BAA4B,OAAO,EAAE,CAAC,CAAA;IAElD,MAAM,SAAS,CAAC,OAAO,CAAC,CAAA;AAC1B,CAAC"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';
|
|
2
1
|
import { execSync } from 'node:child_process';
|
|
3
|
-
import {
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
4
3
|
import chalk from 'chalk';
|
|
4
|
+
import { Command } from 'commander';
|
|
5
5
|
import { GraphQLConfig } from 'graphql-config';
|
|
6
|
+
import { EXTENSION_TARGET_KEYS, ExtensionTarget, } from '../../constants/extensions.js';
|
|
7
|
+
import { isProductExtensionTarget } from '../../utils/extensions.js';
|
|
6
8
|
import { getMiniManifest } from '../../utils/minis-manifest.js';
|
|
7
|
-
import { maybeApplyPatches } from '../../utils/patch-package.js';
|
|
8
9
|
import { getRunBinCommand } from '../../utils/package-manager.js';
|
|
9
|
-
import {
|
|
10
|
+
import { maybeApplyPatches } from '../../utils/patch-package.js';
|
|
10
11
|
// Import these bits as cjs because their esm exports are broken
|
|
11
12
|
// TODO: this way of requiring libraries loses the types
|
|
12
13
|
// https://github.com/Shopify/shop-minis-cli/issues/191
|
|
@@ -39,7 +40,7 @@ export function loadCommand(parentProgram) {
|
|
|
39
40
|
config: {
|
|
40
41
|
projects: {
|
|
41
42
|
default: {
|
|
42
|
-
schemaPath: 'node_modules/@shopify/shop-minis-
|
|
43
|
+
schemaPath: 'node_modules/@shopify/shop-minis-runtime/src/api/schema/minis.graphql',
|
|
43
44
|
includes: [`**/*.graphql`],
|
|
44
45
|
excludes: ['node_modules/**', 'src/targets/**'],
|
|
45
46
|
extensions: {
|
|
@@ -47,11 +48,12 @@ export function loadCommand(parentProgram) {
|
|
|
47
48
|
},
|
|
48
49
|
},
|
|
49
50
|
product: {
|
|
50
|
-
schemaPath: 'node_modules/@shopify/shop-minis-
|
|
51
|
-
includes: [
|
|
52
|
-
`src/targets/${EXTENSION_TARGETS.PRODUCT_PAGE}/**/*.graphql`,
|
|
53
|
-
],
|
|
51
|
+
schemaPath: 'node_modules/@shopify/shop-minis-runtime/src/api/schema/product.graphql',
|
|
52
|
+
includes: EXTENSION_TARGET_KEYS.filter(key => isProductExtensionTarget(ExtensionTarget[key])).map(key => `src/targets/${ExtensionTarget[key]}/**/*.graphql`),
|
|
54
53
|
excludes: ['node_modules/**'],
|
|
54
|
+
extensions: {
|
|
55
|
+
schemaTypesPath: schemaTypesPathConfig,
|
|
56
|
+
},
|
|
55
57
|
},
|
|
56
58
|
},
|
|
57
59
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/generate-graphql-types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/generate-graphql-types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,oBAAoB,CAAA;AAC3C,OAAO,EAAC,aAAa,EAAC,MAAM,aAAa,CAAA;AAEzC,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAA;AACjC,OAAO,EAAC,aAAa,EAAC,MAAM,gBAAgB,CAAA;AAO5C,OAAO,EACL,qBAAqB,EACrB,eAAe,GAChB,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAAC,wBAAwB,EAAC,MAAM,2BAA2B,CAAA;AAClE,OAAO,EAAC,eAAe,EAAC,MAAM,+BAA+B,CAAA;AAC7D,OAAO,EAAC,gBAAgB,EAAC,MAAM,gCAAgC,CAAA;AAC/D,OAAO,EAAC,iBAAiB,EAAC,MAAM,8BAA8B,CAAA;AAE9D,gEAAgE;AAChE,wDAAwD;AACxD,uDAAuD;AACvD,MAAM,EAAC,OAAO,EAAE,YAAY,EAAC,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAC5D,gCAAgC,CACjC,CAAA;AAOD,MAAM,UAAU,WAAW,CAAC,aAAsB;IAChD,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE;SAC1B,IAAI,CAAC,wBAAwB,CAAC;SAC9B,WAAW,CAAC,+CAA+C,CAAC;SAC5D,MAAM,CAAC,SAAS,EAA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,OAAO,CAAC,KAAK,EAAE;gBAClB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;aAChB;QACH,CAAC,CAAC,CAAA;QAEF,OAAO,CAAC,EAAE,CAAC,oBAAoB,EAAE,GAAG,EAAE;YACpC,2FAA2F;YAC3F,2DAA2D;YAC3D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACjB,CAAC,CAAC,CAAA;QAEF,OAAO,CAAC,GAAG,CAAC,EAAC,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAC,CAAC,CAAA;IAC9C,CAAC,CAAC,CAAA;IAEJ,aAAa,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;AACnC,CAAC"}
|
|
@@ -5,6 +5,7 @@ import editor from '@inquirer/editor';
|
|
|
5
5
|
import { getRunBinCommand } from '../../utils/package-manager.js';
|
|
6
6
|
import { assertNetworkAndAuth } from '../../utils/common-tasks.js';
|
|
7
7
|
import { execAsync } from '../../utils/exec-async-child-process.js';
|
|
8
|
+
import { getMiniManifest } from '../../utils/minis-manifest.js';
|
|
8
9
|
import { validateDescription } from './validation.js';
|
|
9
10
|
import { assertManifestValid, assertNoPendingSubmissions, createStagedUpload, createSubmission, packageShopMini, uploadSubmission, } from './tasks.js';
|
|
10
11
|
import { generateSubmissionArchiveFilename, getSubmissionArchivePath, } from './config.js';
|
|
@@ -100,8 +101,10 @@ export const completeConfig = async (args) => {
|
|
|
100
101
|
default: description,
|
|
101
102
|
});
|
|
102
103
|
}
|
|
103
|
-
|
|
104
|
-
|
|
104
|
+
if (getMiniManifest().entry_points?.length >= 1) {
|
|
105
|
+
const entryPointParams = await requestEntryPointParams();
|
|
106
|
+
description += `\n\n## Entry point params \n\n${entryPointParams}`;
|
|
107
|
+
}
|
|
105
108
|
return {
|
|
106
109
|
description,
|
|
107
110
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"submit.js","sourceRoot":"","sources":["../../../src/commands/submit/submit.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,WAAW,EACX,wBAAwB,GAEzB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAC,UAAU,EAAE,OAAO,IAAI,WAAW,EAAC,MAAM,6BAA6B,CAAA;AAC9E,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAA;AACxD,OAAO,MAAM,MAAM,kBAAkB,CAAA;AAErC,OAAO,EAAC,gBAAgB,EAAC,MAAM,gCAAgC,CAAA;AAC/D,OAAO,EAAC,oBAAoB,EAAC,MAAM,6BAA6B,CAAA;AAChE,OAAO,EAAC,SAAS,EAAC,MAAM,yCAAyC,CAAA;
|
|
1
|
+
{"version":3,"file":"submit.js","sourceRoot":"","sources":["../../../src/commands/submit/submit.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,WAAW,EACX,wBAAwB,GAEzB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAC,UAAU,EAAE,OAAO,IAAI,WAAW,EAAC,MAAM,6BAA6B,CAAA;AAC9E,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAA;AACxD,OAAO,MAAM,MAAM,kBAAkB,CAAA;AAErC,OAAO,EAAC,gBAAgB,EAAC,MAAM,gCAAgC,CAAA;AAC/D,OAAO,EAAC,oBAAoB,EAAC,MAAM,6BAA6B,CAAA;AAChE,OAAO,EAAC,SAAS,EAAC,MAAM,yCAAyC,CAAA;AACjE,OAAO,EAAC,eAAe,EAAC,MAAM,+BAA+B,CAAA;AAG7D,OAAO,EAAC,mBAAmB,EAAC,MAAM,iBAAiB,CAAA;AACnD,OAAO,EACL,mBAAmB,EACnB,0BAA0B,EAC1B,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,GACjB,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,iCAAiC,EACjC,wBAAwB,GACzB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAC,6BAA6B,EAAC,MAAM,6CAA6C,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oBAC1D;wBACE,OAAO,EAAE,MAAM,gBAAgB,CAAC,6BAA6B,CAAC;qBAC/D;iBACF;gBACD;oBACE,6CAA6C;oBAC7C;wBACE,OAAO,EAAE,MAAM,gBAAgB,CAAC,8BAA8B,CAAC;qBAChE;iBACF;aACF;SACF,CAAC,CAAA;KACH;IAAC,OAAO,KAAU,EAAE;QACnB,gCAAgC;QAChC,WAAW,CAAC,KAAK,CAAC,CAAA;QAElB,wEAAwE;QACxE,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,EAAE,SAAS,EAAE;YAC/B,WAAW,CACT,IAAI,UAAU,CACZ,mBAAmB,EACnB,mDAAmD,EACnD,CAAC,2BAA2B,EAAE,sCAAsC,CAAC,CACtE,CACF,CAAA;SACF;QAED,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;KAChB;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare enum ExtensionType {
|
|
2
|
+
VIDEO_COLLECTION = "video-collection",
|
|
3
|
+
IMAGE_COLLECTION = "image-collection",
|
|
4
|
+
BUNDLE_SELECTOR = "bundle-selector"
|
|
5
|
+
}
|
|
6
|
+
export declare enum ExtensionTarget {
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated - internal use only and will be removed in future releases of the minis sdk.
|
|
9
|
+
*/
|
|
10
|
+
'product-page' = "product-page",
|
|
11
|
+
'shop.product.variants.render-before' = "shop.product.variants.render-before",
|
|
12
|
+
'shop.product.policies.render-after' = "shop.product.variants.render-before",
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated - internal use only and will be removed in future releases of the minis sdk.
|
|
15
|
+
*/
|
|
16
|
+
'store-page' = "store-page"
|
|
17
|
+
}
|
|
18
|
+
export declare const EXTENSION_TARGET_KEYS: (keyof typeof ExtensionTarget)[];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export var ExtensionType;
|
|
2
|
+
(function (ExtensionType) {
|
|
3
|
+
ExtensionType["VIDEO_COLLECTION"] = "video-collection";
|
|
4
|
+
ExtensionType["IMAGE_COLLECTION"] = "image-collection";
|
|
5
|
+
ExtensionType["BUNDLE_SELECTOR"] = "bundle-selector";
|
|
6
|
+
})(ExtensionType || (ExtensionType = {}));
|
|
7
|
+
// copy and paste from minis sdk
|
|
8
|
+
// TODO: import from a single source of truth
|
|
9
|
+
export var ExtensionTarget;
|
|
10
|
+
(function (ExtensionTarget) {
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated - internal use only and will be removed in future releases of the minis sdk.
|
|
13
|
+
*/
|
|
14
|
+
ExtensionTarget["product-page"] = "product-page";
|
|
15
|
+
ExtensionTarget["shop.product.variants.render-before"] = "shop.product.variants.render-before";
|
|
16
|
+
ExtensionTarget["shop.product.policies.render-after"] = "shop.product.variants.render-before";
|
|
17
|
+
/**
|
|
18
|
+
* @deprecated - internal use only and will be removed in future releases of the minis sdk.
|
|
19
|
+
*/
|
|
20
|
+
ExtensionTarget["store-page"] = "store-page";
|
|
21
|
+
})(ExtensionTarget || (ExtensionTarget = {}));
|
|
22
|
+
export const EXTENSION_TARGET_KEYS = Object.keys(ExtensionTarget);
|
|
23
|
+
//# sourceMappingURL=extensions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extensions.js","sourceRoot":"","sources":["../../src/constants/extensions.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,sDAAqC,CAAA;IACrC,sDAAqC,CAAA;IACrC,oDAAmC,CAAA;AACrC,CAAC,EAJW,aAAa,KAAb,aAAa,QAIxB;AAED,gCAAgC;AAChC,6CAA6C;AAC7C,MAAM,CAAN,IAAY,eAcX;AAdD,WAAY,eAAe;IACzB;;OAEG;IACH,gDAA+B,CAAA;IAE/B,8FAA6E,CAAA;IAE7E,6FAA4E,CAAA;IAE5E;;OAEG;IACH,4CAA2B,CAAA;AAC7B,CAAC,EAdW,eAAe,KAAf,eAAe,QAc1B;AAED,MAAM,CAAC,MAAM,qBAAqB,GAChC,MAAM,CAAC,IAAI,CAAC,eAAe,CAAqC,CAAA"}
|
package/build/index.js
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env -S node --experimental-json-modules --require=suppress-experimental-warnings
|
|
2
2
|
import { Command } from 'commander';
|
|
3
|
+
import { loadCommand as loadCancelSubmissionCommand } from './commands/cancel-submission/index.js';
|
|
4
|
+
import { loadCommand as loadCheckSubmissionCommand } from './commands/check-submission/index.js';
|
|
5
|
+
import { loadCommand as loadCodemodCommand } from './commands/codemod/index.js';
|
|
6
|
+
import { CLI_VERSION } from './commands/config.js';
|
|
7
|
+
import { loadCommand as loadCreateExtensionCommand } from './commands/create-extension/index.js';
|
|
3
8
|
import { loadCommand as loadCreateMiniCommand } from './commands/create-mini/index.js';
|
|
4
9
|
import { loadCommand as loadDevCommand } from './commands/dev/index.js';
|
|
10
|
+
import { command as doctorCommand } from './commands/doctor/index.js';
|
|
11
|
+
import { command as featuresCommand } from './commands/features/index.js';
|
|
5
12
|
import { loadCommand as loadGenerateGraphqlTypesCommand } from './commands/generate-graphql-types/index.js';
|
|
13
|
+
import { loadCommand as loadInfoCommand } from './commands/info/index.js';
|
|
14
|
+
import { loadCommand as loadSetupCommand } from './commands/setup/index.js';
|
|
6
15
|
import { loadCommand as loadSubmitCommand } from './commands/submit/index.js';
|
|
7
|
-
import { loadCommand as loadCancelSubmissionCommand } from './commands/cancel-submission/index.js';
|
|
8
|
-
import { loadCommand as loadCheckSubmissionCommand } from './commands/check-submission/index.js';
|
|
9
16
|
import { loadCommand as loadUpgradeCommand } from './commands/upgrade/index.js';
|
|
10
|
-
import { loadCommand as loadCodemodCommand } from './commands/codemod/index.js';
|
|
11
17
|
import { loadCommand as loadValidateManifestCommand } from './commands/validate-manifest/index.js';
|
|
12
|
-
import { loadCommand as loadInfoCommand } from './commands/info/index.js';
|
|
13
|
-
import { loadCommand as loadSetupCommand } from './commands/setup/index.js';
|
|
14
|
-
import { command as doctorCommand } from './commands/doctor/index.js';
|
|
15
|
-
import { command as featuresCommand } from './commands/features/index.js';
|
|
16
|
-
import { CLI_VERSION } from './commands/config.js';
|
|
17
18
|
const program = new Command();
|
|
18
19
|
async function loadCommands() {
|
|
19
20
|
loadCreateMiniCommand(program);
|
|
@@ -27,6 +28,7 @@ async function loadCommands() {
|
|
|
27
28
|
loadCodemodCommand(program);
|
|
28
29
|
loadInfoCommand(program);
|
|
29
30
|
loadSetupCommand(program);
|
|
31
|
+
loadCreateExtensionCommand(program);
|
|
30
32
|
program.addCommand(doctorCommand);
|
|
31
33
|
program.addCommand(featuresCommand);
|
|
32
34
|
}
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAA;AAEjC,OAAO,EAAC,WAAW,IAAI,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAA;AAEjC,OAAO,EAAC,WAAW,IAAI,2BAA2B,EAAC,MAAM,uCAAuC,CAAA;AAChG,OAAO,EAAC,WAAW,IAAI,0BAA0B,EAAC,MAAM,sCAAsC,CAAA;AAC9F,OAAO,EAAC,WAAW,IAAI,kBAAkB,EAAC,MAAM,6BAA6B,CAAA;AAC7E,OAAO,EAAC,WAAW,EAAC,MAAM,sBAAsB,CAAA;AAChD,OAAO,EAAC,WAAW,IAAI,0BAA0B,EAAC,MAAM,sCAAsC,CAAA;AAC9F,OAAO,EAAC,WAAW,IAAI,qBAAqB,EAAC,MAAM,iCAAiC,CAAA;AACpF,OAAO,EAAC,WAAW,IAAI,cAAc,EAAC,MAAM,yBAAyB,CAAA;AACrE,OAAO,EAAC,OAAO,IAAI,aAAa,EAAC,MAAM,4BAA4B,CAAA;AACnE,OA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IAAI,CAAC,GAAG,EAAE;IACT,OAAO,CAAC,KAAK,EAAE,CAAA;AACjB,CAAC,CAAC;KACD,KAAK,CAAC,GAAG,CAAC,EAAE;IACX,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IAChB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import jscodeshift from 'jscodeshift';
|
|
2
|
+
export declare const j: jscodeshift.JSCodeshift;
|
|
3
|
+
/**
|
|
4
|
+
* Find the first import declaration of a module
|
|
5
|
+
*
|
|
6
|
+
* Returns an object containing:
|
|
7
|
+
* - `importDeclaration`: This is the whole import node. This is null if no import is found
|
|
8
|
+
* - `specifier`: This is the specific import specifier node that matches the name/alias. Also null if not found
|
|
9
|
+
*
|
|
10
|
+
* If `importedAsName` is not provided, it will look for an import like:
|
|
11
|
+
* ```
|
|
12
|
+
* import {importedName} from 'importPath'
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* If `importedAsName` is provided, it will look for an import like:
|
|
16
|
+
* ```
|
|
17
|
+
* import {importedName as importedAsName} from 'importPath'
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare const findImportOf: (root: ReturnType<typeof jscodeshift>, importPath: string, importedName: string, importedAsName?: string) => {
|
|
21
|
+
specifier: import("ast-types").namedTypes.ImportSpecifier | import("ast-types").namedTypes.ImportDefaultSpecifier | import("ast-types").namedTypes.ImportNamespaceSpecifier | null;
|
|
22
|
+
importDeclaration: import("ast-types").namedTypes.ImportDeclaration;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Ensure that an import of a module is present in the file
|
|
26
|
+
*
|
|
27
|
+
* If the import is not present, it will be added to the top of the file
|
|
28
|
+
*
|
|
29
|
+
* Returns the specifier and import declaration nodes that were found, edited or created
|
|
30
|
+
*/
|
|
31
|
+
export declare const ensureImportOf: (root: ReturnType<typeof jscodeshift>, importPath: string, importedName: string, importedAsName?: string) => {
|
|
32
|
+
specifier: import("ast-types").namedTypes.ImportSpecifier | import("ast-types").namedTypes.ImportDefaultSpecifier | import("ast-types").namedTypes.ImportNamespaceSpecifier;
|
|
33
|
+
importDeclaration: import("ast-types").namedTypes.ImportDeclaration;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Find an object expression by its name like
|
|
37
|
+
*
|
|
38
|
+
* ```
|
|
39
|
+
* const objName = {
|
|
40
|
+
* key: 'value',
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* Returns the object expression node if found, otherwise null
|
|
45
|
+
*
|
|
46
|
+
* If multiple are found, the first one is returned
|
|
47
|
+
*/
|
|
48
|
+
export declare const findObjectExpression: (root: ReturnType<typeof jscodeshift>, objName: string) => import("ast-types").namedTypes.ObjectExpression | null;
|
|
49
|
+
/**
|
|
50
|
+
* Ensure that an object has a property with a specific key
|
|
51
|
+
*
|
|
52
|
+
* If the property is not present, it will be added to the object
|
|
53
|
+
*
|
|
54
|
+
* If `defaultValue` is provided, the property will be set to that value if it does not exist
|
|
55
|
+
*
|
|
56
|
+
* If `overwrite` is also true, the property will be replaced with the `defaultValue`
|
|
57
|
+
*
|
|
58
|
+
* Returns the property node that was found or created
|
|
59
|
+
*/
|
|
60
|
+
export declare const ensureObjectProperty: ({ obj, key, defaultValue, overwrite, }: {
|
|
61
|
+
obj: jscodeshift.ObjectExpression;
|
|
62
|
+
key: string;
|
|
63
|
+
defaultValue: jscodeshift.Property['value'];
|
|
64
|
+
overwrite?: boolean | undefined;
|
|
65
|
+
}) => import("ast-types").namedTypes.Property;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import jscodeshift from 'jscodeshift';
|
|
2
|
+
export const j = jscodeshift.withParser('tsx');
|
|
3
|
+
/**
|
|
4
|
+
* Find the first import declaration of a module
|
|
5
|
+
*
|
|
6
|
+
* Returns an object containing:
|
|
7
|
+
* - `importDeclaration`: This is the whole import node. This is null if no import is found
|
|
8
|
+
* - `specifier`: This is the specific import specifier node that matches the name/alias. Also null if not found
|
|
9
|
+
*
|
|
10
|
+
* If `importedAsName` is not provided, it will look for an import like:
|
|
11
|
+
* ```
|
|
12
|
+
* import {importedName} from 'importPath'
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* If `importedAsName` is provided, it will look for an import like:
|
|
16
|
+
* ```
|
|
17
|
+
* import {importedName as importedAsName} from 'importPath'
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export const findImportOf = (root, importPath, importedName, importedAsName) => {
|
|
21
|
+
const matchedImportDeclaration = root
|
|
22
|
+
.find(j.ImportDeclaration, {
|
|
23
|
+
source: { value: importPath },
|
|
24
|
+
})
|
|
25
|
+
.nodes()[0] ?? null;
|
|
26
|
+
const matchedSpecifier = matchedImportDeclaration?.specifiers?.filter(specifier => {
|
|
27
|
+
if (specifier.type !== 'ImportSpecifier')
|
|
28
|
+
return false;
|
|
29
|
+
return importedAsName
|
|
30
|
+
? specifier.imported.name === importedName &&
|
|
31
|
+
specifier?.local?.name === importedAsName
|
|
32
|
+
: specifier.imported.name === importedName;
|
|
33
|
+
})[0] ?? null;
|
|
34
|
+
return {
|
|
35
|
+
specifier: matchedSpecifier,
|
|
36
|
+
importDeclaration: matchedImportDeclaration,
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Ensure that an import of a module is present in the file
|
|
41
|
+
*
|
|
42
|
+
* If the import is not present, it will be added to the top of the file
|
|
43
|
+
*
|
|
44
|
+
* Returns the specifier and import declaration nodes that were found, edited or created
|
|
45
|
+
*/
|
|
46
|
+
export const ensureImportOf = (root, importPath, importedName, importedAsName) => {
|
|
47
|
+
let { importDeclaration, specifier } = findImportOf(root, importPath, importedName, importedAsName);
|
|
48
|
+
if (!specifier) {
|
|
49
|
+
specifier = importedAsName
|
|
50
|
+
? j.importSpecifier(j.identifier(importedName), j.identifier(importedAsName))
|
|
51
|
+
: j.importSpecifier(j.identifier(importedName));
|
|
52
|
+
if (!importDeclaration) {
|
|
53
|
+
importDeclaration = j.importDeclaration([], j.literal(importPath));
|
|
54
|
+
root.get().node.program.body.unshift(importDeclaration);
|
|
55
|
+
}
|
|
56
|
+
importDeclaration?.specifiers?.push(specifier);
|
|
57
|
+
}
|
|
58
|
+
return { specifier, importDeclaration };
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Find an object expression by its name like
|
|
62
|
+
*
|
|
63
|
+
* ```
|
|
64
|
+
* const objName = {
|
|
65
|
+
* key: 'value',
|
|
66
|
+
* }
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* Returns the object expression node if found, otherwise null
|
|
70
|
+
*
|
|
71
|
+
* If multiple are found, the first one is returned
|
|
72
|
+
*/
|
|
73
|
+
export const findObjectExpression = (root, objName) => {
|
|
74
|
+
const result = root
|
|
75
|
+
.find(j.VariableDeclarator, {
|
|
76
|
+
id: { type: 'Identifier', name: objName },
|
|
77
|
+
init: { type: 'ObjectExpression' },
|
|
78
|
+
})
|
|
79
|
+
.nodes()[0];
|
|
80
|
+
return result && result?.init?.type === 'ObjectExpression'
|
|
81
|
+
? result.init
|
|
82
|
+
: null;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Ensure that an object has a property with a specific key
|
|
86
|
+
*
|
|
87
|
+
* If the property is not present, it will be added to the object
|
|
88
|
+
*
|
|
89
|
+
* If `defaultValue` is provided, the property will be set to that value if it does not exist
|
|
90
|
+
*
|
|
91
|
+
* If `overwrite` is also true, the property will be replaced with the `defaultValue`
|
|
92
|
+
*
|
|
93
|
+
* Returns the property node that was found or created
|
|
94
|
+
*/
|
|
95
|
+
export const ensureObjectProperty = ({ obj, key, defaultValue, overwrite = false, }) => {
|
|
96
|
+
const properties = obj.properties;
|
|
97
|
+
let targetProperty = properties.find(prop => {
|
|
98
|
+
if (prop.type !== 'ObjectProperty')
|
|
99
|
+
return false;
|
|
100
|
+
if (prop.key.type === 'Identifier' && prop.key.name === key)
|
|
101
|
+
return true;
|
|
102
|
+
if (prop.key.type === 'StringLiteral' && prop.key.value === key)
|
|
103
|
+
return true;
|
|
104
|
+
return false;
|
|
105
|
+
}) ?? null;
|
|
106
|
+
if (targetProperty) {
|
|
107
|
+
if (overwrite) {
|
|
108
|
+
targetProperty.value = defaultValue;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
const safeKeyName = /^[a-zA-Z_$][a-zA-Z_$0-9]*$/;
|
|
113
|
+
const identifier = safeKeyName.test(key)
|
|
114
|
+
? j.identifier(key)
|
|
115
|
+
: j.stringLiteral(key);
|
|
116
|
+
targetProperty = j.property('init', identifier, defaultValue);
|
|
117
|
+
properties.push(targetProperty);
|
|
118
|
+
}
|
|
119
|
+
return targetProperty;
|
|
120
|
+
};
|
|
121
|
+
//# sourceMappingURL=codemod.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codemod.js","sourceRoot":"","sources":["../../src/utils/codemod.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,aAAa,CAAA;AAErC,MAAM,CAAC,MAAM,CAAC,GAAG,WAAW,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;AAE9C;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,IAAoC,EACpC,UAAkB,EAClB,YAAoB,EACpB,cAAuB,EACvB,EAAE;IACF,MAAM,wBAAwB,GAC5B,IAAI;SACD,IAAI,CAAC,CAAC,CAAC,iBAAiB,EAAE;QACzB,MAAM,EAAE,EAAC,KAAK,EAAE,UAAU,EAAC;KAC5B,CAAC;SACD,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAAA;IAEvB,MAAM,gBAAgB,GACpB,wBAAwB,EAAE,UAAU,EAAE,MAAM,CAAC,SAAS,CAAC,EAAE;QACvD,IAAI,SAAS,CAAC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AAE;YACb,cAAc,CAAC,KAAK,GAAG,YAAY,CAAA;SACpC;KACF;SAAM;QACL,MAAM,WAAW,GAAG,4BAA4B,CAAA;QAChD,MAAM,UAAU,GAAG,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC;YACtC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC;YACnB,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,GAAG,CAAC,CAAA;QAExB,cAAc,GAAG,CAAC,CAAC,QAAQ,CAAC,MAAM,EAAE,UAAU,EAAE,YAAY,CAAC,CAAA;QAE7D,UAAU,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;KAChC;IAED,OAAO,cAAc,CAAA;AACvB,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extensions.js","sourceRoot":"","sources":["../../src/utils/extensions.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,MAAuB,EAAE,EAAE,CAClE,MAAM,CAAC,UAAU,CAAC,cAAc,CAAC,CAAA;AAEnC,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,MAAuB,EAAE,EAAE,CAChE,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public",
|
|
5
5
|
"@shopify:registry": "https://registry.npmjs.org/"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.0.
|
|
7
|
+
"version": "0.0.105-alpha.0",
|
|
8
8
|
"description": "Shop Minis CLI",
|
|
9
9
|
"main": "build/index.js",
|
|
10
10
|
"bin": {
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"fs-extra": "^11.1.0",
|
|
72
72
|
"glob": "^9.3.2",
|
|
73
73
|
"google-auth-library": "9.8.0",
|
|
74
|
-
"graphql": "^
|
|
74
|
+
"graphql": "^16.0.0",
|
|
75
75
|
"graphql-config": "^4.3.5",
|
|
76
76
|
"graphql-request": "^5.2.0",
|
|
77
77
|
"graphql-typescript-definitions": "3.3.6",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('@shopify/shop-minis-runtime/graphqlrc')
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { DocumentNode } from "graphql-typed";
|
|
2
|
+
import { TypedDocumentNode } from "@graphql-typed-document-node/core";
|
|
3
|
+
export namespace __MINI_APP_NAME_PASCAL_CASE____EXTENSION_TARGET_PASCAL_CASE__ExtensionQueryPartialData {
|
|
4
|
+
export interface Product {
|
|
5
|
+
__typename?: "Product" | null;
|
|
6
|
+
id?: string | null;
|
|
7
|
+
title?: string | null;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export interface __MINI_APP_NAME_PASCAL_CASE____EXTENSION_TARGET_PASCAL_CASE__ExtensionQueryPartialData {
|
|
11
|
+
product?: __MINI_APP_NAME_PASCAL_CASE____EXTENSION_TARGET_PASCAL_CASE__ExtensionQueryPartialData.Product | null;
|
|
12
|
+
}
|
|
13
|
+
export namespace __MINI_APP_NAME_PASCAL_CASE____EXTENSION_TARGET_PASCAL_CASE__ExtensionQueryData {
|
|
14
|
+
export interface Product {
|
|
15
|
+
__typename: "Product";
|
|
16
|
+
id: string;
|
|
17
|
+
title: string;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export interface __MINI_APP_NAME_PASCAL_CASE____EXTENSION_TARGET_PASCAL_CASE__ExtensionQueryData {
|
|
21
|
+
product?: __MINI_APP_NAME_PASCAL_CASE____EXTENSION_TARGET_PASCAL_CASE__ExtensionQueryData.Product | null;
|
|
22
|
+
}
|
|
23
|
+
declare const document: DocumentNode<__MINI_APP_NAME_PASCAL_CASE____EXTENSION_TARGET_PASCAL_CASE__ExtensionQueryData, never, __MINI_APP_NAME_PASCAL_CASE____EXTENSION_TARGET_PASCAL_CASE__ExtensionQueryPartialData> & TypedDocumentNode<__MINI_APP_NAME_PASCAL_CASE____EXTENSION_TARGET_PASCAL_CASE__ExtensionQueryData, {
|
|
24
|
+
[key: string]: never;
|
|
25
|
+
}>;
|
|
26
|
+
export default document;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import {ComponentProps, useEffect, useState} from 'react'
|
|
2
|
+
import {BundleSelector} from '@shopify/shop-minis-ui-extensions'
|
|
3
|
+
import {useExtensionShopActions} from '@shopify/shop-minis-platform-sdk/actions'
|
|
4
|
+
|
|
5
|
+
import type {__MINI_APP_NAME_PASCAL_CASE____EXTENSION_TARGET_PASCAL_CASE__ExtensionQueryData as InputData} from './input.graphql'
|
|
6
|
+
import seedData from './seed'
|
|
7
|
+
|
|
8
|
+
type BundleSelectorItems = ComponentProps<typeof BundleSelector>['items']
|
|
9
|
+
|
|
10
|
+
export function Render({
|
|
11
|
+
extensionData,
|
|
12
|
+
}: {
|
|
13
|
+
extensionData: InputData
|
|
14
|
+
}) {
|
|
15
|
+
// Here we are using seed data to populate the initial state of the bundle selector.
|
|
16
|
+
// You can replace this with the actual data from `extensionData`
|
|
17
|
+
const initialBundleSelectorItems: BundleSelectorItems = seedData
|
|
18
|
+
const [bundleSelectorItems, setBundleSelectorItems] = useState(
|
|
19
|
+
initialBundleSelectorItems
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
const {updateLineItemAttributes} = useExtensionShopActions()
|
|
23
|
+
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (!bundleSelectorItems) return
|
|
26
|
+
|
|
27
|
+
const lineItemAttributes = bundleSelectorItems.map(
|
|
28
|
+
item => item.options.find(option => option.selected)?.variantId
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
updateLineItemAttributes({
|
|
32
|
+
lineItemAttributes: [
|
|
33
|
+
{
|
|
34
|
+
key: '_component_reference',
|
|
35
|
+
value: JSON.stringify(lineItemAttributes),
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
})
|
|
39
|
+
}, [updateLineItemAttributes, bundleSelectorItems])
|
|
40
|
+
|
|
41
|
+
if (!bundleSelectorItems) return null
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<BundleSelector
|
|
45
|
+
items={bundleSelectorItems}
|
|
46
|
+
onChange={setBundleSelectorItems}
|
|
47
|
+
/>
|
|
48
|
+
)
|
|
49
|
+
}
|
package/templates/extensions/__template_product-page.above-variants-picker+bundle-selector/seed.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import {BundleSelector} from '@shopify/shop-minis-ui-extensions'
|
|
2
|
+
import {ComponentProps} from 'react'
|
|
3
|
+
|
|
4
|
+
const seedData: ComponentProps<typeof BundleSelector>['items'] = [
|
|
5
|
+
{
|
|
6
|
+
title: 'Main Snowboard',
|
|
7
|
+
options: [
|
|
8
|
+
{
|
|
9
|
+
name: 'Main Snowboard',
|
|
10
|
+
value: 'Mr. Huebert Hydroxy Snowboard',
|
|
11
|
+
variantId: 'gid://shopify/ProductVariant/44887116906751',
|
|
12
|
+
availability: 1,
|
|
13
|
+
selected: false,
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
name: 'Main Snowboard',
|
|
17
|
+
value: 'The H2 Snowboard',
|
|
18
|
+
variantId: 'gid://shopify/ProductVariant/43698709922047',
|
|
19
|
+
availability: 2,
|
|
20
|
+
selected: true,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
name: 'Main Snowboard',
|
|
24
|
+
value: 'The Hosted Snowboard',
|
|
25
|
+
variantId: 'gid://shopify/ProductVariant/43698640978175',
|
|
26
|
+
availability: 2,
|
|
27
|
+
selected: false,
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: 'Main Snowboard',
|
|
31
|
+
value: 'The Hydrogen Snowboard',
|
|
32
|
+
variantId: 'gid://shopify/ProductVariant/43698681938175',
|
|
33
|
+
availability: 2,
|
|
34
|
+
selected: false,
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
title: 'Second snowboard',
|
|
40
|
+
options: [
|
|
41
|
+
{
|
|
42
|
+
name: 'Second snowboard',
|
|
43
|
+
value: 'The Oxygen Snowboard',
|
|
44
|
+
variantId: 'gid://shopify/ProductVariant/43698704318719',
|
|
45
|
+
availability: 2,
|
|
46
|
+
selected: true,
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: 'Second snowboard',
|
|
50
|
+
value: 'The S-Series Snowboard',
|
|
51
|
+
variantId: 'gid://shopify/ProductVariant/43698713526527',
|
|
52
|
+
availability: 2,
|
|
53
|
+
selected: false,
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: 'Second snowboard',
|
|
57
|
+
value: 'The Toggle Snowboard',
|
|
58
|
+
variantId: 'gid://shopify/ProductVariant/43698707857663',
|
|
59
|
+
availability: 2,
|
|
60
|
+
selected: false,
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
},
|
|
64
|
+
]
|
|
65
|
+
|
|
66
|
+
export default seedData
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extension-targets.js","sourceRoot":"","sources":["../../src/utils/extension-targets.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,YAAY,EAAE,cAAc;CAC7B,CAAA"}
|