@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,26 +1,14 @@
|
|
|
1
|
-
import { debug, content } from '
|
|
1
|
+
import { debug, content } from '../../output.js';
|
|
2
2
|
import { execa } from 'execa';
|
|
3
|
-
import {
|
|
4
|
-
import { userInfo as osUserInfo, arch as osArch } from 'node:os';
|
|
5
|
-
const getEnvironmentVariable = () => {
|
|
6
|
-
const { env } = process;
|
|
7
|
-
return env.SUDO_USER || env.C9_USER || env.LOGNAME || env.USER || env.LNAME || env.USERNAME;
|
|
8
|
-
};
|
|
9
|
-
const getUsernameFromOsUserInfo = () => {
|
|
10
|
-
try {
|
|
11
|
-
return osUserInfo().username;
|
|
12
|
-
// eslint-disable-next-line no-catch-all/no-catch-all
|
|
13
|
-
}
|
|
14
|
-
catch {
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
const cleanWindowsCommand = (value) => value.replace(/^.*\\/, '');
|
|
19
|
-
const makeUsernameFromId = (userId) => `no-username-${userId}`;
|
|
3
|
+
import { userInfo as osUserInfo } from 'os';
|
|
20
4
|
// This code has been vendored from https://github.com/sindresorhus/username
|
|
21
5
|
// because adding it as a transtive dependency causes conflicts with other
|
|
22
6
|
// packages that haven't been yet migrated to the latest version.
|
|
23
|
-
|
|
7
|
+
/**
|
|
8
|
+
* @param platform - The platform to get the username for. Defaults to the current platform.
|
|
9
|
+
* @returns The username of the current user.
|
|
10
|
+
*/
|
|
11
|
+
export async function username(platform = process.platform) {
|
|
24
12
|
debug(content `Obtaining user name...`);
|
|
25
13
|
const environmentVariable = getEnvironmentVariable();
|
|
26
14
|
if (environmentVariable) {
|
|
@@ -51,23 +39,39 @@ export const username = async (platform = processPlatform) => {
|
|
|
51
39
|
catch {
|
|
52
40
|
return null;
|
|
53
41
|
}
|
|
54
|
-
}
|
|
42
|
+
}
|
|
55
43
|
/**
|
|
56
44
|
* Returns the platform and architecture.
|
|
57
45
|
* @returns Returns the current platform and architecture.
|
|
58
46
|
*/
|
|
59
|
-
export
|
|
60
|
-
let
|
|
47
|
+
export function platformAndArch(platform = process.platform, arch = process.arch) {
|
|
48
|
+
let archString = arch;
|
|
61
49
|
if (arch === 'x64') {
|
|
62
|
-
|
|
50
|
+
archString = 'amd64';
|
|
63
51
|
}
|
|
64
52
|
if (arch === 'ia32') {
|
|
65
|
-
|
|
53
|
+
archString = '386';
|
|
66
54
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
55
|
+
const platformString = (platform.match(/^win.+/) ? 'windows' : platform);
|
|
56
|
+
return { platform: platformString, arch: archString };
|
|
57
|
+
}
|
|
58
|
+
function getEnvironmentVariable() {
|
|
59
|
+
const { env } = process;
|
|
60
|
+
return env.SUDO_USER || env.C9_USER || env.LOGNAME || env.USER || env.LNAME || env.USERNAME;
|
|
61
|
+
}
|
|
62
|
+
function getUsernameFromOsUserInfo() {
|
|
63
|
+
try {
|
|
64
|
+
return osUserInfo().username;
|
|
65
|
+
// eslint-disable-next-line no-catch-all/no-catch-all
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
return null;
|
|
70
69
|
}
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
}
|
|
71
|
+
function cleanWindowsCommand(value) {
|
|
72
|
+
return value.replace(/^.*\\/, '');
|
|
73
|
+
}
|
|
74
|
+
function makeUsernameFromId(userId) {
|
|
75
|
+
return `no-username-${userId}`;
|
|
76
|
+
}
|
|
73
77
|
//# sourceMappingURL=os.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"os.js","sourceRoot":"","sources":["../../../src/public/node/os.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAE,OAAO,EAAC,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAC,KAAK,EAAC,MAAM,OAAO,CAAA;AAC3B,OAAO,EAAC,QAAQ,IAAI,UAAU,EAAC,MAAM,IAAI,CAAA;AAEzC,4EAA4E;AAC5E,0EAA0E;AAC1E,iEAAiE;AACjE;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,WAAoC,OAAO,CAAC,QAAQ;IACjF,KAAK,CAAC,OAAO,CAAA,wBAAwB,CAAC,CAA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C,QAAQ,EAAE,cAAc,EAAE,IAAI,EAAE,UAAU,EAAC,CAAA;AACrD,CAAC;AAED,SAAS,sBAAsB;IAC7B,MAAM,EAAC,GAAG,EAAC,GAAG,OAAO,CAAA;IAErB,OAAO,GAAG,CAAC,SAAS,IAAI,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,QAAQ,CAAA;AAC7F,CAAC;AAED,SAAS,yBAAyB;IAChC,IAAI;QACF,OAAO,UAAU,EAAE,CAAC,QAAQ,CAAA;QAC5B,qDAAqD;KACtD;IAAC,MAAM;QACN,OAAO,IAAI,CAAA;KACZ;AACH,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAa;IACxC,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;AACnC,CAAC;AAED,SAAS,kBAAkB,CAAC,MAAc;IACxC,OAAO,eAAe,MAAM,EAAE,CAAA;AAChC,CAAC","sourcesContent":["import {debug, content} from '../../output.js'\nimport {execa} from 'execa'\nimport {userInfo as osUserInfo} from 'os'\n\n// This code has been vendored from https://github.com/sindresorhus/username\n// because adding it as a transtive dependency causes conflicts with other\n// packages that haven't been yet migrated to the latest version.\n/**\n * @param platform - The platform to get the username for. Defaults to the current platform.\n * @returns The username of the current user.\n */\nexport async function username(platform: typeof process.platform = process.platform): Promise<string | null> {\n debug(content`Obtaining user name...`)\n const environmentVariable = getEnvironmentVariable()\n if (environmentVariable) {\n return environmentVariable\n }\n\n const userInfoUsername = getUsernameFromOsUserInfo()\n if (userInfoUsername) {\n return userInfoUsername\n }\n\n /**\n First we try to get the ID of the user and then the actual username. We do this because in `docker run --user <uid>:<gid>` context, we don't have \"username\" available. Therefore, we have a fallback to `makeUsernameFromId` for such scenario. Applies also to the `sync()` method below.\n */\n try {\n if (platform === 'win32') {\n const {stdout} = await execa('whoami')\n return cleanWindowsCommand(stdout)\n }\n\n const {stdout: userId} = await execa('id', ['-u'])\n try {\n const {stdout} = await execa('id', ['-un', userId])\n return stdout\n\n // eslint-disable-next-line no-catch-all/no-catch-all,no-empty\n } catch {}\n return makeUsernameFromId(userId)\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return null\n }\n}\n\ntype PlatformArch = Exclude<typeof process.arch, 'x64' | 'ia32'> | 'amd64' | '386'\ntype PlatformStrings = Exclude<typeof process.platform, 'win32'> | 'windows'\n/**\n * Returns the platform and architecture.\n * @returns Returns the current platform and architecture.\n */\nexport function platformAndArch(\n platform: typeof process.platform = process.platform,\n arch: typeof process.arch = process.arch,\n): {\n platform: PlatformStrings\n arch: PlatformArch\n} {\n let archString = arch\n if (arch === 'x64') {\n archString = 'amd64'\n }\n if (arch === 'ia32') {\n archString = '386'\n }\n const platformString = (platform.match(/^win.+/) ? 'windows' : platform) as PlatformStrings\n return {platform: platformString, arch: archString}\n}\n\nfunction getEnvironmentVariable() {\n const {env} = process\n\n return env.SUDO_USER || env.C9_USER || env.LOGNAME || env.USER || env.LNAME || env.USERNAME\n}\n\nfunction getUsernameFromOsUserInfo(): string | null {\n try {\n return osUserInfo().username\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return null\n }\n}\n\nfunction cleanWindowsCommand(value: string) {\n return value.replace(/^.*\\\\/, '')\n}\n\nfunction makeUsernameFromId(userId: string) {\n return `no-username-${userId}`\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { decodeToml } from './toml.js';
|
|
1
2
|
import { exists as fileExists, read as fileRead } from '../../file.js';
|
|
2
3
|
import { findUp, join as pathJoin } from '../../path.js';
|
|
3
|
-
import { decode as tomlDecode } from '../../toml.js';
|
|
4
4
|
export const presetsFilename = 'shopify.presets.toml';
|
|
5
5
|
export async function loadPresetsFromDirectory(dir, opts) {
|
|
6
6
|
let presetsFilePath;
|
|
@@ -17,7 +17,7 @@ export async function loadPresetsFromDirectory(dir, opts) {
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
if (presetsFilePath) {
|
|
20
|
-
return
|
|
20
|
+
return decodeToml(await fileRead(presetsFilePath));
|
|
21
21
|
}
|
|
22
22
|
else {
|
|
23
23
|
return {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presets.js","sourceRoot":"","sources":["../../../src/public/node/presets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"presets.js","sourceRoot":"","sources":["../../../src/public/node/presets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,WAAW,CAAA;AACpC,OAAO,EAAC,MAAM,IAAI,UAAU,EAAE,IAAI,IAAI,QAAQ,EAAC,MAAM,eAAe,CAAA;AAEpE,OAAO,EAAC,MAAM,EAAE,IAAI,IAAI,QAAQ,EAAC,MAAM,eAAe,CAAA;AAEtD,MAAM,CAAC,MAAM,eAAe,GAAG,sBAAsB,CAAA;AAKrD,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAAC,GAAW,EAAE,IAAwB;IAClF,IAAI,eAAmC,CAAA;IACvC,IAAI,IAAI,EAAE,MAAM,EAAE;QAChB,eAAe,GAAG,MAAM,MAAM,CAAC,eAAe,EAAE;YAC9C,GAAG,EAAE,GAAG;YACR,IAAI,EAAE,MAAM;SACb,CAAC,CAAA;KACH;SAAM;QACL,MAAM,sBAAsB,GAAG,QAAQ,CAAC,GAAG,EAAE,eAAe,CAAC,CAAA;QAC7D,IAAI,MAAM,UAAU,CAAC,sBAAsB,CAAC,EAAE;YAC5C,eAAe,GAAG,sBAAsB,CAAA;SACzC;KACF;IACD,IAAI,eAAe,EAAE;QACnB,OAAO,UAAU,CAAC,MAAM,QAAQ,CAAC,eAAe,CAAC,CAAY,CAAA;KAC9D;SAAM;QACL,OAAO,EAAa,CAAA;KACrB;AACH,CAAC","sourcesContent":["import {decodeToml} from './toml.js'\nimport {exists as fileExists, read as fileRead} from '../../file.js'\nimport {JsonMap} from '../../private/common/json.js'\nimport {findUp, join as pathJoin} from '../../path.js'\n\nexport const presetsFilename = 'shopify.presets.toml'\n\nexport interface Presets {\n [name: string]: JsonMap\n}\nexport async function loadPresetsFromDirectory(dir: string, opts?: {findUp: boolean}): Promise<Presets> {\n let presetsFilePath: string | undefined\n if (opts?.findUp) {\n presetsFilePath = await findUp(presetsFilename, {\n cwd: dir,\n type: 'file',\n })\n } else {\n const allowedPresetsFilePath = pathJoin(dir, presetsFilename)\n if (await fileExists(allowedPresetsFilePath)) {\n presetsFilePath = allowedPresetsFilePath\n }\n }\n if (presetsFilePath) {\n return decodeToml(await fileRead(presetsFilePath)) as Presets\n } else {\n return {} as Presets\n }\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
import { AbortSignal } from './abort.js';
|
|
2
3
|
import { AdminSession } from '../../session.js';
|
|
3
|
-
import {
|
|
4
|
-
import { Writable } from 'node:stream';
|
|
4
|
+
import { Writable } from 'stream';
|
|
5
5
|
interface ExecCLI2Options {
|
|
6
6
|
adminSession?: AdminSession;
|
|
7
7
|
storefrontToken?: string;
|
|
@@ -14,25 +14,29 @@ interface ExecCLI2Options {
|
|
|
14
14
|
* Installs a version of RubyCLI as a vendor dependency in a hidden folder in the system.
|
|
15
15
|
* User must have a valid ruby+bundler environment to run any command.
|
|
16
16
|
*
|
|
17
|
-
* @param args - List of argumets to execute. (ex: ['theme', 'pull'])
|
|
17
|
+
* @param args - List of argumets to execute. (ex: ['theme', 'pull']).
|
|
18
18
|
* @param options - Options to customize the execution of cli2.
|
|
19
19
|
*/
|
|
20
|
-
export declare function execCLI2(args: string[],
|
|
20
|
+
export declare function execCLI2(args: string[], options?: ExecCLI2Options): Promise<void>;
|
|
21
21
|
interface ExecThemeCheckCLIOptions {
|
|
22
|
-
/** A list of directories in which theme-check should run */
|
|
22
|
+
/** A list of directories in which theme-check should run. */
|
|
23
23
|
directories: string[];
|
|
24
|
-
/** Arguments to pass to the theme-check CLI */
|
|
24
|
+
/** Arguments to pass to the theme-check CLI. */
|
|
25
25
|
args?: string[];
|
|
26
|
-
/** Writable to send standard output content through */
|
|
26
|
+
/** Writable to send standard output content through. */
|
|
27
27
|
stdout: Writable;
|
|
28
|
-
/** Writable to send standard error content through */
|
|
28
|
+
/** Writable to send standard error content through. */
|
|
29
29
|
stderr: Writable;
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
32
|
* A function that installs (if needed) and runs the theme-check CLI.
|
|
33
|
+
*
|
|
33
34
|
* @param options - Options to customize the execution of theme-check.
|
|
34
35
|
* @returns A promise that resolves or rejects depending on the result of the underlying theme-check process.
|
|
35
36
|
*/
|
|
36
|
-
export declare function execThemeCheckCLI(
|
|
37
|
+
export declare function execThemeCheckCLI(options: ExecThemeCheckCLIOptions): Promise<void[]>;
|
|
38
|
+
/**
|
|
39
|
+
* It returns the Ruby version present in the envirronment.
|
|
40
|
+
*/
|
|
37
41
|
export declare function version(): Promise<string | undefined>;
|
|
38
42
|
export {};
|
package/dist/public/node/ruby.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { coerceSemverVersion } from './semver.js';
|
|
2
|
+
import { platformAndArch } from './os.js';
|
|
2
3
|
import * as file from '../../file.js';
|
|
3
4
|
import * as ui from '../../ui.js';
|
|
4
5
|
import * as system from '../../system.js';
|
|
@@ -6,10 +7,9 @@ import { Abort, AbortSilent } from '../../error.js';
|
|
|
6
7
|
import { glob, join } from '../../path.js';
|
|
7
8
|
import constants from '../../constants.js';
|
|
8
9
|
import { content, token } from '../../output.js';
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
const ThemeCheckVersion = '1.12.1';
|
|
10
|
+
import { Writable } from 'stream';
|
|
11
|
+
const RubyCLIVersion = '2.33.1';
|
|
12
|
+
const ThemeCheckVersion = '1.14.0';
|
|
13
13
|
const MinBundlerVersion = '2.3.8';
|
|
14
14
|
const MinRubyVersion = '2.7.5';
|
|
15
15
|
/**
|
|
@@ -17,17 +17,17 @@ const MinRubyVersion = '2.7.5';
|
|
|
17
17
|
* Installs a version of RubyCLI as a vendor dependency in a hidden folder in the system.
|
|
18
18
|
* User must have a valid ruby+bundler environment to run any command.
|
|
19
19
|
*
|
|
20
|
-
* @param args - List of argumets to execute. (ex: ['theme', 'pull'])
|
|
20
|
+
* @param args - List of argumets to execute. (ex: ['theme', 'pull']).
|
|
21
21
|
* @param options - Options to customize the execution of cli2.
|
|
22
22
|
*/
|
|
23
|
-
export async function execCLI2(args,
|
|
23
|
+
export async function execCLI2(args, options = {}) {
|
|
24
24
|
await installCLIDependencies();
|
|
25
25
|
const env = {
|
|
26
26
|
...process.env,
|
|
27
|
-
SHOPIFY_CLI_STOREFRONT_RENDERER_AUTH_TOKEN: storefrontToken,
|
|
28
|
-
SHOPIFY_CLI_ADMIN_AUTH_TOKEN: adminSession?.token,
|
|
29
|
-
SHOPIFY_SHOP: adminSession?.storeFqdn,
|
|
30
|
-
SHOPIFY_CLI_AUTH_TOKEN: token,
|
|
27
|
+
SHOPIFY_CLI_STOREFRONT_RENDERER_AUTH_TOKEN: options.storefrontToken,
|
|
28
|
+
SHOPIFY_CLI_ADMIN_AUTH_TOKEN: options.adminSession?.token,
|
|
29
|
+
SHOPIFY_SHOP: options.adminSession?.storeFqdn,
|
|
30
|
+
SHOPIFY_CLI_AUTH_TOKEN: options.token,
|
|
31
31
|
SHOPIFY_CLI_RUN_AS_SUBPROCESS: 'true',
|
|
32
32
|
// Bundler uses this Gemfile to understand which gems are available in the
|
|
33
33
|
// environment. We use this to specify our own Gemfile for CLI2, which exists
|
|
@@ -37,9 +37,9 @@ export async function execCLI2(args, { adminSession, storefrontToken, token, dir
|
|
|
37
37
|
try {
|
|
38
38
|
await system.exec(bundleExecutable(), ['exec', 'shopify'].concat(args), {
|
|
39
39
|
stdio: 'inherit',
|
|
40
|
-
cwd: directory ?? process.cwd(),
|
|
40
|
+
cwd: options.directory ?? process.cwd(),
|
|
41
41
|
env,
|
|
42
|
-
signal,
|
|
42
|
+
signal: options.signal,
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
45
|
catch (error) {
|
|
@@ -49,12 +49,13 @@ export async function execCLI2(args, { adminSession, storefrontToken, token, dir
|
|
|
49
49
|
}
|
|
50
50
|
/**
|
|
51
51
|
* A function that installs (if needed) and runs the theme-check CLI.
|
|
52
|
+
*
|
|
52
53
|
* @param options - Options to customize the execution of theme-check.
|
|
53
54
|
* @returns A promise that resolves or rejects depending on the result of the underlying theme-check process.
|
|
54
55
|
*/
|
|
55
|
-
export async function execThemeCheckCLI(
|
|
56
|
-
await installThemeCheckCLIDependencies(stdout);
|
|
57
|
-
const processes = directories.map(async (directory) => {
|
|
56
|
+
export async function execThemeCheckCLI(options) {
|
|
57
|
+
await installThemeCheckCLIDependencies(options.stdout);
|
|
58
|
+
const processes = options.directories.map(async (directory) => {
|
|
58
59
|
// Check that there are files aside from the extension TOML config file,
|
|
59
60
|
// otherwise theme-check will return a false failure.
|
|
60
61
|
const files = await glob(join(directory, '/**/*'));
|
|
@@ -67,15 +68,15 @@ export async function execThemeCheckCLI({ directories, args, stdout, stderr, })
|
|
|
67
68
|
// See https://github.com/Shopify/theme-check/blob/1092737cfb58a73ca397ffb1371665dc55df2976/lib/theme_check/language_server/diagnostics_engine.rb#L31
|
|
68
69
|
// which leads to https://github.com/Shopify/theme-check/blob/1092737cfb58a73ca397ffb1371665dc55df2976/lib/theme_check/language_server/io_messenger.rb#L65
|
|
69
70
|
if (chunk.toString('ascii').match(/^Checking/)) {
|
|
70
|
-
stdout.write(chunk, ...args);
|
|
71
|
+
options.stdout.write(chunk, ...args);
|
|
71
72
|
}
|
|
72
73
|
else {
|
|
73
|
-
stderr.write(chunk, ...args);
|
|
74
|
+
options.stderr.write(chunk, ...args);
|
|
74
75
|
}
|
|
75
76
|
},
|
|
76
77
|
});
|
|
77
|
-
await system.exec(bundleExecutable(), ['exec', 'theme-check'].concat([directory, ...(args || [])]), {
|
|
78
|
-
stdout,
|
|
78
|
+
await system.exec(bundleExecutable(), ['exec', 'theme-check'].concat([directory, ...(options.args || [])]), {
|
|
79
|
+
stdout: options.stdout,
|
|
79
80
|
stderr: customStderr,
|
|
80
81
|
cwd: themeCheckDirectory(),
|
|
81
82
|
});
|
|
@@ -86,7 +87,9 @@ export async function execThemeCheckCLI({ directories, args, stdout, stderr, })
|
|
|
86
87
|
* Validate Ruby Enviroment
|
|
87
88
|
* Install Theme Check CLI and its dependencies
|
|
88
89
|
* Shows a loading message if it's the first time installing dependencies
|
|
89
|
-
* or if we are installing a new version of Theme Check CLI
|
|
90
|
+
* or if we are installing a new version of Theme Check CLI.
|
|
91
|
+
*
|
|
92
|
+
* @param stdout - The Writable stream on which to write the standard output.
|
|
90
93
|
*/
|
|
91
94
|
async function installThemeCheckCLIDependencies(stdout) {
|
|
92
95
|
const exists = await file.exists(themeCheckDirectory());
|
|
@@ -111,7 +114,7 @@ async function installThemeCheckCLIDependencies(stdout) {
|
|
|
111
114
|
* Validate Ruby Enviroment
|
|
112
115
|
* Install RubyCLI and its dependencies
|
|
113
116
|
* Shows a loading spinner if it's the first time installing dependencies
|
|
114
|
-
* or if we are installing a new version of RubyCLI
|
|
117
|
+
* or if we are installing a new version of RubyCLI.
|
|
115
118
|
*/
|
|
116
119
|
async function installCLIDependencies() {
|
|
117
120
|
const exists = await file.exists(shopifyCLIDirectory());
|
|
@@ -135,10 +138,16 @@ async function installCLIDependencies() {
|
|
|
135
138
|
], { renderer });
|
|
136
139
|
await list.run();
|
|
137
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* A function that validates if the environment in which the CLI is running is set up with Ruby and Bundler.
|
|
143
|
+
*/
|
|
138
144
|
async function validateRubyEnv() {
|
|
139
145
|
await validateRuby();
|
|
140
146
|
await validateBundler();
|
|
141
147
|
}
|
|
148
|
+
/**
|
|
149
|
+
* A function that validates if the environment in which the CLI is running is set up with Ruby.
|
|
150
|
+
*/
|
|
142
151
|
async function validateRuby() {
|
|
143
152
|
let version;
|
|
144
153
|
try {
|
|
@@ -153,6 +162,9 @@ async function validateRuby() {
|
|
|
153
162
|
throw new Abort(`Ruby version ${content `${token.yellow(version.raw)}`.value} is not supported`, `Make sure you have at least Ruby ${content `${token.yellow(MinRubyVersion)}`.value} installed on your system. ${content `${token.link('Documentation.', 'https://www.ruby-lang.org/en/documentation/installation/')}`.value}`);
|
|
154
163
|
}
|
|
155
164
|
}
|
|
165
|
+
/**
|
|
166
|
+
* A function that validates if the environment in which the CLI is running is set up with Bundler.
|
|
167
|
+
*/
|
|
156
168
|
async function validateBundler() {
|
|
157
169
|
let version;
|
|
158
170
|
try {
|
|
@@ -167,12 +179,21 @@ async function validateBundler() {
|
|
|
167
179
|
throw new Abort(`Bundler version ${content `${token.yellow(version.raw)}`.value} is not supported`, `To update to the latest version of Bundler, run ${content `${token.genericShellCommand(`${gemExecutable()} install bundler`)}`.value}`);
|
|
168
180
|
}
|
|
169
181
|
}
|
|
170
|
-
|
|
182
|
+
/**
|
|
183
|
+
* It creates the directory where the Ruby CLI will be downloaded along its dependencies.
|
|
184
|
+
*/
|
|
185
|
+
async function createShopifyCLIWorkingDirectory() {
|
|
171
186
|
return file.mkdir(shopifyCLIDirectory());
|
|
172
187
|
}
|
|
173
|
-
|
|
188
|
+
/**
|
|
189
|
+
* It creates the directory where the theme-check CLI will be downloaded along its dependencies.
|
|
190
|
+
*/
|
|
191
|
+
async function createThemeCheckCLIWorkingDirectory() {
|
|
174
192
|
return file.mkdir(themeCheckDirectory());
|
|
175
193
|
}
|
|
194
|
+
/**
|
|
195
|
+
* It creates the Gemfile to install The Ruby CLI and the dependencies.
|
|
196
|
+
*/
|
|
176
197
|
async function createShopifyCLIGemfile() {
|
|
177
198
|
const gemPath = join(shopifyCLIDirectory(), 'Gemfile');
|
|
178
199
|
const gemFileContent = ["source 'https://rubygems.org'", `gem 'shopify-cli', '${RubyCLIVersion}'`];
|
|
@@ -183,32 +204,57 @@ async function createShopifyCLIGemfile() {
|
|
|
183
204
|
}
|
|
184
205
|
await file.write(gemPath, gemFileContent.join('\n'));
|
|
185
206
|
}
|
|
207
|
+
/**
|
|
208
|
+
* It creates the Gemfile to install theme-check and its dependencies.
|
|
209
|
+
*/
|
|
186
210
|
async function createThemeCheckGemfile() {
|
|
187
211
|
const gemPath = join(themeCheckDirectory(), 'Gemfile');
|
|
188
212
|
await file.write(gemPath, `source 'https://rubygems.org'\ngem 'theme-check', '${ThemeCheckVersion}'`);
|
|
189
213
|
}
|
|
214
|
+
/**
|
|
215
|
+
* It runs bundle install for the dev-managed copy of the Ruby CLI.
|
|
216
|
+
*/
|
|
190
217
|
async function bundleInstallLocalShopifyCLI() {
|
|
191
218
|
await system.exec(bundleExecutable(), ['install'], { cwd: shopifyCLIDirectory() });
|
|
192
219
|
}
|
|
220
|
+
/**
|
|
221
|
+
* It runs bundle install for the CLI-managed copy of the Ruby CLI.
|
|
222
|
+
*/
|
|
193
223
|
async function bundleInstallShopifyCLI() {
|
|
194
224
|
await system.exec(bundleExecutable(), ['config', 'set', '--local', 'path', shopifyCLIDirectory()], {
|
|
195
225
|
cwd: shopifyCLIDirectory(),
|
|
196
226
|
});
|
|
197
227
|
await system.exec(bundleExecutable(), ['install'], { cwd: shopifyCLIDirectory() });
|
|
198
228
|
}
|
|
229
|
+
/**
|
|
230
|
+
* It runs bundle install for the CLI-managed copy of theme-check.
|
|
231
|
+
*/
|
|
199
232
|
async function bundleInstallThemeCheck() {
|
|
200
233
|
await system.exec(bundleExecutable(), ['config', 'set', '--local', 'path', themeCheckDirectory()], {
|
|
201
234
|
cwd: themeCheckDirectory(),
|
|
202
235
|
});
|
|
203
236
|
await system.exec(bundleExecutable(), ['install'], { cwd: themeCheckDirectory() });
|
|
204
237
|
}
|
|
238
|
+
/**
|
|
239
|
+
* It returns the directory where the Ruby CLI is located.
|
|
240
|
+
*
|
|
241
|
+
* @returns The absolute path to the directory.
|
|
242
|
+
*/
|
|
205
243
|
function shopifyCLIDirectory() {
|
|
206
244
|
return (process.env.SHOPIFY_CLI_2_0_DIRECTORY ??
|
|
207
245
|
join(constants.paths.directories.cache.vendor.path(), 'ruby-cli', RubyCLIVersion));
|
|
208
246
|
}
|
|
247
|
+
/**
|
|
248
|
+
* It returns the path to the directory containing the theme-check CLI.
|
|
249
|
+
*
|
|
250
|
+
* @returns The absolute path to the theme-check directory.
|
|
251
|
+
*/
|
|
209
252
|
function themeCheckDirectory() {
|
|
210
253
|
return join(constants.paths.directories.cache.vendor.path(), 'theme-check', ThemeCheckVersion);
|
|
211
254
|
}
|
|
255
|
+
/**
|
|
256
|
+
* It returns the Ruby version present in the envirronment.
|
|
257
|
+
*/
|
|
212
258
|
export async function version() {
|
|
213
259
|
const parseOutput = (version) => version.match(/ruby (\d+\.\d+\.\d+)/)?.[1];
|
|
214
260
|
return system
|
|
@@ -216,17 +262,39 @@ export async function version() {
|
|
|
216
262
|
.then(parseOutput)
|
|
217
263
|
.catch(() => undefined);
|
|
218
264
|
}
|
|
265
|
+
/**
|
|
266
|
+
* It returns the Ruby binary path set through the environment variable SHOPIFY_RUBY_BINDIR.
|
|
267
|
+
* This is useful when the CLI is managed by an installer like a Homebrew where we need to
|
|
268
|
+
* point the CLI to the Ruby installation managed by Homebrew.
|
|
269
|
+
*
|
|
270
|
+
* @returns The value of the environment variable.
|
|
271
|
+
*/
|
|
219
272
|
function getRubyBinDir() {
|
|
220
273
|
return process.env.SHOPIFY_RUBY_BINDIR;
|
|
221
274
|
}
|
|
275
|
+
/**
|
|
276
|
+
* It returns the path to the "ruby" executable.
|
|
277
|
+
*
|
|
278
|
+
* @returns The path to the executable.
|
|
279
|
+
*/
|
|
222
280
|
function rubyExecutable() {
|
|
223
281
|
const rubyBinDir = getRubyBinDir();
|
|
224
282
|
return rubyBinDir ? join(rubyBinDir, 'ruby') : 'ruby';
|
|
225
283
|
}
|
|
284
|
+
/**
|
|
285
|
+
* It returns the path to the "bundle" executable.
|
|
286
|
+
*
|
|
287
|
+
* @returns The path to the executable.
|
|
288
|
+
*/
|
|
226
289
|
function bundleExecutable() {
|
|
227
290
|
const rubyBinDir = getRubyBinDir();
|
|
228
291
|
return rubyBinDir ? join(rubyBinDir, 'bundle') : 'bundle';
|
|
229
292
|
}
|
|
293
|
+
/**
|
|
294
|
+
* It returns the path to the "gem"" executable.
|
|
295
|
+
*
|
|
296
|
+
* @returns The path to the executable.
|
|
297
|
+
*/
|
|
230
298
|
function gemExecutable() {
|
|
231
299
|
const rubyBinDir = getRubyBinDir();
|
|
232
300
|
return rubyBinDir ? join(rubyBinDir, 'gem') : 'gem';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ruby.js","sourceRoot":"","sources":["../../../src/public/node/ruby.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,mBAAmB,EAAC,MAAM,aAAa,CAAA;AAC/C,OAAO,KAAK,IAAI,MAAM,eAAe,CAAA;AACrC,OAAO,KAAK,EAAE,MAAM,aAAa,CAAA;AACjC,OAAO,KAAK,MAAM,MAAM,iBAAiB,CAAA;AACzC,OAAO,EAAC,KAAK,EAAE,WAAW,EAAC,MAAM,gBAAgB,CAAA;AACjD,OAAO,EAAC,IAAI,EAAE,IAAI,EAAC,MAAM,eAAe,CAAA;AACxC,OAAO,SAAS,MAAM,oBAAoB,CAAA;AAE1C,OAAO,EAAC,OAAO,EAAE,KAAK,EAAC,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAC,eAAe,EAAC,MAAM,aAAa,CAAA;AAE3C,OAAO,EAAC,QAAQ,EAAC,MAAM,aAAa,CAAA;AAEpC,MAAM,cAAc,GAAG,QAAQ,CAAA;AAC/B,MAAM,iBAAiB,GAAG,QAAQ,CAAA;AAClC,MAAM,iBAAiB,GAAG,OAAO,CAAA;AACjC,MAAM,cAAc,GAAG,OAAO,CAAA;AAc9B;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,IAAc,EACd,EAAC,YAAY,EAAE,eAAe,EAAE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EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,sBAAsB,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;IACnF,OAAO,MAAM;SACV,aAAa,CAAC,cAAc,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;SACvC,IAAI,CAAC,WAAW,CAAC;SACjB,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAA;AAC3B,CAAC;AAED,SAAS,aAAa;IACpB,OAAO,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAA;AACxC,CAAC;AAED,SAAS,cAAc;IACrB,MAAM,UAAU,GAAG,aAAa,EAAE,CAAA;IAClC,OAAO,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAA;AACvD,CAAC;AAED,SAAS,gBAAgB;IACvB,MAAM,UAAU,GAAG,aAAa,EAAE,CAAA;IAClC,OAAO,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAA;AAC3D,CAAC;AAED,SAAS,aAAa;IACpB,MAAM,UAAU,GAAG,aAAa,EAAE,CAAA;IAClC,OAAO,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAA;AACrD,CAAC","sourcesContent":["import {coerceSemverVersion} from './semver.js'\nimport * as file from '../../file.js'\nimport * as ui from '../../ui.js'\nimport * as system from '../../system.js'\nimport {Abort, AbortSilent} from '../../error.js'\nimport {glob, join} from '../../path.js'\nimport constants from '../../constants.js'\nimport {AdminSession} from '../../session.js'\nimport {content, token} from '../../output.js'\nimport {platformAndArch} from '../../os.js'\nimport {AbortSignal} from 'abort-controller'\nimport {Writable} from 'node:stream'\n\nconst RubyCLIVersion = '2.33.0'\nconst ThemeCheckVersion = '1.12.1'\nconst MinBundlerVersion = '2.3.8'\nconst MinRubyVersion = '2.7.5'\n\ninterface ExecCLI2Options {\n // Contains token and store to pass to CLI 2.0, which will be set as environment variables\n adminSession?: AdminSession\n // Contains token for storefront access to pass to CLI 2.0 as environment variable\n storefrontToken?: string\n // Contains token for partners access to pass to CLI 2.0 as environment variable\n token?: string\n // Directory in which to execute the command. Otherwise the current directory will be used.\n directory?: string\n\n signal?: AbortSignal\n}\n/**\n * Execute CLI 2.0 commands.\n * Installs a version of RubyCLI as a vendor dependency in a hidden folder in the system.\n * User must have a valid ruby+bundler environment to run any command.\n *\n * @param args - List of argumets to execute. (ex: ['theme', 'pull'])\n * @param options - Options to customize the execution of cli2.\n */\nexport async function execCLI2(\n args: string[],\n {adminSession, storefrontToken, token, directory, signal}: ExecCLI2Options = {},\n): Promise<void> {\n await installCLIDependencies()\n const env = {\n ...process.env,\n SHOPIFY_CLI_STOREFRONT_RENDERER_AUTH_TOKEN: storefrontToken,\n SHOPIFY_CLI_ADMIN_AUTH_TOKEN: adminSession?.token,\n SHOPIFY_SHOP: adminSession?.storeFqdn,\n SHOPIFY_CLI_AUTH_TOKEN: token,\n SHOPIFY_CLI_RUN_AS_SUBPROCESS: 'true',\n // Bundler uses this Gemfile to understand which gems are available in the\n // environment. We use this to specify our own Gemfile for CLI2, which exists\n // outside the user's project directory.\n BUNDLE_GEMFILE: join(shopifyCLIDirectory(), 'Gemfile'),\n }\n\n try {\n await system.exec(bundleExecutable(), ['exec', 'shopify'].concat(args), {\n stdio: 'inherit',\n cwd: directory ?? process.cwd(),\n env,\n signal,\n })\n } catch (error) {\n // CLI2 will show it's own errors, we don't need to show an additional CLI3 error\n throw new AbortSilent()\n }\n}\n\ninterface ExecThemeCheckCLIOptions {\n /** A list of directories in which theme-check should run */\n directories: string[]\n /** Arguments to pass to the theme-check CLI */\n args?: string[]\n /** Writable to send standard output content through */\n stdout: Writable\n /** Writable to send standard error content through */\n stderr: Writable\n}\n\n/**\n * A function that installs (if needed) and runs the theme-check CLI.\n * @param options - Options to customize the execution of theme-check.\n * @returns A promise that resolves or rejects depending on the result of the underlying theme-check process.\n */\nexport async function execThemeCheckCLI({\n directories,\n args,\n stdout,\n stderr,\n}: ExecThemeCheckCLIOptions): Promise<void[]> {\n await installThemeCheckCLIDependencies(stdout)\n\n const processes = directories.map(async (directory): Promise<void> => {\n // Check that there are files aside from the extension TOML config file,\n // otherwise theme-check will return a false failure.\n const files = await glob(join(directory, '/**/*'))\n const fileCount = files.filter((file) => !file.match(/\\.toml$/)).length\n if (fileCount === 0) return\n\n const customStderr = new Writable({\n write(chunk, ...args) {\n // For some reason, theme-check reports this initial status line to stderr\n // See https://github.com/Shopify/theme-check/blob/1092737cfb58a73ca397ffb1371665dc55df2976/lib/theme_check/language_server/diagnostics_engine.rb#L31\n // which leads to https://github.com/Shopify/theme-check/blob/1092737cfb58a73ca397ffb1371665dc55df2976/lib/theme_check/language_server/io_messenger.rb#L65\n if (chunk.toString('ascii').match(/^Checking/)) {\n stdout.write(chunk, ...args)\n } else {\n stderr.write(chunk, ...args)\n }\n },\n })\n await system.exec(bundleExecutable(), ['exec', 'theme-check'].concat([directory, ...(args || [])]), {\n stdout,\n stderr: customStderr,\n cwd: themeCheckDirectory(),\n })\n })\n return Promise.all(processes)\n}\n\n/**\n * Validate Ruby Enviroment\n * Install Theme Check CLI and its dependencies\n * Shows a loading message if it's the first time installing dependencies\n * or if we are installing a new version of Theme Check CLI\n */\nasync function installThemeCheckCLIDependencies(stdout: Writable) {\n const exists = await file.exists(themeCheckDirectory())\n\n if (!exists) stdout.write('Installing theme dependencies...')\n const list = ui.newListr(\n [\n {\n title: 'Installing theme dependencies',\n task: async () => {\n await validateRubyEnv()\n await createThemeCheckCLIWorkingDirectory()\n await createThemeCheckGemfile()\n await bundleInstallThemeCheck()\n },\n },\n ],\n {renderer: 'silent'},\n )\n await list.run()\n if (!exists) stdout.write('Installed theme dependencies!')\n}\n\n/**\n * Validate Ruby Enviroment\n * Install RubyCLI and its dependencies\n * Shows a loading spinner if it's the first time installing dependencies\n * or if we are installing a new version of RubyCLI\n */\nasync function installCLIDependencies() {\n const exists = await file.exists(shopifyCLIDirectory())\n const renderer = exists ? 'silent' : 'default'\n\n const list = ui.newListr(\n [\n {\n title: 'Installing theme dependencies',\n task: async () => {\n const usingLocalCLI2 = Boolean(process.env.SHOPIFY_CLI_2_0_DIRECTORY)\n await validateRubyEnv()\n if (usingLocalCLI2) {\n await bundleInstallLocalShopifyCLI()\n } else {\n await createShopifyCLIWorkingDirectory()\n await createShopifyCLIGemfile()\n await bundleInstallShopifyCLI()\n }\n },\n },\n ],\n {renderer},\n )\n await list.run()\n}\n\nasync function validateRubyEnv() {\n await validateRuby()\n await validateBundler()\n}\n\nasync function validateRuby() {\n let version\n try {\n const stdout = await system.captureOutput(rubyExecutable(), ['-v'])\n version = coerceSemverVersion(stdout)\n } catch {\n throw new Abort(\n 'Ruby environment not found',\n `Make sure you have Ruby installed on your system. ${\n content`${token.link('Documentation.', 'https://www.ruby-lang.org/en/documentation/installation/')}`.value\n }`,\n )\n }\n\n const isValid = version?.compare(MinRubyVersion)\n if (isValid === -1 || isValid === undefined) {\n throw new Abort(\n `Ruby version ${content`${token.yellow(version.raw)}`.value} is not supported`,\n `Make sure you have at least Ruby ${content`${token.yellow(MinRubyVersion)}`.value} installed on your system. ${\n content`${token.link('Documentation.', 'https://www.ruby-lang.org/en/documentation/installation/')}`.value\n }`,\n )\n }\n}\n\nasync function validateBundler() {\n let version\n try {\n const stdout = await system.captureOutput(bundleExecutable(), ['-v'])\n version = coerceSemverVersion(stdout)\n } catch {\n throw new Abort(\n 'Bundler not found',\n `To install the latest version of Bundler, run ${\n content`${token.genericShellCommand(`${gemExecutable()} install bundler`)}`.value\n }`,\n )\n }\n\n const isValid = version?.compare(MinBundlerVersion)\n if (isValid === -1 || isValid === undefined) {\n throw new Abort(\n `Bundler version ${content`${token.yellow(version.raw)}`.value} is not supported`,\n `To update to the latest version of Bundler, run ${\n content`${token.genericShellCommand(`${gemExecutable()} install bundler`)}`.value\n }`,\n )\n }\n}\n\nfunction createShopifyCLIWorkingDirectory() {\n return file.mkdir(shopifyCLIDirectory())\n}\n\nfunction createThemeCheckCLIWorkingDirectory() {\n return file.mkdir(themeCheckDirectory())\n}\n\nasync function createShopifyCLIGemfile() {\n const gemPath = join(shopifyCLIDirectory(), 'Gemfile')\n const gemFileContent = [\"source 'https://rubygems.org'\", `gem 'shopify-cli', '${RubyCLIVersion}'`]\n const {platform} = platformAndArch()\n if (platform === 'windows') {\n // 'wdm' is required by 'listen', see https://github.com/Shopify/cli/issues/780\n gemFileContent.push(\"gem 'wdm', '>= 0.1.0'\")\n }\n await file.write(gemPath, gemFileContent.join('\\n'))\n}\n\nasync function createThemeCheckGemfile() {\n const gemPath = join(themeCheckDirectory(), 'Gemfile')\n await file.write(gemPath, `source 'https://rubygems.org'\\ngem 'theme-check', '${ThemeCheckVersion}'`)\n}\n\nasync function bundleInstallLocalShopifyCLI() {\n await system.exec(bundleExecutable(), ['install'], {cwd: shopifyCLIDirectory()})\n}\n\nasync function bundleInstallShopifyCLI() {\n await system.exec(bundleExecutable(), ['config', 'set', '--local', 'path', shopifyCLIDirectory()], {\n cwd: shopifyCLIDirectory(),\n })\n await system.exec(bundleExecutable(), ['install'], {cwd: shopifyCLIDirectory()})\n}\n\nasync function bundleInstallThemeCheck() {\n await system.exec(bundleExecutable(), ['config', 'set', '--local', 'path', themeCheckDirectory()], {\n cwd: themeCheckDirectory(),\n })\n await system.exec(bundleExecutable(), ['install'], {cwd: themeCheckDirectory()})\n}\n\nfunction shopifyCLIDirectory() {\n return (\n process.env.SHOPIFY_CLI_2_0_DIRECTORY ??\n join(constants.paths.directories.cache.vendor.path(), 'ruby-cli', RubyCLIVersion)\n )\n}\n\nfunction themeCheckDirectory() {\n return join(constants.paths.directories.cache.vendor.path(), 'theme-check', ThemeCheckVersion)\n}\n\nexport async function version(): Promise<string | undefined> {\n const parseOutput = (version: string) => version.match(/ruby (\\d+\\.\\d+\\.\\d+)/)?.[1]\n return system\n .captureOutput(rubyExecutable(), ['-v'])\n .then(parseOutput)\n .catch(() => undefined)\n}\n\nfunction getRubyBinDir(): string | undefined {\n return process.env.SHOPIFY_RUBY_BINDIR\n}\n\nfunction rubyExecutable(): string {\n const rubyBinDir = getRubyBinDir()\n return rubyBinDir ? join(rubyBinDir, 'ruby') : 'ruby'\n}\n\nfunction bundleExecutable(): string {\n const rubyBinDir = getRubyBinDir()\n return rubyBinDir ? join(rubyBinDir, 'bundle') : 'bundle'\n}\n\nfunction gemExecutable(): string {\n const rubyBinDir = getRubyBinDir()\n return rubyBinDir ? join(rubyBinDir, 'gem') : 'gem'\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ruby.js","sourceRoot":"","sources":["../../../src/public/node/ruby.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,mBAAmB,EAAC,MAAM,aAAa,CAAA;AAE/C,OAAO,EAAC,eAAe,EAAC,MAAM,SAAS,CAAA;AACvC,OAAO,KAAK,IAAI,MAAM,eAAe,CAAA;AACrC,OAAO,KAAK,EAAE,MAAM,aAAa,CAAA;AACjC,OAAO,KAAK,MAAM,MAAM,iBAAiB,CAAA;AACzC,OAAO,EAAC,KAAK,EAAE,WAAW,EAAC,MAAM,gBAAgB,CAAA;AACjD,OAAO,EAAC,IAAI,EAAE,IAAI,EAAC,MAAM,eAAe,CAAA;AACxC,OAAO,SAAS,MAAM,oBAAoB,CAAA;AAE1C,OAAO,EAAC,OAAO,EAAE,KAAK,EAAC,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAC,QAAQ,EAAC,MAAM,QAAQ,CAAA;AAE/B,MAAM,cAAc,GAAG,QAAQ,CAAA;AAC/B,MAAM,iBAAiB,GAAG,QAAQ,CAAA;AAClC,MAAM,iBAAiB,GAAG,OAAO,CAAA;AACjC,MAAM,cAAc,GAAG,OAAO,CAAA;AAc9B;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,IAAc,EAAE,UAA2B,EAAE;IAC1E,MAAM,s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Arch} from './os.js'\nimport * as file from '../../file.js'\nimport * as ui from '../../ui.js'\nimport * as system from '../../system.js'\nimport {Abort, AbortSilent} from '../../error.js'\nimport {glob, join} from '../../path.js'\nimport constants from '../../constants.js'\nimport {AdminSession} from '../../session.js'\nimport {content, token} from '../../output.js'\nimport {Writable} from 'stream'\n\nconst RubyCLIVersion = '2.33.1'\nconst ThemeCheckVersion = '1.14.0'\nconst MinBundlerVersion = '2.3.8'\nconst MinRubyVersion = '2.7.5'\n\ninterface ExecCLI2Options {\n // Contains token and store to pass to CLI 2.0, which will be set as environment variables\n adminSession?: AdminSession\n // Contains token for storefront access to pass to CLI 2.0 as environment variable\n storefrontToken?: string\n // Contains token for partners access to pass to CLI 2.0 as environment variable\n token?: string\n // Directory in which to execute the command. Otherwise the current directory will be used.\n directory?: string\n // A signal to stop the process execution.\n signal?: AbortSignal\n}\n/**\n * Execute CLI 2.0 commands.\n * Installs a version of RubyCLI as a vendor dependency in a hidden folder in the system.\n * User must have a valid ruby+bundler environment to run any command.\n *\n * @param args - List of argumets to execute. (ex: ['theme', 'pull']).\n * @param options - Options to customize the execution of cli2.\n */\nexport async function execCLI2(args: string[], options: ExecCLI2Options = {}): Promise<void> {\n await installCLIDependencies()\n const env: NodeJS.ProcessEnv = {\n ...process.env,\n SHOPIFY_CLI_STOREFRONT_RENDERER_AUTH_TOKEN: options.storefrontToken,\n SHOPIFY_CLI_ADMIN_AUTH_TOKEN: options.adminSession?.token,\n SHOPIFY_SHOP: options.adminSession?.storeFqdn,\n SHOPIFY_CLI_AUTH_TOKEN: options.token,\n SHOPIFY_CLI_RUN_AS_SUBPROCESS: 'true',\n // Bundler uses this Gemfile to understand which gems are available in the\n // environment. We use this to specify our own Gemfile for CLI2, which exists\n // outside the user's project directory.\n BUNDLE_GEMFILE: join(shopifyCLIDirectory(), 'Gemfile'),\n }\n\n try {\n await system.exec(bundleExecutable(), ['exec', 'shopify'].concat(args), {\n stdio: 'inherit',\n cwd: options.directory ?? process.cwd(),\n env,\n signal: options.signal,\n })\n } catch (error) {\n // CLI2 will show it's own errors, we don't need to show an additional CLI3 error\n throw new AbortSilent()\n }\n}\n\ninterface ExecThemeCheckCLIOptions {\n /** A list of directories in which theme-check should run. */\n directories: string[]\n /** Arguments to pass to the theme-check CLI. */\n args?: string[]\n /** Writable to send standard output content through. */\n stdout: Writable\n /** Writable to send standard error content through. */\n stderr: Writable\n}\n\n/**\n * A function that installs (if needed) and runs the theme-check CLI.\n *\n * @param options - Options to customize the execution of theme-check.\n * @returns A promise that resolves or rejects depending on the result of the underlying theme-check process.\n */\nexport async function execThemeCheckCLI(options: ExecThemeCheckCLIOptions): Promise<void[]> {\n await installThemeCheckCLIDependencies(options.stdout)\n\n const processes = options.directories.map(async (directory): Promise<void> => {\n // Check that there are files aside from the extension TOML config file,\n // otherwise theme-check will return a false failure.\n const files = await glob(join(directory, '/**/*'))\n const fileCount = files.filter((file) => !file.match(/\\.toml$/)).length\n if (fileCount === 0) return\n\n const customStderr = new Writable({\n write(chunk, ...args) {\n // For some reason, theme-check reports this initial status line to stderr\n // See https://github.com/Shopify/theme-check/blob/1092737cfb58a73ca397ffb1371665dc55df2976/lib/theme_check/language_server/diagnostics_engine.rb#L31\n // which leads to https://github.com/Shopify/theme-check/blob/1092737cfb58a73ca397ffb1371665dc55df2976/lib/theme_check/language_server/io_messenger.rb#L65\n if (chunk.toString('ascii').match(/^Checking/)) {\n options.stdout.write(chunk, ...args)\n } else {\n options.stderr.write(chunk, ...args)\n }\n },\n })\n await system.exec(bundleExecutable(), ['exec', 'theme-check'].concat([directory, ...(options.args || [])]), {\n stdout: options.stdout,\n stderr: customStderr,\n cwd: themeCheckDirectory(),\n })\n })\n return Promise.all(processes)\n}\n\n/**\n * Validate Ruby Enviroment\n * Install Theme Check CLI and its dependencies\n * Shows a loading message if it's the first time installing dependencies\n * or if we are installing a new version of Theme Check CLI.\n *\n * @param stdout - The Writable stream on which to write the standard output.\n */\nasync function installThemeCheckCLIDependencies(stdout: Writable) {\n const exists = await file.exists(themeCheckDirectory())\n\n if (!exists) stdout.write('Installing theme dependencies...')\n const list = ui.newListr(\n [\n {\n title: 'Installing theme dependencies',\n task: async () => {\n await validateRubyEnv()\n await createThemeCheckCLIWorkingDirectory()\n await createThemeCheckGemfile()\n await bundleInstallThemeCheck()\n },\n },\n ],\n {renderer: 'silent'},\n )\n await list.run()\n if (!exists) stdout.write('Installed theme dependencies!')\n}\n\n/**\n * Validate Ruby Enviroment\n * Install RubyCLI and its dependencies\n * Shows a loading spinner if it's the first time installing dependencies\n * or if we are installing a new version of RubyCLI.\n */\nasync function installCLIDependencies() {\n const exists = await file.exists(shopifyCLIDirectory())\n const renderer = exists ? 'silent' : 'default'\n\n const list = ui.newListr(\n [\n {\n title: 'Installing theme dependencies',\n task: async () => {\n const usingLocalCLI2 = Boolean(process.env.SHOPIFY_CLI_2_0_DIRECTORY)\n await validateRubyEnv()\n if (usingLocalCLI2) {\n await bundleInstallLocalShopifyCLI()\n } else {\n await createShopifyCLIWorkingDirectory()\n await createShopifyCLIGemfile()\n await bundleInstallShopifyCLI()\n }\n },\n },\n ],\n {renderer},\n )\n await list.run()\n}\n\n/**\n * A function that validates if the environment in which the CLI is running is set up with Ruby and Bundler.\n */\nasync function validateRubyEnv() {\n await validateRuby()\n await validateBundler()\n}\n\n/**\n * A function that validates if the environment in which the CLI is running is set up with Ruby.\n */\nasync function validateRuby() {\n let version\n try {\n const stdout = await system.captureOutput(rubyExecutable(), ['-v'])\n version = coerceSemverVersion(stdout)\n } catch {\n throw new Abort(\n 'Ruby environment not found',\n `Make sure you have Ruby installed on your system. ${\n content`${token.link('Documentation.', 'https://www.ruby-lang.org/en/documentation/installation/')}`.value\n }`,\n )\n }\n\n const isValid = version?.compare(MinRubyVersion)\n if (isValid === -1 || isValid === undefined) {\n throw new Abort(\n `Ruby version ${content`${token.yellow(version.raw)}`.value} is not supported`,\n `Make sure you have at least Ruby ${content`${token.yellow(MinRubyVersion)}`.value} installed on your system. ${\n content`${token.link('Documentation.', 'https://www.ruby-lang.org/en/documentation/installation/')}`.value\n }`,\n )\n }\n}\n\n/**\n * A function that validates if the environment in which the CLI is running is set up with Bundler.\n */\nasync function validateBundler() {\n let version\n try {\n const stdout = await system.captureOutput(bundleExecutable(), ['-v'])\n version = coerceSemverVersion(stdout)\n } catch {\n throw new Abort(\n 'Bundler not found',\n `To install the latest version of Bundler, run ${\n content`${token.genericShellCommand(`${gemExecutable()} install bundler`)}`.value\n }`,\n )\n }\n\n const isValid = version?.compare(MinBundlerVersion)\n if (isValid === -1 || isValid === undefined) {\n throw new Abort(\n `Bundler version ${content`${token.yellow(version.raw)}`.value} is not supported`,\n `To update to the latest version of Bundler, run ${\n content`${token.genericShellCommand(`${gemExecutable()} install bundler`)}`.value\n }`,\n )\n }\n}\n\n/**\n * It creates the directory where the Ruby CLI will be downloaded along its dependencies.\n */\nasync function createShopifyCLIWorkingDirectory(): Promise<void> {\n return file.mkdir(shopifyCLIDirectory())\n}\n\n/**\n * It creates the directory where the theme-check CLI will be downloaded along its dependencies.\n */\nasync function createThemeCheckCLIWorkingDirectory(): Promise<void> {\n return file.mkdir(themeCheckDirectory())\n}\n\n/**\n * It creates the Gemfile to install The Ruby CLI and the dependencies.\n */\nasync function createShopifyCLIGemfile(): Promise<void> {\n const gemPath = join(shopifyCLIDirectory(), 'Gemfile')\n const gemFileContent = [\"source 'https://rubygems.org'\", `gem 'shopify-cli', '${RubyCLIVersion}'`]\n const {platform} = platformAndArch()\n if (platform === 'windows') {\n // 'wdm' is required by 'listen', see https://github.com/Shopify/cli/issues/780\n gemFileContent.push(\"gem 'wdm', '>= 0.1.0'\")\n }\n await file.write(gemPath, gemFileContent.join('\\n'))\n}\n\n/**\n * It creates the Gemfile to install theme-check and its dependencies.\n */\nasync function createThemeCheckGemfile(): Promise<void> {\n const gemPath = join(themeCheckDirectory(), 'Gemfile')\n await file.write(gemPath, `source 'https://rubygems.org'\\ngem 'theme-check', '${ThemeCheckVersion}'`)\n}\n\n/**\n * It runs bundle install for the dev-managed copy of the Ruby CLI.\n */\nasync function bundleInstallLocalShopifyCLI(): Promise<void> {\n await system.exec(bundleExecutable(), ['install'], {cwd: shopifyCLIDirectory()})\n}\n\n/**\n * It runs bundle install for the CLI-managed copy of the Ruby CLI.\n */\nasync function bundleInstallShopifyCLI() {\n await system.exec(bundleExecutable(), ['config', 'set', '--local', 'path', shopifyCLIDirectory()], {\n cwd: shopifyCLIDirectory(),\n })\n await system.exec(bundleExecutable(), ['install'], {cwd: shopifyCLIDirectory()})\n}\n\n/**\n * It runs bundle install for the CLI-managed copy of theme-check.\n */\nasync function bundleInstallThemeCheck() {\n await system.exec(bundleExecutable(), ['config', 'set', '--local', 'path', themeCheckDirectory()], {\n cwd: themeCheckDirectory(),\n })\n await system.exec(bundleExecutable(), ['install'], {cwd: themeCheckDirectory()})\n}\n\n/**\n * It returns the directory where the Ruby CLI is located.\n *\n * @returns The absolute path to the directory.\n */\nfunction shopifyCLIDirectory(): string {\n return (\n process.env.SHOPIFY_CLI_2_0_DIRECTORY ??\n join(constants.paths.directories.cache.vendor.path(), 'ruby-cli', RubyCLIVersion)\n )\n}\n\n/**\n * It returns the path to the directory containing the theme-check CLI.\n *\n * @returns The absolute path to the theme-check directory.\n */\nfunction themeCheckDirectory(): string {\n return join(constants.paths.directories.cache.vendor.path(), 'theme-check', ThemeCheckVersion)\n}\n\n/**\n * It returns the Ruby version present in the envirronment.\n */\nexport async function version(): Promise<string | undefined> {\n const parseOutput = (version: string) => version.match(/ruby (\\d+\\.\\d+\\.\\d+)/)?.[1]\n return system\n .captureOutput(rubyExecutable(), ['-v'])\n .then(parseOutput)\n .catch(() => undefined)\n}\n\n/**\n * It returns the Ruby binary path set through the environment variable SHOPIFY_RUBY_BINDIR.\n * This is useful when the CLI is managed by an installer like a Homebrew where we need to\n * point the CLI to the Ruby installation managed by Homebrew.\n *\n * @returns The value of the environment variable.\n */\nfunction getRubyBinDir(): string | undefined {\n return process.env.SHOPIFY_RUBY_BINDIR\n}\n\n/**\n * It returns the path to the \"ruby\" executable.\n *\n * @returns The path to the executable.\n */\nfunction rubyExecutable(): string {\n const rubyBinDir = getRubyBinDir()\n return rubyBinDir ? join(rubyBinDir, 'ruby') : 'ruby'\n}\n\n/**\n * It returns the path to the \"bundle\" executable.\n *\n * @returns The path to the executable.\n */\nfunction bundleExecutable(): string {\n const rubyBinDir = getRubyBinDir()\n return rubyBinDir ? join(rubyBinDir, 'bundle') : 'bundle'\n}\n\n/**\n * It returns the path to the \"gem\"\" executable.\n *\n * @returns The path to the executable.\n */\nfunction gemExecutable(): string {\n const rubyBinDir = getRubyBinDir()\n return rubyBinDir ? join(rubyBinDir, 'gem') : 'gem'\n}\n"]}
|
package/dist/public/node/tcp.js
CHANGED
|
@@ -4,7 +4,9 @@ import { sleep } from '../../system.js';
|
|
|
4
4
|
import * as port from 'get-port-please';
|
|
5
5
|
/**
|
|
6
6
|
* Returns an available port in the current environment.
|
|
7
|
+
*
|
|
7
8
|
* @returns A promise that resolves with an availabe port.
|
|
9
|
+
* @example
|
|
8
10
|
*/
|
|
9
11
|
export async function getAvailableTCPPort() {
|
|
10
12
|
debug(content `Getting a random port...`);
|
|
@@ -12,6 +14,13 @@ export async function getAvailableTCPPort() {
|
|
|
12
14
|
debug(content `Random port obtained: ${token.raw(`${randomPort}`)}`);
|
|
13
15
|
return randomPort;
|
|
14
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Given a function, it runs it and retries in case of failiure up to the provided number of times.
|
|
19
|
+
*
|
|
20
|
+
* @param execute - The function to execute.
|
|
21
|
+
* @param maxTries - The maximum retries.
|
|
22
|
+
* @param waitTimeInSeconds - The time to wait between retries.
|
|
23
|
+
*/
|
|
15
24
|
async function retryOnError(execute, maxTries = 5, waitTimeInSeconds = 1) {
|
|
16
25
|
let retryCount = 1;
|
|
17
26
|
while (true) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tcp.js","sourceRoot":"","sources":["../../../src/public/node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AAO,CAAA,0CAA0C,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;gBACvE,4CAA4C;gBAC5C,MAAM,KAAK,CAAC,iBAAiB,CAAC,CAAA;aAC/B;iBAAM;gBACL,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;aAC/B;SACF;KACF;AACH,CAAC","sourcesContent":["import {debug, content, token} from '../../output.js'\nimport {Abort} from '../../error.js'\nimport {sleep} from '../../system.js'\nimport * as port from 'get-port-please'\n\n/**\n * Returns an available port in the current environment.\n *\n * @returns A promise that resolves with an availabe port.\n * @example\n */\nexport async function getAvailableTCPPort(): Promise<number> {\n debug(content`Getting a random port...`)\n const randomPort = await retryOnError(() => port.getRandomPort())\n debug(content`Random port obtained: ${token.raw(`${randomPort}`)}`)\n return randomPort\n}\n\n/**\n * Given a function, it runs it and retries in case of failiure up to the provided number of times.\n *\n * @param execute - The function to execute.\n * @param maxTries - The maximum retries.\n * @param waitTimeInSeconds - The time to wait between retries.\n */\nasync function retryOnError<T>(execute: () => T, maxTries = 5, waitTimeInSeconds = 1) {\n let retryCount = 1\n while (true) {\n try {\n // eslint-disable-next-line no-await-in-loop\n return await execute()\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n if (retryCount++ < maxTries) {\n debug(content`Unknown problem getting a random port: ${error.message}`)\n // eslint-disable-next-line no-await-in-loop\n await sleep(waitTimeInSeconds)\n } else {\n throw new Abort(error.message)\n }\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as toml from '@iarna/toml';
|
|
2
|
+
/**
|
|
3
|
+
* Given a TOML string, it returns a JSON object.
|
|
4
|
+
*
|
|
5
|
+
* @param input - TOML string.
|
|
6
|
+
* @returns JSON object.
|
|
7
|
+
*/
|
|
8
|
+
export declare function decodeToml(input: string): object;
|
|
9
|
+
/**
|
|
10
|
+
* Given a JSON object, it returns a TOML string.
|
|
11
|
+
*
|
|
12
|
+
* @param content - JSON object.
|
|
13
|
+
* @returns TOML string.
|
|
14
|
+
*/
|
|
15
|
+
export declare function encodeToml(content: toml.JsonMap): string;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as toml from '@iarna/toml';
|
|
2
|
+
/**
|
|
3
|
+
* Given a TOML string, it returns a JSON object.
|
|
4
|
+
*
|
|
5
|
+
* @param input - TOML string.
|
|
6
|
+
* @returns JSON object.
|
|
7
|
+
*/
|
|
8
|
+
export function decodeToml(input) {
|
|
9
|
+
return toml.parse(input);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Given a JSON object, it returns a TOML string.
|
|
13
|
+
*
|
|
14
|
+
* @param content - JSON object.
|
|
15
|
+
* @returns TOML string.
|
|
16
|
+
*/
|
|
17
|
+
export function encodeToml(content) {
|
|
18
|
+
return toml.stringify(content);
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=toml.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toml.js","sourceRoot":"","sources":["../../../src/public/node/toml.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,aAAa,CAAA;AAEnC;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,KAAa;IACtC,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;AAC1B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,OAAqB;IAC9C,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;AAChC,CAAC","sourcesContent":["import * as toml from '@iarna/toml'\n\n/**\n * Given a TOML string, it returns a JSON object.\n *\n * @param input - TOML string.\n * @returns JSON object.\n */\nexport function decodeToml(input: string): object {\n return toml.parse(input)\n}\n\n/**\n * Given a JSON object, it returns a TOML string.\n *\n * @param content - JSON object.\n * @returns TOML string.\n */\nexport function encodeToml(content: toml.JsonMap): string {\n return toml.stringify(content)\n}\n"]}
|