@shopify/cli-kit 3.32.0 → 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/dist/api.d.ts +2 -5
- package/dist/api.js +2 -5
- package/dist/api.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 -5
- package/dist/index.js +0 -5
- package/dist/index.js.map +1 -1
- package/dist/npm.js +1 -1
- package/dist/npm.js.map +1 -1
- package/dist/private/node/analytics.js +2 -2
- package/dist/private/node/analytics.js.map +1 -1
- 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/FullScreen.js +11 -9
- package/dist/private/node/ui/components/FullScreen.js.map +1 -1
- package/dist/private/node/ui/components/SelectPrompt.js +15 -3
- package/dist/private/node/ui/components/SelectPrompt.js.map +1 -1
- package/dist/private/node/ui/components/Table.js +1 -1
- package/dist/private/node/ui/components/Table.js.map +1 -1
- package/dist/public/common/collection.js.map +1 -1
- package/dist/public/common/object.js +3 -3
- 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/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/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/{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/os.d.ts +16 -0
- package/dist/{os.js → public/node/os.js} +33 -28
- package/dist/public/node/os.js.map +1 -0
- package/dist/public/node/presets.js +2 -2
- package/dist/public/node/presets.js.map +1 -1
- package/dist/public/node/ruby.d.ts +11 -7
- package/dist/public/node/ruby.js +89 -21
- 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/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 +7 -2
- 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/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.js +1 -1
- package/dist/system.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/ui/inquirer/autocomplete.js +1 -1
- package/dist/ui/inquirer/autocomplete.js.map +1 -1
- package/package.json +2 -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/os.d.ts +0 -11
- package/dist/os.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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crypto.js","sourceRoot":"","sources":["../../../src/public/node/crypto.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAA;AAE3B;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,OAAO,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;AACjD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,GAAW;IACzC,OAAO,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;AAC3F,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,MAAM,CAAC,GAAW;IAChC,OAAO,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAA;AACzD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,GAAW;IACpC,OAAO,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AAC5D,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,OAAO,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;AACjC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU;IACxB,OAAO,MAAM,CAAC,UAAU,EAAE,CAAA;AAC5B,CAAC","sourcesContent":["import crypto from 'crypto'\n\n/**\n * Generate a random string in Hex format of the provided size.\n *\n * @param size - Number of bytes to be generated.\n * @returns A random string in Hex format.\n */\nexport function randomHex(size: number): string {\n return crypto.randomBytes(size).toString('hex')\n}\n\n/**\n * Encode a string in Base64 valid for URLs.\n *\n * @param str - The string to encode.\n * @returns The encoded string.\n */\nexport function base64URLEncode(str: Buffer): string {\n return str.toString('base64').replace(/\\+/g, '-').replace(/\\//g, '_').replace(/[=]/g, '')\n}\n\n/**\n * Generate the SHA256 hash of a string.\n *\n * @param str - The string to hash.\n * @returns The SHA256 hash of the string.\n */\nexport function sha256(str: string): Buffer {\n return crypto.createHash('sha256').update(str).digest()\n}\n\n/**\n * Generate the SHA1 hash of a string.\n *\n * @param str - The string to hash.\n * @returns The SHA1 hash of the string.\n */\nexport function hashString(str: string): string {\n return crypto.createHash('sha1').update(str).digest('hex')\n}\n\n/**\n * Generate random data of the provided size.\n *\n * @param size - Number of bytes to be generated.\n * @returns A buffer of random data.\n */\nexport function randomBytes(size: number): Buffer {\n return crypto.randomBytes(size)\n}\n\n/**\n * Generate a random UUID string.\n *\n * @returns A random UUID string.\n */\nexport function randomUUID(): string {\n return crypto.randomUUID()\n}\n"]}
|
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Renders a template using the Liquid template engine.
|
|
3
|
+
*
|
|
4
|
+
* @param templateContent - Template content.
|
|
5
|
+
* @param data - Data to feed the template engine.
|
|
6
|
+
* @returns Rendered template.
|
|
7
|
+
*/
|
|
8
|
+
export declare function renderLiquidTemplate(templateContent: string, data: object): Promise<string>;
|
|
2
9
|
/**
|
|
3
10
|
* Given a directory, it traverses the files and directories recursively
|
|
4
11
|
* and replaces variables in directory and file names, and files' content
|
|
5
12
|
* using the Liquid template engine.
|
|
6
13
|
* Files indicate that they are liquid template by using the .liquid extension.
|
|
14
|
+
*
|
|
7
15
|
* @param from - Directory that contains the template.
|
|
8
16
|
* @param to - Output directory.
|
|
9
17
|
* @param data - Data to feed the template engine.
|
|
10
18
|
*/
|
|
11
|
-
export declare function
|
|
19
|
+
export declare function recursiveLiquidTemplateCopy(from: string, to: string, data: object): Promise<void>;
|
|
@@ -1,24 +1,29 @@
|
|
|
1
|
-
import { glob, join, dirname, relative } from '
|
|
2
|
-
import { mkdir, read, copy, chmod, isDirectory, write, hasExecutablePermissions } from '
|
|
3
|
-
import { content, token, debug } from '
|
|
1
|
+
import { glob, join, dirname, relative } from '../../path.js';
|
|
2
|
+
import { mkdir, read, copy, chmod, isDirectory, write, hasExecutablePermissions } from '../../file.js';
|
|
3
|
+
import { content, token, debug } from '../../output.js';
|
|
4
4
|
import { Liquid } from 'liquidjs';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Renders a template using the Liquid template engine.
|
|
7
|
+
*
|
|
8
|
+
* @param templateContent - Template content.
|
|
9
|
+
* @param data - Data to feed the template engine.
|
|
10
|
+
* @returns Rendered template.
|
|
11
|
+
*/
|
|
12
|
+
export function renderLiquidTemplate(templateContent, data) {
|
|
13
|
+
const engine = new Liquid();
|
|
14
|
+
return engine.render(engine.parse(templateContent), data);
|
|
11
15
|
}
|
|
12
16
|
/**
|
|
13
17
|
* Given a directory, it traverses the files and directories recursively
|
|
14
18
|
* and replaces variables in directory and file names, and files' content
|
|
15
19
|
* using the Liquid template engine.
|
|
16
20
|
* Files indicate that they are liquid template by using the .liquid extension.
|
|
21
|
+
*
|
|
17
22
|
* @param from - Directory that contains the template.
|
|
18
23
|
* @param to - Output directory.
|
|
19
24
|
* @param data - Data to feed the template engine.
|
|
20
25
|
*/
|
|
21
|
-
export async function
|
|
26
|
+
export async function recursiveLiquidTemplateCopy(from, to, data) {
|
|
22
27
|
debug(content `Copying template from directory ${token.path(from)} to ${token.path(to)}`);
|
|
23
28
|
const templateFiles = await glob(join(from, '**/*'), { dot: true });
|
|
24
29
|
const sortedTemplateFiles = templateFiles
|
|
@@ -26,14 +31,14 @@ export async function recursiveDirectoryCopy(from, to, data) {
|
|
|
26
31
|
.sort((lhs, rhs) => (lhs.length < rhs.length ? 1 : -1))
|
|
27
32
|
.map((components) => components.join('/'));
|
|
28
33
|
await Promise.all(sortedTemplateFiles.map(async (templateItemPath) => {
|
|
29
|
-
const outputPath = await
|
|
34
|
+
const outputPath = await renderLiquidTemplate(join(to, relative(from, templateItemPath)), data);
|
|
30
35
|
if (await isDirectory(templateItemPath)) {
|
|
31
36
|
await mkdir(outputPath);
|
|
32
37
|
}
|
|
33
38
|
else if (templateItemPath.endsWith('.liquid')) {
|
|
34
39
|
await mkdir(dirname(outputPath));
|
|
35
40
|
const content = await read(templateItemPath);
|
|
36
|
-
const contentOutput = await
|
|
41
|
+
const contentOutput = await renderLiquidTemplate(content, data);
|
|
37
42
|
const isExecutable = await hasExecutablePermissions(templateItemPath);
|
|
38
43
|
const outputPathWithoutLiquid = outputPath.replace('.liquid', '');
|
|
39
44
|
await copy(templateItemPath, outputPathWithoutLiquid);
|
|
@@ -47,4 +52,4 @@ export async function recursiveDirectoryCopy(from, to, data) {
|
|
|
47
52
|
}
|
|
48
53
|
}));
|
|
49
54
|
}
|
|
50
|
-
//# sourceMappingURL=
|
|
55
|
+
//# sourceMappingURL=liquid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"liquid.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, copy, chmod, isDirectory, write, hasExecutablePermissions} from '../../file.js'\nimport {content, token, debug} from '../../output.js'\nimport {Liquid} from 'liquidjs'\n\n/**\n * Renders a template using the Liquid template engine.\n *\n * @param templateContent - Template content.\n * @param data - Data to feed the template engine.\n * @returns Rendered template.\n */\nexport function renderLiquidTemplate(templateContent: string, data: object): Promise<string> {\n const engine = new Liquid()\n return engine.render(engine.parse(templateContent), data)\n}\n\n/**\n * Given a directory, it traverses the files and directories recursively\n * and replaces variables in directory and file names, and files' content\n * using the Liquid template engine.\n * Files indicate that they are liquid template by using the .liquid extension.\n *\n * @param from - Directory that contains the template.\n * @param to - Output directory.\n * @param data - Data to feed the template engine.\n */\nexport async function recursiveLiquidTemplateCopy(from: string, to: string, data: object): Promise<void> {\n debug(content`Copying template from directory ${token.path(from)} to ${token.path(to)}`)\n const templateFiles: string[] = await glob(join(from, '**/*'), {dot: true})\n\n const sortedTemplateFiles = templateFiles\n .map((path) => path.split('/'))\n .sort((lhs, rhs) => (lhs.length < rhs.length ? 1 : -1))\n .map((components) => components.join('/'))\n await Promise.all(\n sortedTemplateFiles.map(async (templateItemPath) => {\n const outputPath = await renderLiquidTemplate(join(to, relative(from, templateItemPath)), data)\n if (await isDirectory(templateItemPath)) {\n await mkdir(outputPath)\n } else if (templateItemPath.endsWith('.liquid')) {\n await mkdir(dirname(outputPath))\n const content = await read(templateItemPath)\n const contentOutput = await renderLiquidTemplate(content, data)\n const isExecutable = await hasExecutablePermissions(templateItemPath)\n const outputPathWithoutLiquid = outputPath.replace('.liquid', '')\n await copy(templateItemPath, outputPathWithoutLiquid)\n await write(outputPathWithoutLiquid, contentOutput)\n if (isExecutable) {\n await chmod(outputPathWithoutLiquid, 0o755)\n }\n } else {\n await copy(templateItemPath, outputPath)\n }\n }),\n )\n}\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param platform - The platform to get the username for. Defaults to the current platform.
|
|
3
|
+
* @returns The username of the current user.
|
|
4
|
+
*/
|
|
5
|
+
export declare function username(platform?: typeof process.platform): Promise<string | null>;
|
|
6
|
+
declare type PlatformArch = Exclude<typeof process.arch, 'x64' | 'ia32'> | 'amd64' | '386';
|
|
7
|
+
declare type PlatformStrings = Exclude<typeof process.platform, 'win32'> | 'windows';
|
|
8
|
+
/**
|
|
9
|
+
* Returns the platform and architecture.
|
|
10
|
+
* @returns Returns the current platform and architecture.
|
|
11
|
+
*/
|
|
12
|
+
export declare function platformAndArch(platform?: typeof process.platform, arch?: typeof process.arch): {
|
|
13
|
+
platform: PlatformStrings;
|
|
14
|
+
arch: PlatformArch;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -1,25 +1,14 @@
|
|
|
1
|
-
import { debug, content } from '
|
|
1
|
+
import { debug, content } from '../../output.js';
|
|
2
2
|
import { execa } from 'execa';
|
|
3
|
-
import { userInfo as osUserInfo
|
|
4
|
-
const getEnvironmentVariable = () => {
|
|
5
|
-
const { env } = process;
|
|
6
|
-
return env.SUDO_USER || env.C9_USER || env.LOGNAME || env.USER || env.LNAME || env.USERNAME;
|
|
7
|
-
};
|
|
8
|
-
const getUsernameFromOsUserInfo = () => {
|
|
9
|
-
try {
|
|
10
|
-
return osUserInfo().username;
|
|
11
|
-
// eslint-disable-next-line no-catch-all/no-catch-all
|
|
12
|
-
}
|
|
13
|
-
catch {
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
const cleanWindowsCommand = (value) => value.replace(/^.*\\/, '');
|
|
18
|
-
const makeUsernameFromId = (userId) => `no-username-${userId}`;
|
|
3
|
+
import { userInfo as osUserInfo } from 'os';
|
|
19
4
|
// This code has been vendored from https://github.com/sindresorhus/username
|
|
20
5
|
// because adding it as a transtive dependency causes conflicts with other
|
|
21
6
|
// packages that haven't been yet migrated to the latest version.
|
|
22
|
-
|
|
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) {
|
|
23
12
|
debug(content `Obtaining user name...`);
|
|
24
13
|
const environmentVariable = getEnvironmentVariable();
|
|
25
14
|
if (environmentVariable) {
|
|
@@ -50,23 +39,39 @@ export const username = async (platform = process.platform) => {
|
|
|
50
39
|
catch {
|
|
51
40
|
return null;
|
|
52
41
|
}
|
|
53
|
-
}
|
|
42
|
+
}
|
|
54
43
|
/**
|
|
55
44
|
* Returns the platform and architecture.
|
|
56
45
|
* @returns Returns the current platform and architecture.
|
|
57
46
|
*/
|
|
58
|
-
export
|
|
59
|
-
let
|
|
47
|
+
export function platformAndArch(platform = process.platform, arch = process.arch) {
|
|
48
|
+
let archString = arch;
|
|
60
49
|
if (arch === 'x64') {
|
|
61
|
-
|
|
50
|
+
archString = 'amd64';
|
|
62
51
|
}
|
|
63
52
|
if (arch === 'ia32') {
|
|
64
|
-
|
|
53
|
+
archString = '386';
|
|
65
54
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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;
|
|
69
69
|
}
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
}
|
|
71
|
+
function cleanWindowsCommand(value) {
|
|
72
|
+
return value.replace(/^.*\\/, '');
|
|
73
|
+
}
|
|
74
|
+
function makeUsernameFromId(userId) {
|
|
75
|
+
return `no-username-${userId}`;
|
|
76
|
+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D;KACtD;IAAC,MAAM;QACN,OAAO,IAAI,CAAA;KACZ;AACH,CAAC;AAID;;;GAGG;AACH,MAAM,UAAU,eAAe,CAC7B,WAAoC,OAAO,CAAC,QAAQ,EACpD,OAA4B,OAAO,CAAC,IAAI;IAKxC,IAAI,UAAU,GAAG,IAAI,CAAA;IACrB,IAAI,IAAI,KAAK,KAAK,EAAE;QAClB,UAAU,GAAG,OAAO,CAAA;KACrB;IACD,IAAI,IAAI,KAAK,MAAM,EAAE;QACnB,UAAU,GAAG,KAAK,CAAA;KACnB;IACD,MAAM,cAAc,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAoB,CAAA;IAC3F,OAAO,EAAC,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"]}
|
|
@@ -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 { platformAndArch } from '../../os.js';
|
|
10
10
|
import { Writable } from 'stream';
|
|
11
11
|
const RubyCLIVersion = '2.33.1';
|
|
12
|
-
const ThemeCheckVersion = '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';
|