@shopify/cli-kit 3.31.1 → 3.32.1
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/README.md +1 -1
- package/dist/api.d.ts +2 -5
- package/dist/api.js +2 -5
- package/dist/api.js.map +1 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +1 -0
- package/dist/constants.js.map +1 -1
- package/dist/environment/local.d.ts +1 -0
- package/dist/environment/local.js +4 -1
- package/dist/environment/local.js.map +1 -1
- package/dist/file.d.ts +10 -3
- package/dist/file.js +34 -34
- package/dist/file.js.map +1 -1
- package/dist/http/fetch.js +1 -1
- package/dist/http/fetch.js.map +1 -1
- package/dist/http.d.ts +0 -1
- package/dist/http.js +0 -1
- package/dist/http.js.map +1 -1
- package/dist/index.d.ts +0 -8
- package/dist/index.js +0 -8
- package/dist/index.js.map +1 -1
- package/dist/metadata.d.ts +1 -1
- package/dist/metadata.js.map +1 -1
- package/dist/monorail.d.ts +1 -1
- package/dist/monorail.js.map +1 -1
- package/dist/npm.js +1 -1
- package/dist/npm.js.map +1 -1
- package/dist/output.d.ts +2 -2
- package/dist/output.js +1 -1
- package/dist/output.js.map +1 -1
- package/dist/path.d.ts +3 -1
- package/dist/path.js +2 -2
- package/dist/path.js.map +1 -1
- package/dist/plugins.d.ts +1 -1
- package/dist/plugins.js.map +1 -1
- package/dist/{json.d.ts → private/common/json.d.ts} +0 -0
- package/dist/{json.js → private/common/json.js} +0 -0
- package/dist/private/common/json.js.map +1 -0
- package/dist/private/node/analytics.d.ts +27 -0
- package/dist/private/node/analytics.js +57 -0
- package/dist/private/node/analytics.js.map +1 -0
- package/dist/private/node/api/graphql.d.ts +5 -0
- package/dist/private/node/api/graphql.js +63 -0
- package/dist/private/node/api/graphql.js.map +1 -0
- package/dist/{api/common.d.ts → private/node/api/headers.d.ts} +3 -8
- package/dist/{api/common.js → private/node/api/headers.js} +20 -60
- package/dist/private/node/api/headers.js.map +1 -0
- package/dist/private/node/ui/components/Alert.test.js +5 -5
- package/dist/private/node/ui/components/Alert.test.js.map +1 -1
- package/dist/private/node/ui/components/Banner.js +5 -5
- package/dist/private/node/ui/components/Banner.js.map +1 -1
- package/dist/private/node/ui/components/Banner.test.js +11 -11
- package/dist/private/node/ui/components/Banner.test.js.map +1 -1
- package/dist/private/node/ui/components/Command.test.js +3 -3
- package/dist/private/node/ui/components/Command.test.js.map +1 -1
- package/dist/private/node/ui/components/ConcurrentOutput.d.ts +2 -2
- package/dist/private/node/ui/components/ConcurrentOutput.js +1 -1
- package/dist/private/node/ui/components/ConcurrentOutput.js.map +1 -1
- package/dist/private/node/ui/components/ConcurrentOutput.test.js +3 -3
- package/dist/private/node/ui/components/ConcurrentOutput.test.js.map +1 -1
- package/dist/private/node/ui/components/FatalError.test.js +9 -9
- package/dist/private/node/ui/components/FatalError.test.js.map +1 -1
- package/dist/private/node/ui/components/FilePath.test.js +3 -3
- package/dist/private/node/ui/components/FilePath.test.js.map +1 -1
- package/dist/private/node/ui/components/FullScreen.js +11 -9
- package/dist/private/node/ui/components/FullScreen.js.map +1 -1
- package/dist/private/node/ui/components/Link.test.js +5 -5
- package/dist/private/node/ui/components/Link.test.js.map +1 -1
- package/dist/private/node/ui/components/List.test.js +5 -5
- package/dist/private/node/ui/components/List.test.js.map +1 -1
- package/dist/private/node/ui/components/SelectInput.d.ts +2 -2
- package/dist/private/node/ui/components/SelectInput.js +16 -24
- package/dist/private/node/ui/components/SelectInput.js.map +1 -1
- package/dist/private/node/ui/components/SelectInput.test.js +62 -32
- package/dist/private/node/ui/components/SelectInput.test.js.map +1 -1
- package/dist/private/node/ui/components/{Prompt.d.ts → SelectPrompt.d.ts} +4 -3
- package/dist/private/node/ui/components/SelectPrompt.js +46 -0
- package/dist/private/node/ui/components/SelectPrompt.js.map +1 -0
- package/dist/private/node/ui/components/{Prompt.test.d.ts → SelectPrompt.test.d.ts} +0 -0
- package/dist/private/node/ui/components/{Prompt.test.js → SelectPrompt.test.js} +7 -6
- package/dist/private/node/ui/components/SelectPrompt.test.js.map +1 -0
- package/dist/private/node/ui/components/Table.js +2 -2
- package/dist/private/node/ui/components/Table.js.map +1 -1
- package/dist/private/node/ui/components/Tasks.d.ts +1 -1
- package/dist/private/node/ui/components/Tasks.js +3 -3
- package/dist/private/node/ui/components/Tasks.js.map +1 -1
- package/dist/private/node/ui/components/Tasks.test.js +4 -4
- package/dist/private/node/ui/components/Tasks.test.js.map +1 -1
- package/dist/private/node/ui/components/TextAnimation.js.map +1 -1
- package/dist/private/node/ui/components/TextInput.d.ts +9 -0
- package/dist/private/node/ui/components/TextInput.js +74 -0
- package/dist/private/node/ui/components/TextInput.js.map +1 -0
- package/dist/private/node/ui/components/TextInput.test.d.ts +1 -0
- package/dist/private/node/ui/components/TextInput.test.js +139 -0
- package/dist/private/node/ui/components/TextInput.test.js.map +1 -0
- package/dist/private/node/ui/components/TextPrompt.d.ts +8 -0
- package/dist/private/node/ui/components/TextPrompt.js +52 -0
- package/dist/private/node/ui/components/TextPrompt.js.map +1 -0
- package/dist/private/node/ui/components/TextPrompt.test.d.ts +1 -0
- package/dist/private/node/ui/components/TextPrompt.test.js +68 -0
- package/dist/private/node/ui/components/TextPrompt.test.js.map +1 -0
- package/dist/private/node/ui/components/TokenizedText.test.js +3 -3
- package/dist/private/node/ui/components/TokenizedText.test.js.map +1 -1
- package/dist/private/node/ui/components/UserInput.test.js +3 -3
- package/dist/private/node/ui/components/UserInput.test.js.map +1 -1
- package/dist/private/node/ui/hooks/use-layout.d.ts +6 -3
- package/dist/private/node/ui/hooks/use-layout.js +17 -8
- package/dist/private/node/ui/hooks/use-layout.js.map +1 -1
- package/dist/private/node/ui.d.ts +2 -3
- package/dist/private/node/ui.js +7 -16
- package/dist/private/node/ui.js.map +1 -1
- package/dist/public/common/array.js +1 -1
- package/dist/public/common/array.js.map +1 -1
- package/dist/public/common/collection.js +1 -1
- package/dist/public/common/collection.js.map +1 -1
- package/dist/public/common/function.js +1 -1
- package/dist/public/common/function.js.map +1 -1
- package/dist/public/common/lang.js +1 -1
- package/dist/public/common/lang.js.map +1 -1
- package/dist/public/common/object.js +4 -4
- package/dist/public/common/object.js.map +1 -1
- package/dist/public/common/string.d.ts +55 -1
- package/dist/public/common/string.js +93 -1
- package/dist/public/common/string.js.map +1 -1
- package/dist/public/common/url.d.ts +7 -0
- package/dist/public/common/url.js +17 -0
- package/dist/public/common/url.js.map +1 -0
- package/dist/public/node/abort.d.ts +16 -0
- package/dist/public/node/abort.js +17 -0
- package/dist/public/node/abort.js.map +1 -0
- package/dist/public/node/analytics.d.ts +13 -0
- package/dist/public/node/analytics.js +82 -0
- package/dist/public/node/analytics.js.map +1 -0
- package/dist/public/node/api/admin.d.ts +11 -0
- package/dist/public/node/api/admin.js +70 -0
- package/dist/public/node/api/admin.js.map +1 -0
- package/dist/public/node/api/oxygen.d.ts +22 -0
- package/dist/public/node/api/oxygen.js +40 -0
- package/dist/public/node/api/oxygen.js.map +1 -0
- package/dist/{api → public/node/api}/partners.d.ts +11 -3
- package/dist/public/node/api/partners.js +40 -0
- package/dist/public/node/api/partners.js.map +1 -0
- package/dist/public/node/archiver.js +1 -1
- package/dist/public/node/archiver.js.map +1 -1
- package/dist/public/node/base-command.js +1 -1
- package/dist/public/node/base-command.js.map +1 -1
- package/dist/public/node/crypto.d.ts +42 -0
- package/dist/public/node/crypto.js +55 -0
- package/dist/public/node/crypto.js.map +1 -0
- package/dist/public/node/error-handler.js +3 -2
- package/dist/public/node/error-handler.js.map +1 -1
- package/dist/public/node/framework.js +1 -1
- package/dist/public/node/framework.js.map +1 -1
- package/dist/public/node/hooks/postrun.js +2 -2
- package/dist/public/node/hooks/postrun.js.map +1 -1
- package/dist/public/node/hooks/prerun.js +2 -2
- package/dist/public/node/hooks/prerun.js.map +1 -1
- package/dist/{template.d.ts → public/node/liquid.d.ts} +10 -2
- package/dist/{template.js → public/node/liquid.js} +18 -13
- package/dist/public/node/liquid.js.map +1 -0
- package/dist/public/node/node-package-manager.d.ts +3 -3
- package/dist/public/node/node-package-manager.js +1 -1
- package/dist/public/node/node-package-manager.js.map +1 -1
- package/dist/public/node/os.d.ts +16 -0
- package/dist/{os.js → public/node/os.js} +33 -29
- package/dist/public/node/os.js.map +1 -0
- package/dist/public/node/presets.d.ts +1 -1
- package/dist/public/node/presets.js +2 -2
- package/dist/public/node/presets.js.map +1 -1
- package/dist/public/node/ruby.d.ts +13 -9
- package/dist/public/node/ruby.js +91 -23
- package/dist/public/node/ruby.js.map +1 -1
- package/dist/public/node/tcp.d.ts +2 -0
- package/dist/public/node/tcp.js +9 -0
- package/dist/public/node/tcp.js.map +1 -1
- package/dist/public/node/toml.d.ts +15 -0
- package/dist/public/node/toml.js +20 -0
- package/dist/public/node/toml.js.map +1 -0
- package/dist/public/node/ui.d.ts +12 -17
- package/dist/public/node/ui.js +25 -29
- package/dist/public/node/ui.js.map +1 -1
- package/dist/public/node/vscode.d.ts +14 -0
- package/dist/{vscode.js → public/node/vscode.js} +13 -7
- package/dist/public/node/vscode.js.map +1 -0
- package/dist/session/authorize.d.ts +4 -0
- package/dist/session/authorize.js +8 -3
- package/dist/session/authorize.js.map +1 -1
- package/dist/{api/identity.d.ts → session/identity-token-validation.d.ts} +0 -0
- package/dist/{api/identity.js → session/identity-token-validation.js} +1 -1
- package/dist/session/identity-token-validation.js.map +1 -0
- package/dist/session/redirect-listener.js +6 -3
- package/dist/session/redirect-listener.js.map +1 -1
- package/dist/session/schema.d.ts +18 -18
- package/dist/session/store.js +1 -1
- package/dist/session/store.js.map +1 -1
- package/dist/session.js +3 -3
- package/dist/session.js.map +1 -1
- package/dist/system.d.ts +2 -2
- package/dist/system.js +1 -1
- package/dist/system.js.map +1 -1
- package/dist/testing/ui.d.ts +1 -1
- package/dist/testing/ui.js +1 -1
- package/dist/testing/ui.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/ui/inquirer/autocomplete.d.ts +2 -2
- package/dist/ui/inquirer/autocomplete.js +1 -1
- package/dist/ui/inquirer/autocomplete.js.map +1 -1
- package/dist/ui/inquirer/input.d.ts +2 -2
- package/dist/ui/inquirer/input.js.map +1 -1
- package/dist/ui/inquirer/password.d.ts +2 -2
- package/dist/ui/inquirer/password.js.map +1 -1
- package/dist/ui/inquirer/select.d.ts +2 -2
- package/dist/ui/inquirer/select.js +2 -2
- package/dist/ui/inquirer/select.js.map +1 -1
- package/package.json +30 -27
- package/dist/abort.d.ts +0 -1
- package/dist/abort.js +0 -2
- package/dist/abort.js.map +0 -1
- package/dist/analytics.d.ts +0 -44
- package/dist/analytics.js +0 -154
- package/dist/analytics.js.map +0 -1
- package/dist/api/admin.d.ts +0 -3
- package/dist/api/admin.js +0 -56
- package/dist/api/admin.js.map +0 -1
- package/dist/api/common.js.map +0 -1
- package/dist/api/identity.js.map +0 -1
- package/dist/api/oxygen.d.ts +0 -5
- package/dist/api/oxygen.js +0 -30
- package/dist/api/oxygen.js.map +0 -1
- package/dist/api/partners.js +0 -44
- package/dist/api/partners.js.map +0 -1
- package/dist/http/graphql.d.ts +0 -13
- package/dist/http/graphql.js +0 -12
- package/dist/http/graphql.js.map +0 -1
- package/dist/id.d.ts +0 -6
- package/dist/id.js +0 -18
- package/dist/id.js.map +0 -1
- package/dist/json.js.map +0 -1
- package/dist/os.d.ts +0 -10
- package/dist/os.js.map +0 -1
- package/dist/private/node/ui/components/Prompt.js +0 -23
- package/dist/private/node/ui/components/Prompt.js.map +0 -1
- package/dist/private/node/ui/components/Prompt.test.js.map +0 -1
- package/dist/string.d.ts +0 -28
- package/dist/string.js +0 -77
- package/dist/string.js.map +0 -1
- package/dist/template.js.map +0 -1
- package/dist/toml.d.ts +0 -3
- package/dist/toml.js +0 -8
- package/dist/toml.js.map +0 -1
- package/dist/vscode.d.ts +0 -8
- package/dist/vscode.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string.js","sourceRoot":"","sources":["../../../src/public/common/string.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,mBAAmB,EAAC,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"string.js","sourceRoot":"","sources":["../../../src/public/common/string.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,mBAAmB,EAAC,MAAM,YAAY,CAAA;AAC9C,OAAO,EAAC,QAAQ,EAAC,MAAM,iBAAiB,CAAA;AAExC,MAAM,+BAA+B,GAAG;IACtC,YAAY;IACZ,YAAY;IACZ,aAAa;IACb,SAAS;IACT,YAAY;IACZ,aAAa;IACb,cAAc;IACd,aAAa;IACb,MAAM;IACN,OAAO;IACP,SAAS;IACT,QAAQ;IACR,UAAU;IACV,WAAW;IACX,WAAW;IACX,eAAe;IACf,YAAY;IACZ,UAAU;IACV,WAAW;IACX,WAAW;IACX,QAAQ;CACT,CAAA;AAED,MAAM,+BAA+B,GAAG;IACtC,QAAQ;IACR,WAAW;IACX,SAAS;IACT,UAAU;IACV,QAAQ;IACR,SAAS;IACT,QAAQ;IACR,UAAU;IACV,UAAU;IACV,aAAa;IACb,WAAW;IACX,QAAQ;IACR,OAAO;IACP,WAAW;IACX,OAAO;IACP,UAAU;IACV,UAAU;IACV,UAAU;IACV,YAAY;IACZ,UAAU;CACX,CAAA;AAED,MAAM,0BAA0B,GAAG;IACjC,SAAS;IACT,UAAU;IACV,UAAU;IACV,YAAY;IACZ,UAAU;IACV,SAAS;IACT,aAAa;IACb,SAAS;IACT,UAAU;IACV,WAAW;IACX,aAAa;IACb,UAAU;IACV,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,UAAU;IACV,YAAY;IACZ,aAAa;IACb,YAAY;IACZ,SAAS;IACT,YAAY;IACZ,QAAQ;IACR,OAAO;IACP,MAAM;IACN,aAAa;IACb,aAAa;IACb,MAAM;CACP,CAAA;AAED,MAAM,0BAA0B,GAAG;IACjC,MAAM;IACN,OAAO;IACP,QAAQ;IACR,MAAM;IACN,QAAQ;IACR,MAAM;IACN,YAAY;IACZ,aAAa;IACb,QAAQ;IACR,UAAU;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O,EAAC,SAAS,IAAI,UAAU,EAAC,MAAM,aAAa,CAAA;AAEnD;;GAEG;AACH,OAAO,EAAC,YAAY,IAAI,WAAW,EAAC,MAAM,aAAa,CAAA","sourcesContent":["import {takeRandomFromArray} from './array.js'\nimport {unstyled} from '../../output.js'\n\nconst SAFE_RANDOM_BUSINESS_ADJECTIVES = [\n 'commercial',\n 'profitable',\n 'amortizable',\n 'branded',\n 'integrated',\n 'synergistic',\n 'consolidated',\n 'diversified',\n 'lean',\n 'niche',\n 'premium',\n 'luxury',\n 'scalable',\n 'optimized',\n 'empowered',\n 'international',\n 'beneficial',\n 'fruitful',\n 'extensive',\n 'lucrative',\n 'modern',\n]\n\nconst SAFE_RANDOM_CREATIVE_ADJECTIVES = [\n 'bright',\n 'impactful',\n 'stylish',\n 'colorful',\n 'modern',\n 'minimal',\n 'trendy',\n 'creative',\n 'artistic',\n 'spectacular',\n 'glamorous',\n 'luxury',\n 'retro',\n 'nostalgic',\n 'comfy',\n 'polished',\n 'fabulous',\n 'balanced',\n 'monochrome',\n 'glitched',\n]\n\nconst SAFE_RANDOM_BUSINESS_NOUNS = [\n 'account',\n 'consumer',\n 'customer',\n 'enterprise',\n 'business',\n 'venture',\n 'marketplace',\n 'revenue',\n 'vertical',\n 'portfolio',\n 'negotiation',\n 'shipping',\n 'demand',\n 'supply',\n 'growth',\n 'merchant',\n 'investment',\n 'shareholder',\n 'conversion',\n 'capital',\n 'projection',\n 'upside',\n 'trade',\n 'deal',\n 'merchandise',\n 'transaction',\n 'sale',\n]\n\nconst SAFE_RANDOM_CREATIVE_NOUNS = [\n 'vibe',\n 'style',\n 'moment',\n 'mood',\n 'flavor',\n 'look',\n 'appearance',\n 'perspective',\n 'aspect',\n 'ambience',\n 'quality',\n 'backdrop',\n 'focus',\n 'tone',\n]\n\nexport type RandomNameFamily = 'business' | 'creative'\n\n/**\n * Generates a random name by combining an adjective and noun.\n *\n * @param family - Theme to use for the random name (business or creative).\n * @returns A random name generated by combining an adjective and noun.\n */\nexport function getRandomName(family: RandomNameFamily = 'business'): string {\n const mapping = {\n business: {\n adjectives: SAFE_RANDOM_BUSINESS_ADJECTIVES,\n nouns: SAFE_RANDOM_BUSINESS_NOUNS,\n },\n creative: {\n adjectives: SAFE_RANDOM_CREATIVE_ADJECTIVES,\n nouns: SAFE_RANDOM_CREATIVE_NOUNS,\n },\n }\n return `${takeRandomFromArray(mapping[family].adjectives)}-${takeRandomFromArray(mapping[family].nouns)}`\n}\n\n/**\n * Given a string, it returns it with the first letter capitalized.\n *\n * @param str - String to capitalize.\n * @returns String with the first letter capitalized.\n */\nexport function capitalize(str: string): string {\n return str.substring(0, 1).toUpperCase() + str.substring(1)\n}\n\n/**\n * Try to convert a string to an int, falling back to undefined if unable to.\n *\n * @param maybeInt - String to convert to an int.\n * @returns The int if it was able to convert, otherwise undefined.\n */\nexport function tryParseInt(maybeInt: string | undefined): number | undefined {\n let asInt: number | undefined\n if (maybeInt !== undefined) {\n asInt = parseInt(maybeInt, 10)\n if (isNaN(asInt)) {\n asInt = undefined\n }\n }\n return asInt\n}\n\n/**\n * Transforms a matrix of strings into a single string with the columns aligned.\n *\n * @param lines - Array of rows, where each row is an array of strings (representing columns).\n * @returns A string with the columns aligned.\n */\nexport function linesToColumns(lines: string[][]): string {\n const widths: number[] = []\n for (let i = 0; lines[0] && i < lines[0].length; i++) {\n const columnRows = lines.map((line) => line[i]!)\n widths.push(Math.max(...columnRows.map((row) => unstyled(row).length)))\n }\n const paddedLines = lines\n .map((line) => {\n return line\n .map((col, index) => {\n return `${col}${' '.repeat(widths[index]! - unstyled(col).length)}`\n })\n .join(' ')\n .trimEnd()\n })\n .join('\\n')\n return paddedLines\n}\n\n/**\n * Given a string, it transforms it to a slug (lowercase, hyphenated, no special chars, trimmed...).\n *\n * @param str - String to slugify.\n * @returns The slugified string.\n */\nexport function slugify(str: string): string {\n return str\n .toLowerCase()\n .trim()\n .replace(/[^\\w\\s-]/g, '')\n .replace(/[\\s_-]+/g, '-')\n .replace(/^-+|-+$/g, '')\n}\n\n/**\n * Given a string, it returns it with the special regex characters escaped.\n * More info: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping.\n *\n * @param str - String to escape.\n * @returns The escaped string.\n */\nexport function escapeRegExp(str: string): string {\n return str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n}\n\n/**\n * Transform a string to camelCase.\n */\nexport {camelCase as camelize} from 'change-case'\n\n/**\n * Transform a string to param-case.\n */\nexport {paramCase as hyphenate} from 'change-case'\n\n/**\n * Transform a string to snake_case.\n */\nexport {snakeCase as underscore} from 'change-case'\n\n/**\n * Transform a string to CONSTANT_CASE.\n */\nexport {constantCase as constantize} from 'change-case'\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if the format of a URL is valid or not.
|
|
3
|
+
*
|
|
4
|
+
* @param url - URL to be checked.
|
|
5
|
+
* @returns True if the URL is valid, false otherwise.
|
|
6
|
+
*/
|
|
7
|
+
export const isValidURL = (url) => {
|
|
8
|
+
try {
|
|
9
|
+
return Boolean(new URL(url));
|
|
10
|
+
}
|
|
11
|
+
catch (error) {
|
|
12
|
+
if (error instanceof TypeError)
|
|
13
|
+
return false;
|
|
14
|
+
throw error;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=url.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url.js","sourceRoot":"","sources":["../../../src/public/common/url.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,GAAW,EAAW,EAAE;IACjD,IAAI;QACF,OAAO,OAAO,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,CAAA;KAC7B;IAAC,OAAO,KAAc,EAAE;QACvB,IAAI,KAAK,YAAY,SAAS;YAAE,OAAO,KAAK,CAAA;QAC5C,MAAM,KAAK,CAAA;KACZ;AACH,CAAC,CAAA","sourcesContent":["/**\n * Check if the format of a URL is valid or not.\n *\n * @param url - URL to be checked.\n * @returns True if the URL is valid, false otherwise.\n */\nexport const isValidURL = (url: string): boolean => {\n try {\n return Boolean(new URL(url))\n } catch (error: unknown) {\n if (error instanceof TypeError) return false\n throw error\n }\n}\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AbortController as NodeAbortController, AbortSignal as NodeAbortControllerSignal } from 'node-abort-controller';
|
|
2
|
+
/**
|
|
3
|
+
* The AbortController interface represents a controller object that allows you to abort one or more Web requests as and when desired.
|
|
4
|
+
*
|
|
5
|
+
* - MDN Documentation: https://developer.mozilla.org/en-US/docs/Web/API/AbortController
|
|
6
|
+
*
|
|
7
|
+
* This class is necessary because AbortController support was added to Node 15 and the minimum
|
|
8
|
+
* version that we support is Node 14.
|
|
9
|
+
*/
|
|
10
|
+
export declare class AbortController extends NodeAbortController {
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The AbortSignal interface represents a signal object that allows you to communicate with a DOM request (such as a fetch request) and abort it if required via an AbortController object.
|
|
14
|
+
*/
|
|
15
|
+
export declare class AbortSignal extends NodeAbortControllerSignal {
|
|
16
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AbortController as NodeAbortController, AbortSignal as NodeAbortControllerSignal } from 'node-abort-controller';
|
|
2
|
+
/**
|
|
3
|
+
* The AbortController interface represents a controller object that allows you to abort one or more Web requests as and when desired.
|
|
4
|
+
*
|
|
5
|
+
* - MDN Documentation: https://developer.mozilla.org/en-US/docs/Web/API/AbortController
|
|
6
|
+
*
|
|
7
|
+
* This class is necessary because AbortController support was added to Node 15 and the minimum
|
|
8
|
+
* version that we support is Node 14.
|
|
9
|
+
*/
|
|
10
|
+
export class AbortController extends NodeAbortController {
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The AbortSignal interface represents a signal object that allows you to communicate with a DOM request (such as a fetch request) and abort it if required via an AbortController object.
|
|
14
|
+
*/
|
|
15
|
+
export class AbortSignal extends NodeAbortControllerSignal {
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=abort.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abort.js","sourceRoot":"","sources":["../../../src/public/node/abort.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,IAAI,mBAAmB,EAAE,WAAW,IAAI,yBAAyB,EAAC,MAAM,uBAAuB,CAAA;AAEtH;;;;;;;GAOG;AACH,MAAM,OAAO,eAAgB,SAAQ,mBAAmB;CAAG;AAE3D;;GAEG;AACH,MAAM,OAAO,WAAY,SAAQ,yBAAyB;CAAG","sourcesContent":["import {AbortController as NodeAbortController, AbortSignal as NodeAbortControllerSignal} from 'node-abort-controller'\n\n/**\n * The AbortController interface represents a controller object that allows you to abort one or more Web requests as and when desired.\n *\n * - MDN Documentation: https://developer.mozilla.org/en-US/docs/Web/API/AbortController\n *\n * This class is necessary because AbortController support was added to Node 15 and the minimum\n * version that we support is Node 14.\n */\nexport class AbortController extends NodeAbortController {}\n\n/**\n * The AbortSignal interface represents a signal object that allows you to communicate with a DOM request (such as a fetch request) and abort it if required via an AbortController object.\n */\nexport class AbortSignal extends NodeAbortControllerSignal {}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Interfaces } from '@oclif/core';
|
|
2
|
+
interface ReportAnalyticsEventOptions {
|
|
3
|
+
config: Interfaces.Config;
|
|
4
|
+
errorMessage?: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Report an analytics event, sending it off to Monorail -- Shopify's internal analytics service.
|
|
8
|
+
*
|
|
9
|
+
* The payload for an event includes both generic data, and data gathered from installed plug-ins.
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
export declare function reportAnalyticsEvent(options: ReportAnalyticsEventOptions): Promise<void>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { version as rubyVersion } from './ruby.js';
|
|
2
|
+
import * as environment from '../../environment.js';
|
|
3
|
+
import { content, debug, token } from '../../output.js';
|
|
4
|
+
import constants from '../../constants.js';
|
|
5
|
+
import * as metadata from '../../metadata.js';
|
|
6
|
+
import { publishEvent, MONORAIL_COMMAND_TOPIC } from '../../monorail.js';
|
|
7
|
+
import { fanoutHooks } from '../../plugins.js';
|
|
8
|
+
import { getEnvironmentData, getSensitiveEnvironmentData } from '../../private/node/analytics.js';
|
|
9
|
+
/**
|
|
10
|
+
* Report an analytics event, sending it off to Monorail -- Shopify's internal analytics service.
|
|
11
|
+
*
|
|
12
|
+
* The payload for an event includes both generic data, and data gathered from installed plug-ins.
|
|
13
|
+
*
|
|
14
|
+
*/
|
|
15
|
+
export async function reportAnalyticsEvent(options) {
|
|
16
|
+
try {
|
|
17
|
+
const payload = await buildPayload(options);
|
|
18
|
+
if (payload === undefined) {
|
|
19
|
+
// Nothing to log
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (!environment.local.alwaysLogAnalytics() && environment.local.analyticsDisabled()) {
|
|
23
|
+
debug(content `Skipping command analytics, payload: ${token.json(payload)}`);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const response = await publishEvent(MONORAIL_COMMAND_TOPIC, payload.public, payload.sensitive);
|
|
27
|
+
if (response.type === 'error') {
|
|
28
|
+
debug(response.message);
|
|
29
|
+
}
|
|
30
|
+
// eslint-disable-next-line no-catch-all/no-catch-all
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
let message = 'Failed to report usage analytics';
|
|
34
|
+
if (error instanceof Error) {
|
|
35
|
+
message = message.concat(`: ${error.message}`);
|
|
36
|
+
}
|
|
37
|
+
debug(message);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
async function buildPayload({ config, errorMessage }) {
|
|
41
|
+
const { commandStartOptions, ...sensitiveMetadata } = metadata.getAllSensitive();
|
|
42
|
+
if (commandStartOptions === undefined) {
|
|
43
|
+
debug('Unable to log analytics event - no information on executed command');
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const { startCommand, startArgs, startTime } = commandStartOptions;
|
|
47
|
+
const currentTime = new Date().getTime();
|
|
48
|
+
const { '@shopify/app': appPublic, ...otherPluginsPublic } = await fanoutHooks(config, 'public_command_metadata', {});
|
|
49
|
+
const { '@shopify/app': appSensitive, ...otherPluginsSensitive } = await fanoutHooks(config, 'sensitive_command_metadata', {});
|
|
50
|
+
const environmentData = await getEnvironmentData(config);
|
|
51
|
+
const sensitiveEnvironmentData = await getSensitiveEnvironmentData(config);
|
|
52
|
+
return {
|
|
53
|
+
public: {
|
|
54
|
+
command: startCommand,
|
|
55
|
+
time_start: startTime,
|
|
56
|
+
time_end: currentTime,
|
|
57
|
+
total_time: currentTime - startTime,
|
|
58
|
+
success: errorMessage === undefined,
|
|
59
|
+
cli_version: await constants.versions.cliKit(),
|
|
60
|
+
ruby_version: (await rubyVersion()) || '',
|
|
61
|
+
node_version: process.version.replace('v', ''),
|
|
62
|
+
is_employee: await environment.local.isShopify(),
|
|
63
|
+
...environmentData,
|
|
64
|
+
...appPublic,
|
|
65
|
+
...metadata.getAllPublic(),
|
|
66
|
+
},
|
|
67
|
+
sensitive: {
|
|
68
|
+
args: startArgs.join(' '),
|
|
69
|
+
error_message: errorMessage,
|
|
70
|
+
...appSensitive,
|
|
71
|
+
...sensitiveEnvironmentData,
|
|
72
|
+
metadata: JSON.stringify({
|
|
73
|
+
...sensitiveMetadata,
|
|
74
|
+
extraPublic: {
|
|
75
|
+
...otherPluginsPublic,
|
|
76
|
+
},
|
|
77
|
+
extraSensitive: { ...otherPluginsSensitive },
|
|
78
|
+
}),
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=analytics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analytics.js","sourceRoot":"","sources":["../../../src/public/node/analytics.ts"],"names":[],"mappings":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CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC;YAC9C,WAAW,EAAE,MAAM,WAAW,CAAC,KAAK,CAAC,SAAS,EAAE;YAChD,GAAG,eAAe;YAClB,GAAG,SAAS;YACZ,GAAG,QAAQ,CAAC,YAAY,EAAE;SAC3B;QACD,SAAS,EAAE;YACT,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC;YACzB,aAAa,EAAE,YAAY;YAC3B,GAAG,YAAY;YACf,GAAG,wBAAwB;YAC3B,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC;gBACvB,GAAG,iBAAiB;gBACpB,WAAW,EAAE;oBACX,GAAG,kBAAkB;iBACtB;gBACD,cAAc,EAAE,EAAC,GAAG,qBAAqB,EAAC;aAC3C,CAAC;SACH;KACF,CAAA;AACH,CAAC","sourcesContent":["import {version as rubyVersion} from './ruby.js'\nimport * as environment from '../../environment.js'\nimport {content, debug, token} from '../../output.js'\nimport constants from '../../constants.js'\nimport * as metadata from '../../metadata.js'\nimport {publishEvent, MONORAIL_COMMAND_TOPIC} from '../../monorail.js'\nimport {fanoutHooks} from '../../plugins.js'\nimport {getEnvironmentData, getSensitiveEnvironmentData} from '../../private/node/analytics.js'\nimport {Interfaces} from '@oclif/core'\n\ninterface ReportAnalyticsEventOptions {\n config: Interfaces.Config\n errorMessage?: string\n}\n\n/**\n * Report an analytics event, sending it off to Monorail -- Shopify's internal analytics service.\n *\n * The payload for an event includes both generic data, and data gathered from installed plug-ins.\n *\n */\nexport async function reportAnalyticsEvent(options: ReportAnalyticsEventOptions): Promise<void> {\n try {\n const payload = await buildPayload(options)\n if (payload === undefined) {\n // Nothing to log\n return\n }\n if (!environment.local.alwaysLogAnalytics() && environment.local.analyticsDisabled()) {\n debug(content`Skipping command analytics, payload: ${token.json(payload)}`)\n return\n }\n const response = await publishEvent(MONORAIL_COMMAND_TOPIC, payload.public, payload.sensitive)\n if (response.type === 'error') {\n debug(response.message)\n }\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (error) {\n let message = 'Failed to report usage analytics'\n if (error instanceof Error) {\n message = message.concat(`: ${error.message}`)\n }\n debug(message)\n }\n}\n\nasync function buildPayload({config, errorMessage}: ReportAnalyticsEventOptions) {\n const {commandStartOptions, ...sensitiveMetadata} = metadata.getAllSensitive()\n if (commandStartOptions === undefined) {\n debug('Unable to log analytics event - no information on executed command')\n return\n }\n const {startCommand, startArgs, startTime} = commandStartOptions\n const currentTime = new Date().getTime()\n\n const {'@shopify/app': appPublic, ...otherPluginsPublic} = await fanoutHooks(config, 'public_command_metadata', {})\n const {'@shopify/app': appSensitive, ...otherPluginsSensitive} = await fanoutHooks(\n config,\n 'sensitive_command_metadata',\n {},\n )\n\n const environmentData = await getEnvironmentData(config)\n const sensitiveEnvironmentData = await getSensitiveEnvironmentData(config)\n\n return {\n public: {\n command: startCommand,\n time_start: startTime,\n time_end: currentTime,\n total_time: currentTime - startTime,\n success: errorMessage === undefined,\n cli_version: await constants.versions.cliKit(),\n ruby_version: (await rubyVersion()) || '',\n node_version: process.version.replace('v', ''),\n is_employee: await environment.local.isShopify(),\n ...environmentData,\n ...appPublic,\n ...metadata.getAllPublic(),\n },\n sensitive: {\n args: startArgs.join(' '),\n error_message: errorMessage,\n ...appSensitive,\n ...sensitiveEnvironmentData,\n metadata: JSON.stringify({\n ...sensitiveMetadata,\n extraPublic: {\n ...otherPluginsPublic,\n },\n extraSensitive: {...otherPluginsSensitive},\n }),\n },\n }\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AdminSession } from '../../../session.js';
|
|
2
|
+
import { GraphQLVariables } from '../../../private/node/api/graphql.js';
|
|
3
|
+
/**
|
|
4
|
+
* Executes a GraphQL query against the Admin API.
|
|
5
|
+
*
|
|
6
|
+
* @param query - GraphQL query to execute.
|
|
7
|
+
* @param session - Shopify admin session including token and Store FQDN.
|
|
8
|
+
* @param variables - GraphQL variables to pass to the query.
|
|
9
|
+
* @returns The response of the query of generic type <T>.
|
|
10
|
+
*/
|
|
11
|
+
export declare function adminRequest<T>(query: string, session: AdminSession, variables?: GraphQLVariables): Promise<T>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { content, token as outputToken } from '../../../output.js';
|
|
2
|
+
import { Bug, Abort } from '../../../error.js';
|
|
3
|
+
import { graphqlRequest } from '../../../private/node/api/graphql.js';
|
|
4
|
+
import { ClientError, gql } from 'graphql-request';
|
|
5
|
+
/**
|
|
6
|
+
* Executes a GraphQL query against the Admin API.
|
|
7
|
+
*
|
|
8
|
+
* @param query - GraphQL query to execute.
|
|
9
|
+
* @param session - Shopify admin session including token and Store FQDN.
|
|
10
|
+
* @param variables - GraphQL variables to pass to the query.
|
|
11
|
+
* @returns The response of the query of generic type <T>.
|
|
12
|
+
*/
|
|
13
|
+
export async function adminRequest(query, session, variables) {
|
|
14
|
+
const api = 'Admin';
|
|
15
|
+
const version = await fetchApiVersion(session);
|
|
16
|
+
const url = adminUrl(session.storeFqdn, version);
|
|
17
|
+
return graphqlRequest(query, api, url, session.token, variables);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* GraphQL query to retrieve the latest supported API version.
|
|
21
|
+
*
|
|
22
|
+
* @param session - Shopify admin session including token and Store FQDN.
|
|
23
|
+
* @returns - The latest supported API version.
|
|
24
|
+
*/
|
|
25
|
+
async function fetchApiVersion(session) {
|
|
26
|
+
const url = adminUrl(session.storeFqdn, 'unstable');
|
|
27
|
+
const query = apiVersionQuery();
|
|
28
|
+
try {
|
|
29
|
+
const data = await graphqlRequest(query, 'Admin', url, session.token, {}, false);
|
|
30
|
+
return data.publicApiVersions
|
|
31
|
+
.filter((item) => item.supported)
|
|
32
|
+
.map((item) => item.handle)
|
|
33
|
+
.sort()
|
|
34
|
+
.reverse()[0];
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
if (error instanceof ClientError && error.response.status === 403) {
|
|
38
|
+
const storeName = session.storeFqdn.replace('.myshopify.com', '');
|
|
39
|
+
throw new Abort(content `Looks like you don't have access this dev store: (${outputToken.link(storeName, `https://${session.storeFqdn}`)})`, content `If you're not the owner, create a dev store staff account for yourself`);
|
|
40
|
+
}
|
|
41
|
+
throw new Bug(`Unknown error connecting to your store`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Returns the Admin API URL for the given store and version.
|
|
46
|
+
*
|
|
47
|
+
* @param store - Store FQDN.
|
|
48
|
+
* @param version - API version.
|
|
49
|
+
* @returns - Admin API URL.
|
|
50
|
+
*/
|
|
51
|
+
function adminUrl(store, version) {
|
|
52
|
+
const realVersion = version || 'unstable';
|
|
53
|
+
return `https://${store}/admin/api/${realVersion}/graphql.json`;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* GraphQL query string to retrieve the latest supported API version.
|
|
57
|
+
*
|
|
58
|
+
* @returns - A query string.
|
|
59
|
+
*/
|
|
60
|
+
function apiVersionQuery() {
|
|
61
|
+
return gql `
|
|
62
|
+
query {
|
|
63
|
+
publicApiVersions {
|
|
64
|
+
handle
|
|
65
|
+
supported
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
`;
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=admin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin.js","sourceRoot":"","sources":["../../../../src/public/node/api/admin.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,OAAO,EAAE,KAAK,IAAI,WAAW,EAAC,MAAM,oBAAoB,CAAA;AAChE,OAAO,EAAC,GAAG,EAAE,KAAK,EAAC,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EAAC,cAAc,EAAmB,MAAM,sCAAsC,CAAA;AACrF,OAAO,EAAC,WAAW,EAAE,GAAG,EAAC,MAAM,iBAAiB,CAAA;AAEhD;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAI,KAAa,EAAE,OAAqB,EAAE,SAA4B;IAC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AAM,IAAI,GAAG,CAAC,wCAAwC,CAAC,CAAA;KACxD;AACH,CAAC;AAED;;;;;;GAMG;AACH,SAAS,QAAQ,CAAC,KAAa,EAAE,OAA2B;IAC1D,MAAM,WAAW,GAAG,OAAO,IAAI,UAAU,CAAA;IACzC,OAAO,WAAW,KAAK,cAAc,WAAW,eAAe,CAAA;AACjE,CAAC;AAMD;;;;GAIG;AACH,SAAS,eAAe;IACtB,OAAO,GAAG,CAAA;;;;;;;GAOT,CAAA;AACH,CAAC","sourcesContent":["import {AdminSession} from '../../../session.js'\nimport {content, token as outputToken} from '../../../output.js'\nimport {Bug, Abort} from '../../../error.js'\nimport {graphqlRequest, GraphQLVariables} from '../../../private/node/api/graphql.js'\nimport {ClientError, gql} from 'graphql-request'\n\n/**\n * Executes a GraphQL query against the Admin API.\n *\n * @param query - GraphQL query to execute.\n * @param session - Shopify admin session including token and Store FQDN.\n * @param variables - GraphQL variables to pass to the query.\n * @returns The response of the query of generic type <T>.\n */\nexport async function adminRequest<T>(query: string, session: AdminSession, variables?: GraphQLVariables): Promise<T> {\n const api = 'Admin'\n const version = await fetchApiVersion(session)\n const url = adminUrl(session.storeFqdn, version)\n return graphqlRequest(query, api, url, session.token, variables)\n}\n\n/**\n * GraphQL query to retrieve the latest supported API version.\n *\n * @param session - Shopify admin session including token and Store FQDN.\n * @returns - The latest supported API version.\n */\nasync function fetchApiVersion(session: AdminSession): Promise<string> {\n const url = adminUrl(session.storeFqdn, 'unstable')\n const query = apiVersionQuery()\n try {\n const data: ApiVersionResponse = await graphqlRequest(query, 'Admin', url, session.token, {}, false)\n\n return data.publicApiVersions\n .filter((item) => item.supported)\n .map((item) => item.handle)\n .sort()\n .reverse()[0]!\n } catch (error) {\n if (error instanceof ClientError && error.response.status === 403) {\n const storeName = session.storeFqdn.replace('.myshopify.com', '')\n throw new Abort(\n content`Looks like you don't have access this dev store: (${outputToken.link(\n storeName,\n `https://${session.storeFqdn}`,\n )})`,\n content`If you're not the owner, create a dev store staff account for yourself`,\n )\n }\n throw new Bug(`Unknown error connecting to your store`)\n }\n}\n\n/**\n * Returns the Admin API URL for the given store and version.\n *\n * @param store - Store FQDN.\n * @param version - API version.\n * @returns - Admin API URL.\n */\nfunction adminUrl(store: string, version: string | undefined): string {\n const realVersion = version || 'unstable'\n return `https://${store}/admin/api/${realVersion}/graphql.json`\n}\n\ninterface ApiVersionResponse {\n publicApiVersions: {handle: string; supported: boolean}[]\n}\n\n/**\n * GraphQL query string to retrieve the latest supported API version.\n *\n * @returns - A query string.\n */\nfunction apiVersionQuery(): string {\n return gql`\n query {\n publicApiVersions {\n handle\n supported\n }\n }\n `\n}\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { GraphQLVariables } from '../../../private/node/api/graphql.js';
|
|
2
|
+
import FormData from 'form-data';
|
|
3
|
+
import { Response } from 'node-fetch';
|
|
4
|
+
/**
|
|
5
|
+
* Executes a GraphQL query against the Oxygen API.
|
|
6
|
+
*
|
|
7
|
+
* @param oxygenAddress - Oxygen address to query.
|
|
8
|
+
* @param query - GraphQL query to execute.
|
|
9
|
+
* @param token - Shopify access token.
|
|
10
|
+
* @param variables - GraphQL variables to pass to the query.
|
|
11
|
+
* @returns The response of the query of generic type <T>.
|
|
12
|
+
*/
|
|
13
|
+
export declare function oxygenRequest<T>(oxygenAddress: string, query: string, token: string, variables?: GraphQLVariables): Promise<T>;
|
|
14
|
+
/**
|
|
15
|
+
* Uploads a deployment file to the Oxygen API.
|
|
16
|
+
*
|
|
17
|
+
* @param oxygenAddress - Oxygen address to upload to.
|
|
18
|
+
* @param token - Shopify access token.
|
|
19
|
+
* @param data - FormData to upload.
|
|
20
|
+
* @returns The response of the query.
|
|
21
|
+
*/
|
|
22
|
+
export declare function uploadOxygenDeploymentFile(oxygenAddress: string, token: string, data: FormData): Promise<Response>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { shopifyFetch } from '../../../http.js';
|
|
2
|
+
import { graphqlRequest } from '../../../private/node/api/graphql.js';
|
|
3
|
+
import { buildHeaders } from '../../../private/node/api/headers.js';
|
|
4
|
+
/**
|
|
5
|
+
* Executes a GraphQL query against the Oxygen API.
|
|
6
|
+
*
|
|
7
|
+
* @param oxygenAddress - Oxygen address to query.
|
|
8
|
+
* @param query - GraphQL query to execute.
|
|
9
|
+
* @param token - Shopify access token.
|
|
10
|
+
* @param variables - GraphQL variables to pass to the query.
|
|
11
|
+
* @returns The response of the query of generic type <T>.
|
|
12
|
+
*/
|
|
13
|
+
export async function oxygenRequest(oxygenAddress, query, token, variables) {
|
|
14
|
+
return graphqlRequest(query, 'Oxygen', getOxygenAddress(oxygenAddress), token, variables);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Uploads a deployment file to the Oxygen API.
|
|
18
|
+
*
|
|
19
|
+
* @param oxygenAddress - Oxygen address to upload to.
|
|
20
|
+
* @param token - Shopify access token.
|
|
21
|
+
* @param data - FormData to upload.
|
|
22
|
+
* @returns The response of the query.
|
|
23
|
+
*/
|
|
24
|
+
export async function uploadOxygenDeploymentFile(oxygenAddress, token, data) {
|
|
25
|
+
const headers = await buildHeaders(token);
|
|
26
|
+
delete headers['Content-Type'];
|
|
27
|
+
const response = await shopifyFetch(getOxygenAddress(oxygenAddress), {
|
|
28
|
+
method: 'POST',
|
|
29
|
+
body: data,
|
|
30
|
+
headers: {
|
|
31
|
+
...headers,
|
|
32
|
+
...data.getHeaders(),
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
return response;
|
|
36
|
+
}
|
|
37
|
+
const getOxygenAddress = (oxygenHost) => {
|
|
38
|
+
return `https://${oxygenHost}/api/graphql/deploy/v1`;
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=oxygen.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oxygen.js","sourceRoot":"","sources":["../../../../src/public/node/api/oxygen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAC,cAAc,EAAmB,MAAM,sCAAsC,CAAA;AACrF,OAAO,EAAC,YAAY,EAAC,MAAM,sCAAsC,CAAA;AAIjE;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,aAAqB,EACrB,KAAa,EACb,KAAa,EACb,SAA4B;IAE5B,OAAO,cAAc,CAAC,KAAK,EAAE,QAAQ,EAAE,gBAAgB,CAAC,aAAa,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,CAAA;AAC3F,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,aAAqB,EACrB,KAAa,EACb,IAAc;IAEd,MAAM,OAAO,GAAG,MAAM,YAAY,CAAC,KAAK,CAAC,CAAA;IACzC,OAAO,OAAO,CAAC,cAAc,CAAC,CAAA;IAE9B,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,gBAAgB,CAAC,aAAa,CAAC,EAAE;QACnE,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,IAAI;QACV,OAAO,EAAE;YACP,GAAG,OAAO;YACV,GAAG,IAAI,CAAC,UAAU,EAAE;SACrB;KACF,CAAC,CAAA;IAEF,OAAO,QAAQ,CAAA;AACjB,CAAC;AAED,MAAM,gBAAgB,GAAG,CAAC,UAAkB,EAAU,EAAE;IACtD,OAAO,WAAW,UAAU,wBAAwB,CAAA;AACtD,CAAC,CAAA","sourcesContent":["import {shopifyFetch} from '../../../http.js'\nimport {graphqlRequest, GraphQLVariables} from '../../../private/node/api/graphql.js'\nimport {buildHeaders} from '../../../private/node/api/headers.js'\nimport FormData from 'form-data'\nimport {Response} from 'node-fetch'\n\n/**\n * Executes a GraphQL query against the Oxygen API.\n *\n * @param oxygenAddress - Oxygen address to query.\n * @param query - GraphQL query to execute.\n * @param token - Shopify access token.\n * @param variables - GraphQL variables to pass to the query.\n * @returns The response of the query of generic type <T>.\n */\nexport async function oxygenRequest<T>(\n oxygenAddress: string,\n query: string,\n token: string,\n variables?: GraphQLVariables,\n): Promise<T> {\n return graphqlRequest(query, 'Oxygen', getOxygenAddress(oxygenAddress), token, variables)\n}\n\n/**\n * Uploads a deployment file to the Oxygen API.\n *\n * @param oxygenAddress - Oxygen address to upload to.\n * @param token - Shopify access token.\n * @param data - FormData to upload.\n * @returns The response of the query.\n */\nexport async function uploadOxygenDeploymentFile(\n oxygenAddress: string,\n token: string,\n data: FormData,\n): Promise<Response> {\n const headers = await buildHeaders(token)\n delete headers['Content-Type']\n\n const response = await shopifyFetch(getOxygenAddress(oxygenAddress), {\n method: 'POST',\n body: data,\n headers: {\n ...headers,\n ...data.getHeaders(),\n },\n })\n\n return response\n}\n\nconst getOxygenAddress = (oxygenHost: string): string => {\n return `https://${oxygenHost}/api/graphql/deploy/v1`\n}\n"]}
|
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { GraphQLVariables } from '../../../private/node/api/graphql.js';
|
|
2
|
+
/**
|
|
3
|
+
* Executes a GraphQL query against the Partners API.
|
|
4
|
+
*
|
|
5
|
+
* @param query - GraphQL query to execute.
|
|
6
|
+
* @param token - Partners token.
|
|
7
|
+
* @param variables - GraphQL variables to pass to the query.
|
|
8
|
+
* @returns The response of the query of generic type <T>.
|
|
9
|
+
*/
|
|
10
|
+
export declare function partnersRequest<T>(query: string, token: string, variables?: GraphQLVariables): Promise<T>;
|
|
3
11
|
/**
|
|
4
12
|
* Function queries are proxied through the script service proxy.
|
|
5
13
|
* To execute a query, we encapsulate it inside another query (including the variables)
|
|
@@ -7,7 +15,7 @@ export declare function request<T>(query: RequestDocument, token: string, variab
|
|
|
7
15
|
*
|
|
8
16
|
* @param apiKey - APIKey of the app where the query will be executed.
|
|
9
17
|
* @param query - GraphQL query to execute.
|
|
10
|
-
* @param token - Partners token
|
|
18
|
+
* @param token - Partners token.
|
|
11
19
|
* @param variables - GraphQL variables to pass to the query.
|
|
12
20
|
* @returns The response of the query.
|
|
13
21
|
*/
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { partners as partnersFqdn } from '../../../environment/fqdn.js';
|
|
2
|
+
import { graphqlRequest } from '../../../private/node/api/graphql.js';
|
|
3
|
+
import { ScriptServiceProxyQuery } from '../../../api/graphql/index.js';
|
|
4
|
+
/**
|
|
5
|
+
* Executes a GraphQL query against the Partners API.
|
|
6
|
+
*
|
|
7
|
+
* @param query - GraphQL query to execute.
|
|
8
|
+
* @param token - Partners token.
|
|
9
|
+
* @param variables - GraphQL variables to pass to the query.
|
|
10
|
+
* @returns The response of the query of generic type <T>.
|
|
11
|
+
*/
|
|
12
|
+
export async function partnersRequest(query, token, variables) {
|
|
13
|
+
const api = 'Partners';
|
|
14
|
+
const fqdn = await partnersFqdn();
|
|
15
|
+
const url = `https://${fqdn}/api/cli/graphql`;
|
|
16
|
+
return graphqlRequest(query, api, url, token, variables);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Function queries are proxied through the script service proxy.
|
|
20
|
+
* To execute a query, we encapsulate it inside another query (including the variables)
|
|
21
|
+
* This is done automatically, you just need to provide the query and the variables.
|
|
22
|
+
*
|
|
23
|
+
* @param apiKey - APIKey of the app where the query will be executed.
|
|
24
|
+
* @param query - GraphQL query to execute.
|
|
25
|
+
* @param token - Partners token.
|
|
26
|
+
* @param variables - GraphQL variables to pass to the query.
|
|
27
|
+
* @returns The response of the query.
|
|
28
|
+
*/
|
|
29
|
+
export async function functionProxyRequest(apiKey, query, token, variables) {
|
|
30
|
+
const proxyVariables = {
|
|
31
|
+
api_key: apiKey,
|
|
32
|
+
query,
|
|
33
|
+
variables: JSON.stringify(variables) || '{}',
|
|
34
|
+
};
|
|
35
|
+
const proxyQuery = ScriptServiceProxyQuery;
|
|
36
|
+
const res = await partnersRequest(proxyQuery, token, proxyVariables);
|
|
37
|
+
const json = JSON.parse(res.scriptServiceProxy);
|
|
38
|
+
return json;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=partners.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"partners.js","sourceRoot":"","sources":["../../../../src/public/node/api/partners.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,IAAI,YAAY,EAAC,MAAM,8BAA8B,CAAA;AACrE,OAAO,EAAC,cAAc,EAAmB,MAAM,sCAAsC,CAAA;AACrF,OAAO,EAAC,uBAAuB,EAAC,MAAM,+BAA+B,CAAA;AAErE;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAI,KAAa,EAAE,KAAa,EAAE,SAA4B;IACjG,MAAM,GAAG,GAAG,UAAU,CAAA;IACtB,MAAM,IAAI,GAAG,MAAM,YAAY,EAAE,CAAA;IACjC,MAAM,GAAG,GAAG,WAAW,IAAI,kBAAkB,CAAA;IAC7C,OAAO,cAAc,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,CAAC,CAAA;AAC1D,CAAC;AAMD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,MAAc,EACd,KAAc,EACd,KAAa,EACb,SAAmB;IAEnB,MAAM,cAAc,GAAG;QACrB,OAAO,EAAE,MAAM;QACf,KAAK;QACL,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,IAAI;KAC7C,CAAA;IACD,MAAM,UAAU,GAAG,uBAAuB,CAAA;IAC1C,MAAM,GAAG,GAAkB,MAAM,eAAe,CAAC,UAAU,EAAE,KAAK,EAAE,cAAc,CAAC,CAAA;IACnF,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAA;IAC/C,OAAO,IAAS,CAAA;AAClB,CAAC","sourcesContent":["import {partners as partnersFqdn} from '../../../environment/fqdn.js'\nimport {graphqlRequest, GraphQLVariables} from '../../../private/node/api/graphql.js'\nimport {ScriptServiceProxyQuery} from '../../../api/graphql/index.js'\n\n/**\n * Executes a GraphQL query against the Partners API.\n *\n * @param query - GraphQL query to execute.\n * @param token - Partners token.\n * @param variables - GraphQL variables to pass to the query.\n * @returns The response of the query of generic type <T>.\n */\nexport async function partnersRequest<T>(query: string, token: string, variables?: GraphQLVariables): Promise<T> {\n const api = 'Partners'\n const fqdn = await partnersFqdn()\n const url = `https://${fqdn}/api/cli/graphql`\n return graphqlRequest(query, api, url, token, variables)\n}\n\ninterface ProxyResponse {\n scriptServiceProxy: string\n}\n\n/**\n * Function queries are proxied through the script service proxy.\n * To execute a query, we encapsulate it inside another query (including the variables)\n * This is done automatically, you just need to provide the query and the variables.\n *\n * @param apiKey - APIKey of the app where the query will be executed.\n * @param query - GraphQL query to execute.\n * @param token - Partners token.\n * @param variables - GraphQL variables to pass to the query.\n * @returns The response of the query.\n */\nexport async function functionProxyRequest<T>(\n apiKey: string,\n query: unknown,\n token: string,\n variables?: unknown,\n): Promise<T> {\n const proxyVariables = {\n api_key: apiKey,\n query,\n variables: JSON.stringify(variables) || '{}',\n }\n const proxyQuery = ScriptServiceProxyQuery\n const res: ProxyResponse = await partnersRequest(proxyQuery, token, proxyVariables)\n const json = JSON.parse(res.scriptServiceProxy)\n return json as T\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { debug, content, token } from '../../output.js';
|
|
2
2
|
import { glob, relative as relativePath } from '../../path.js';
|
|
3
3
|
import archiver from 'archiver';
|
|
4
|
-
import { createWriteStream } from '
|
|
4
|
+
import { createWriteStream } from 'fs';
|
|
5
5
|
/**
|
|
6
6
|
* It zips a directory normalizing the paths to be forward-slash. Note that unzipping
|
|
7
7
|
* the zip generated by this function from a Windows environment won't work because paths
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"archiver.js","sourceRoot":"","sources":["../../../src/public/node/archiver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAC,MAAM,iBAAiB,CAAA;A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AAA;QACF,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QAEpB,KAAK,MAAM,QAAQ,IAAI,UAAU,EAAE;YACjC,MAAM,gBAAgB,GAAG,YAAY,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAA;YAC/D,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAC,IAAI,EAAE,gBAAgB,EAAC,CAAC,CAAA;SACjD;QAED,mEAAmE;QACnE,OAAO,CAAC,QAAQ,EAAE,CAAA;IACpB,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import {debug, content, token} from '../../output.js'\nimport {glob, relative as relativePath} from '../../path.js'\nimport archiver from 'archiver'\nimport {createWriteStream} from 'fs'\n/**\n * It zips a directory normalizing the paths to be forward-slash. Note that unzipping\n * the zip generated by this function from a Windows environment won't work because paths\n * need to be made backward-slash.\n *\n * @param inputDirectory - The absolute path to the directory to be zipped.\n * @param outputZipPath - The absolute path to the output zip file.\n */\nexport async function zip(inputDirectory: string, outputZipPath: string): Promise<void> {\n debug(content`Zipping ${token.path(inputDirectory)} into ${token.path(outputZipPath)}`)\n const pathsToZip = await glob('**/*', {cwd: inputDirectory, absolute: true, dot: true, followSymbolicLinks: false})\n return new Promise((resolve, reject) => {\n const archive = archiver('zip')\n const output = createWriteStream(outputZipPath)\n\n output.on('close', function () {\n resolve()\n })\n archive.on('error', function (error) {\n reject(error)\n })\n archive.pipe(output)\n\n for (const filePath of pathsToZip) {\n const fileRelativePath = relativePath(inputDirectory, filePath)\n archive.file(filePath, {name: fileRelativePath})\n }\n\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n archive.finalize()\n })\n}\n"]}
|
|
@@ -4,7 +4,7 @@ import { isDevelopment } from '../../environment/local.js';
|
|
|
4
4
|
import { Abort } from '../../error.js';
|
|
5
5
|
import { addPublic } from '../../metadata.js';
|
|
6
6
|
import { content, info, token } from '../../output.js';
|
|
7
|
-
import { hashString } from '../../
|
|
7
|
+
import { hashString } from '../../public/node/crypto.js';
|
|
8
8
|
import { isTruthy } from '../../environment/utilities.js';
|
|
9
9
|
import { Command } from '@oclif/core';
|
|
10
10
|
class BaseCommand extends Command {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-command.js","sourceRoot":"","sources":["../../../src/public/node/base-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,2CAA2C,EAAC,MAAM,oBAAoB,CAAA;AAC5F,OAAO,EAAC,wBAAwB,EAAC,MAAM,cAAc,CAAA;AAErD,OAAO,EAAC,aAAa,EAAC,MAAM,4BAA4B,CAAA;AACxD,OAAO,EAAC,KAAK,EAAC,MAAM,gBAAgB,CAAA;AACpC,OAAO,EAAC,SAAS,EAAC,MAAM,mBAAmB,CAAA;AAC3C,OAAO,EAAC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAC,MAAM,iBAAiB,CAAA;AACpD,OAAO,EAAC,UAAU,EAAC,MAAM,iBAAiB,CAAA;AAC1C,OAAO,EAAC,QAAQ,EAAC,MAAM,gCAAgC,CAAA;AACvD,OAAO,EAAC,OAAO,EAAa,MAAM,aAAa,CAAA;AAO/C,MAAe,WAAY,SAAQ,OAAO;IACjC,MAAM,CAAC,qBAAqB;QACjC,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,KAA8C;QACxD,MAAM,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;IACxC,CAAC;IAED,8DAA8D;IACpD,KAAK,CAAC,IAAI;QAClB,IAAI,CAAC,uCAAuC,EAAE,CAAA;QAC9C,IAAI,CAAC,aAAa,EAAE,EAAE;YACpB,yCAAyC;YACzC,MAAM,2CAA2C,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;SAC/D;QACD,OAAO,KAAK,CAAC,IAAI,EAAE,CAAA;IACrB,CAAC;IAED,6EAA6E;IACnE,uCAAuC;QAC/C,IAAI,QAAQ,CAAC,OAAO,CAAC,GAAG,CA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AO,EAAE,KAAK,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;QAC5G,MAAM,qBAAqB,GACzB,gBAAgB,CAAC,KAAK,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;QAC/F,IAAI,uBAAuB,IAAI,CAAC,qBAAqB,EAAE;YACrD,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE;gBAC9B,IAAI,KAAK,KAAK,IAAI,EAAE;oBAClB,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,EAAE,CAAC,CAAA;iBACxB;qBAAM;oBACL,MAAM,IAAI,KAAK,CACb,OAAO,CAAA,qEAAqE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,CAC5G,CAAA;iBACF;aACF;iBAAM,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;gBAC/B,KAAK,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,EAAE,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC,CAAA;aAClE;iBAAM;gBACL,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,EAAE,EAAE,GAAG,KAAK,EAAE,CAAC,CAAA;aACpC;SACF;KACF;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AAED,eAAe,WAAW,CAAA","sourcesContent":["import {errorHandler, registerCleanBugsnagErrorsFromWithinPlugins} from './error-handler.js'\nimport {loadPresetsFromDirectory} from './presets.js'\nimport {JsonMap} from '../../json.js'\nimport {isDevelopment} from '../../environment/local.js'\nimport {Abort} from '../../error.js'\nimport {addPublic} from '../../metadata.js'\nimport {content, info, token} from '../../output.js'\nimport {hashString} from '../../string.js'\nimport {isTruthy} from '../../environment/utilities.js'\nimport {Command, Interfaces} from '@oclif/core'\n\ninterface PresettableFlags {\n preset?: string\n path?: string\n}\n\nabstract class BaseCommand extends Command {\n public static analyticsNameOverride(): string | undefined {\n return undefined\n }\n\n async catch(error: Error & {exitCode?: number | undefined}): Promise<void> {\n await errorHandler(error, this.config)\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n protected async init(): Promise<any> {\n this.exitWithTimestampWhenEnvVariablePresent()\n if (!isDevelopment()) {\n // This function runs just prior to `run`\n await registerCleanBugsnagErrorsFromWithinPlugins(this.config)\n }\n return super.init()\n }\n\n // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n protected exitWithTimestampWhenEnvVariablePresent() {\n if (isTruthy(process.env.SHOPIFY_CLI_ENV_STARTUP_PERFORMANCE_RUN)) {\n info(`\n SHOPIFY_CLI_TIMESTAMP_START\n { \"timestamp\": ${Date.now()} }\n SHOPIFY_CLI_TIMESTAMP_END\n `)\n process.exit(0)\n }\n }\n\n protected async parse<\n TFlags extends Interfaces.FlagOutput & {path?: string; verbose?: boolean},\n TGlobalFlags extends Interfaces.FlagOutput,\n TArgs extends Interfaces.OutputArgs,\n >(\n options?: Interfaces.Input<TFlags, TGlobalFlags>,\n argv?: string[],\n ): Promise<Interfaces.ParserOutput<TFlags, TGlobalFlags, TArgs>> {\n let result = await super.parse<TFlags, TGlobalFlags, TArgs>(options, argv)\n result = await this.resultWithPreset<TFlags, TGlobalFlags, TArgs>(result, options, argv)\n await addFromParsedFlags(result.flags)\n return result\n }\n\n protected async resultWithPreset<\n TFlags extends Interfaces.FlagOutput & {path?: string; verbose?: boolean},\n TGlobalFlags extends Interfaces.FlagOutput,\n TArgs extends Interfaces.OutputArgs,\n >(\n originalResult: Interfaces.ParserOutput<TFlags, TGlobalFlags, TArgs>,\n options?: Interfaces.Input<TFlags, TGlobalFlags>,\n argv?: string[],\n ): Promise<Interfaces.ParserOutput<TFlags, TGlobalFlags, TArgs>> {\n // If no preset is specified, don't modify the results\n const flags = originalResult.flags as PresettableFlags\n if (!flags.preset) return originalResult\n\n // If the specified preset isn't found, don't modify the results\n const presets = await loadPresetsFromDirectory(await this.presetsPath(flags), {findUp: this.findUpForPresets()})\n const preset = presets[flags.preset]\n if (!preset) return originalResult\n\n // Parse using noDefaultsOptions to derive a list of flags specified as\n // command-line arguments.\n const noDefaultsResult = await super.parse<TFlags, TGlobalFlags, TArgs>(noDefaultsOptions(options), argv)\n\n // Add the preset's settings to argv and pass them to `super.parse`. This\n // invokes oclif's validation system without breaking the oclif black box.\n // Replace the original result with this one.\n const result = await super.parse<TFlags, TGlobalFlags, TArgs>(options, [\n // Need to specify argv default because we're merging with argsFromPreset.\n ...(argv || this.argv),\n ...argsFromPreset<TFlags, TGlobalFlags, TArgs>(preset, options, noDefaultsResult),\n ])\n\n // Report successful application of the preset.\n reportPresetApplication<TFlags, TGlobalFlags, TArgs>(noDefaultsResult.flags, result.flags, flags.preset, preset)\n\n return result\n }\n\n protected async presetsPath(rawFlags: {path?: string}): Promise<string> {\n return rawFlags.path || process.cwd()\n }\n\n protected findUpForPresets(): boolean {\n return true\n }\n}\n\nexport async function addFromParsedFlags(flags: {path?: string; verbose?: boolean}): Promise<void> {\n await addPublic(() => ({\n cmd_all_verbose: flags.verbose,\n cmd_all_path_override: flags.path !== undefined,\n cmd_all_path_override_hash: flags.path === undefined ? undefined : hashString(flags.path),\n }))\n}\n\n/**\n * Any flag which is:\n *\n * 1. Present in the final set of flags\n * 2. Specified in the preset\n * 3. Not specified by the user as a command line argument\n *\n * should be reported.\n *\n * It doesn't matter if the preset flag's value was the same as the default; from\n * the user's perspective, they want to know their preset was applied.\n */\nfunction reportPresetApplication<\n TFlags extends Interfaces.FlagOutput,\n TGlobalFlags extends Interfaces.FlagOutput,\n TArgs extends Interfaces.OutputArgs,\n>(\n noDefaultsFlags: Interfaces.ParserOutput<TFlags, TGlobalFlags, TArgs>['flags'],\n flagsWithPresets: Interfaces.ParserOutput<TFlags, TGlobalFlags, TArgs>['flags'],\n presetName: string,\n preset: JsonMap,\n): void {\n const changes: JsonMap = {}\n for (const [name, value] of Object.entries(flagsWithPresets)) {\n const userSpecifiedThisFlag = Object.prototype.hasOwnProperty.call(noDefaultsFlags, name)\n const presetContainsFlag = Object.prototype.hasOwnProperty.call(preset, name)\n if (!userSpecifiedThisFlag && presetContainsFlag) changes[name] = value\n }\n if (Object.keys(changes).length === 0) return\n info(content`Using applicable flags from the preset ${token.yellow(presetName)}:\n\n${Object.entries(changes)\n .map(([name, value]) => `• ${name} = ${value}`)\n .join('\\n')}\\n`)\n}\n\n/**\n * Strips the defaults from configured flags. For example, if flags contains:\n *\n * ```\n * someFlag: Flags.boolean({\n * description: 'some flag',\n * default: false\n * })\n * ```\n *\n * it becomes:\n *\n * ```\n * someFlag: Flags.boolean({\n * description: 'some flag'\n * })\n * ```\n *\n * If we parse using this configuration, the only specified flags will be those\n * the user actually passed on the command line.\n */\n\nfunction noDefaultsOptions<TFlags extends Interfaces.FlagOutput, TGlobalFlags extends Interfaces.FlagOutput>(\n options: Interfaces.Input<TFlags, TGlobalFlags> | undefined,\n): Interfaces.Input<TFlags, TGlobalFlags> | undefined {\n if (!options?.flags) return options\n return {\n ...options,\n flags: Object.fromEntries(\n Object.entries(options.flags).map(([label, settings]) => {\n const copiedSettings = {...(settings as {default?: unknown})}\n delete copiedSettings.default\n return [label, copiedSettings]\n }),\n ) as Interfaces.FlagInput<TFlags>,\n }\n}\n\n/**\n * Converts the preset's settings to arguments as though passed on the command\n * line, skipping any arguments the user specified on the command line.\n */\nfunction argsFromPreset<\n TFlags extends Interfaces.FlagOutput,\n TGlobalFlags extends Interfaces.FlagOutput,\n TArgs extends Interfaces.OutputArgs,\n>(\n preset: JsonMap,\n options: Interfaces.Input<TFlags, TGlobalFlags> | undefined,\n noDefaultsResult: Interfaces.ParserOutput<TFlags, TArgs>,\n): string[] {\n const args: string[] = []\n for (const [label, value] of Object.entries(preset)) {\n const flagIsRelevantToCommand = options?.flags && Object.prototype.hasOwnProperty.call(options.flags, label)\n const userSpecifiedThisFlag =\n noDefaultsResult.flags && Object.prototype.hasOwnProperty.call(noDefaultsResult.flags, label)\n if (flagIsRelevantToCommand && !userSpecifiedThisFlag) {\n if (typeof value === 'boolean') {\n if (value === true) {\n args.push(`--${label}`)\n } else {\n throw new Abort(\n content`Presets can only specify true for boolean flags. Attempted to set ${token.yellow(label)} to false.`,\n )\n }\n } else if (Array.isArray(value)) {\n value.forEach((element) => args.push(`--${label}`, `${element}`))\n } else {\n args.push(`--${label}`, `${value}`)\n }\n }\n }\n return args\n}\n\nexport default BaseCommand\n"]}
|
|
1
|
+
{"version":3,"file":"base-command.js","sourceRoot":"","sources":["../../../src/public/node/base-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,2CAA2C,EAAC,MAAM,oBAAoB,CAAA;AAC5F,OAAO,EAAC,wBAAwB,EAAC,MAAM,cAAc,CAAA;AAErD,OAAO,EAAC,aAAa,EAAC,MAAM,4BAA4B,CAAA;AACxD,OAAO,EAAC,KAAK,EAAC,MAAM,gBAAgB,CAAA;AACpC,OAAO,EAAC,SAAS,EAAC,MAAM,mBAAmB,CAAA;AAC3C,OAAO,EAAC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAC,MAAM,iBAAiB,CAAA;AACpD,OAAO,EAAC,UAAU,EAAC,MAAM,6BAA6B,CAAA;AACtD,OAAO,EAAC,QAAQ,EAAC,MAAM,gCAAgC,CAAA;AACvD,OAAO,EAAC,OAAO,EAAa,MAAM,aAAa,CAAA;AAO/C,MAAe,WAAY,SAAQ,OAAO;IACjC,MAAM,CAAC,qBAAqB;QACjC,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,KAA8C;QACxD,MAAM,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;IACxC,CAAC;IAED,8DAA8D;IACpD,KAAK,CAAC,IAAI;QAClB,IAAI,CAAC,uCAAuC,EAAE,CAAA;QAC9C,IAAI,CAAC,a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nimport {loadPresetsFromDirectory} from './presets.js'\nimport {JsonMap} from '../../private/common/json.js'\nimport {isDevelopment} from '../../environment/local.js'\nimport {Abort} from '../../error.js'\nimport {addPublic} from '../../metadata.js'\nimport {content, info, token} from '../../output.js'\nimport {hashString} from '../../public/node/crypto.js'\nimport {isTruthy} from '../../environment/utilities.js'\nimport {Command, Interfaces} from '@oclif/core'\n\ninterface PresettableFlags {\n preset?: string\n path?: string\n}\n\nabstract class BaseCommand extends Command {\n public static analyticsNameOverride(): string | undefined {\n return undefined\n }\n\n async catch(error: Error & {exitCode?: number | undefined}): Promise<void> {\n await errorHandler(error, this.config)\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n protected async init(): Promise<any> {\n this.exitWithTimestampWhenEnvVariablePresent()\n if (!isDevelopment()) {\n // This function runs just prior to `run`\n await registerCleanBugsnagErrorsFromWithinPlugins(this.config)\n }\n return super.init()\n }\n\n // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n protected exitWithTimestampWhenEnvVariablePresent() {\n if (isTruthy(process.env.SHOPIFY_CLI_ENV_STARTUP_PERFORMANCE_RUN)) {\n info(`\n SHOPIFY_CLI_TIMESTAMP_START\n { \"timestamp\": ${Date.now()} }\n SHOPIFY_CLI_TIMESTAMP_END\n `)\n process.exit(0)\n }\n }\n\n protected async parse<\n TFlags extends Interfaces.FlagOutput & {path?: string; verbose?: boolean},\n TGlobalFlags extends Interfaces.FlagOutput,\n TArgs extends Interfaces.OutputArgs,\n >(\n options?: Interfaces.Input<TFlags, TGlobalFlags>,\n argv?: string[],\n ): Promise<Interfaces.ParserOutput<TFlags, TGlobalFlags, TArgs>> {\n let result = await super.parse<TFlags, TGlobalFlags, TArgs>(options, argv)\n result = await this.resultWithPreset<TFlags, TGlobalFlags, TArgs>(result, options, argv)\n await addFromParsedFlags(result.flags)\n return result\n }\n\n protected async resultWithPreset<\n TFlags extends Interfaces.FlagOutput & {path?: string; verbose?: boolean},\n TGlobalFlags extends Interfaces.FlagOutput,\n TArgs extends Interfaces.OutputArgs,\n >(\n originalResult: Interfaces.ParserOutput<TFlags, TGlobalFlags, TArgs>,\n options?: Interfaces.Input<TFlags, TGlobalFlags>,\n argv?: string[],\n ): Promise<Interfaces.ParserOutput<TFlags, TGlobalFlags, TArgs>> {\n // If no preset is specified, don't modify the results\n const flags = originalResult.flags as PresettableFlags\n if (!flags.preset) return originalResult\n\n // If the specified preset isn't found, don't modify the results\n const presets = await loadPresetsFromDirectory(await this.presetsPath(flags), {findUp: this.findUpForPresets()})\n const preset = presets[flags.preset]\n if (!preset) return originalResult\n\n // Parse using noDefaultsOptions to derive a list of flags specified as\n // command-line arguments.\n const noDefaultsResult = await super.parse<TFlags, TGlobalFlags, TArgs>(noDefaultsOptions(options), argv)\n\n // Add the preset's settings to argv and pass them to `super.parse`. This\n // invokes oclif's validation system without breaking the oclif black box.\n // Replace the original result with this one.\n const result = await super.parse<TFlags, TGlobalFlags, TArgs>(options, [\n // Need to specify argv default because we're merging with argsFromPreset.\n ...(argv || this.argv),\n ...argsFromPreset<TFlags, TGlobalFlags, TArgs>(preset, options, noDefaultsResult),\n ])\n\n // Report successful application of the preset.\n reportPresetApplication<TFlags, TGlobalFlags, TArgs>(noDefaultsResult.flags, result.flags, flags.preset, preset)\n\n return result\n }\n\n protected async presetsPath(rawFlags: {path?: string}): Promise<string> {\n return rawFlags.path || process.cwd()\n }\n\n protected findUpForPresets(): boolean {\n return true\n }\n}\n\nexport async function addFromParsedFlags(flags: {path?: string; verbose?: boolean}): Promise<void> {\n await addPublic(() => ({\n cmd_all_verbose: flags.verbose,\n cmd_all_path_override: flags.path !== undefined,\n cmd_all_path_override_hash: flags.path === undefined ? undefined : hashString(flags.path),\n }))\n}\n\n/**\n * Any flag which is:\n *\n * 1. Present in the final set of flags\n * 2. Specified in the preset\n * 3. Not specified by the user as a command line argument\n *\n * should be reported.\n *\n * It doesn't matter if the preset flag's value was the same as the default; from\n * the user's perspective, they want to know their preset was applied.\n */\nfunction reportPresetApplication<\n TFlags extends Interfaces.FlagOutput,\n TGlobalFlags extends Interfaces.FlagOutput,\n TArgs extends Interfaces.OutputArgs,\n>(\n noDefaultsFlags: Interfaces.ParserOutput<TFlags, TGlobalFlags, TArgs>['flags'],\n flagsWithPresets: Interfaces.ParserOutput<TFlags, TGlobalFlags, TArgs>['flags'],\n presetName: string,\n preset: JsonMap,\n): void {\n const changes: JsonMap = {}\n for (const [name, value] of Object.entries(flagsWithPresets)) {\n const userSpecifiedThisFlag = Object.prototype.hasOwnProperty.call(noDefaultsFlags, name)\n const presetContainsFlag = Object.prototype.hasOwnProperty.call(preset, name)\n if (!userSpecifiedThisFlag && presetContainsFlag) changes[name] = value\n }\n if (Object.keys(changes).length === 0) return\n info(content`Using applicable flags from the preset ${token.yellow(presetName)}:\n\n${Object.entries(changes)\n .map(([name, value]) => `• ${name} = ${value}`)\n .join('\\n')}\\n`)\n}\n\n/**\n * Strips the defaults from configured flags. For example, if flags contains:\n *\n * ```\n * someFlag: Flags.boolean({\n * description: 'some flag',\n * default: false\n * })\n * ```\n *\n * it becomes:\n *\n * ```\n * someFlag: Flags.boolean({\n * description: 'some flag'\n * })\n * ```\n *\n * If we parse using this configuration, the only specified flags will be those\n * the user actually passed on the command line.\n */\nfunction noDefaultsOptions<TFlags extends Interfaces.FlagOutput, TGlobalFlags extends Interfaces.FlagOutput>(\n options: Interfaces.Input<TFlags, TGlobalFlags> | undefined,\n): Interfaces.Input<TFlags, TGlobalFlags> | undefined {\n if (!options?.flags) return options\n return {\n ...options,\n flags: Object.fromEntries(\n Object.entries(options.flags).map(([label, settings]) => {\n const copiedSettings = {...(settings as {default?: unknown})}\n delete copiedSettings.default\n return [label, copiedSettings]\n }),\n ) as Interfaces.FlagInput<TFlags>,\n }\n}\n\n/**\n * Converts the preset's settings to arguments as though passed on the command\n * line, skipping any arguments the user specified on the command line.\n */\nfunction argsFromPreset<\n TFlags extends Interfaces.FlagOutput,\n TGlobalFlags extends Interfaces.FlagOutput,\n TArgs extends Interfaces.OutputArgs,\n>(\n preset: JsonMap,\n options: Interfaces.Input<TFlags, TGlobalFlags> | undefined,\n noDefaultsResult: Interfaces.ParserOutput<TFlags, TArgs>,\n): string[] {\n const args: string[] = []\n for (const [label, value] of Object.entries(preset)) {\n const flagIsRelevantToCommand = options?.flags && Object.prototype.hasOwnProperty.call(options.flags, label)\n const userSpecifiedThisFlag =\n noDefaultsResult.flags && Object.prototype.hasOwnProperty.call(noDefaultsResult.flags, label)\n if (flagIsRelevantToCommand && !userSpecifiedThisFlag) {\n if (typeof value === 'boolean') {\n if (value === true) {\n args.push(`--${label}`)\n } else {\n throw new Abort(\n content`Presets can only specify true for boolean flags. Attempted to set ${token.yellow(label)} to false.`,\n )\n }\n } else if (Array.isArray(value)) {\n value.forEach((element) => args.push(`--${label}`, `${element}`))\n } else {\n args.push(`--${label}`, `${value}`)\n }\n }\n }\n return args\n}\n\nexport default BaseCommand\n"]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/**
|
|
3
|
+
* Generate a random string in Hex format of the provided size.
|
|
4
|
+
*
|
|
5
|
+
* @param size - Number of bytes to be generated.
|
|
6
|
+
* @returns A random string in Hex format.
|
|
7
|
+
*/
|
|
8
|
+
export declare function randomHex(size: number): string;
|
|
9
|
+
/**
|
|
10
|
+
* Encode a string in Base64 valid for URLs.
|
|
11
|
+
*
|
|
12
|
+
* @param str - The string to encode.
|
|
13
|
+
* @returns The encoded string.
|
|
14
|
+
*/
|
|
15
|
+
export declare function base64URLEncode(str: Buffer): string;
|
|
16
|
+
/**
|
|
17
|
+
* Generate the SHA256 hash of a string.
|
|
18
|
+
*
|
|
19
|
+
* @param str - The string to hash.
|
|
20
|
+
* @returns The SHA256 hash of the string.
|
|
21
|
+
*/
|
|
22
|
+
export declare function sha256(str: string): Buffer;
|
|
23
|
+
/**
|
|
24
|
+
* Generate the SHA1 hash of a string.
|
|
25
|
+
*
|
|
26
|
+
* @param str - The string to hash.
|
|
27
|
+
* @returns The SHA1 hash of the string.
|
|
28
|
+
*/
|
|
29
|
+
export declare function hashString(str: string): string;
|
|
30
|
+
/**
|
|
31
|
+
* Generate random data of the provided size.
|
|
32
|
+
*
|
|
33
|
+
* @param size - Number of bytes to be generated.
|
|
34
|
+
* @returns A buffer of random data.
|
|
35
|
+
*/
|
|
36
|
+
export declare function randomBytes(size: number): Buffer;
|
|
37
|
+
/**
|
|
38
|
+
* Generate a random UUID string.
|
|
39
|
+
*
|
|
40
|
+
* @returns A random UUID string.
|
|
41
|
+
*/
|
|
42
|
+
export declare function randomUUID(): string;
|