@shopify/cli-kit 3.0.24 → 3.0.27
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/CHANGELOG.md +32 -0
- package/assets/auth-error.html +2 -4
- package/assets/empty-url.html +2 -4
- package/assets/missing-code.html +2 -4
- package/assets/missing-state.html +2 -4
- package/assets/style.css +5 -8
- package/assets/success.html +1 -1
- package/dist/abort.d.ts +1 -0
- package/dist/abort.js +2 -0
- package/dist/abort.js.map +1 -0
- package/dist/analytics.d.ts +11 -0
- package/dist/analytics.js +96 -0
- package/dist/analytics.js.map +1 -0
- package/dist/api/admin.d.ts +3 -0
- package/dist/api/admin.js +80 -0
- package/dist/api/admin.js.map +1 -0
- package/dist/api/common.d.ts +11 -0
- package/dist/api/common.js +40 -0
- package/dist/api/common.js.map +1 -0
- package/dist/api/graphql/all_app_extension_registrations.d.ts +14 -0
- package/dist/api/graphql/all_app_extension_registrations.js +14 -0
- package/dist/api/graphql/all_app_extension_registrations.js.map +1 -0
- package/dist/api/graphql/all_orgs.d.ts +12 -0
- package/dist/api/graphql/all_orgs.js +14 -0
- package/dist/api/graphql/all_orgs.js.map +1 -0
- package/dist/api/graphql/all_stores_by_org.d.ts +18 -0
- package/dist/api/graphql/all_stores_by_org.js +21 -0
- package/dist/api/graphql/all_stores_by_org.js.map +1 -0
- package/dist/api/graphql/convert_dev_to_test_store.d.ts +16 -0
- package/dist/api/graphql/convert_dev_to_test_store.js +13 -0
- package/dist/api/graphql/convert_dev_to_test_store.js.map +1 -0
- package/dist/api/graphql/create_app.d.ts +28 -0
- package/dist/api/graphql/create_app.js +32 -0
- package/dist/api/graphql/create_app.js.map +1 -0
- package/dist/api/graphql/create_deployment.d.ts +33 -0
- package/dist/api/graphql/create_deployment.js +25 -0
- package/dist/api/graphql/create_deployment.js.map +1 -0
- package/dist/api/graphql/extension_create.d.ts +30 -0
- package/dist/api/graphql/extension_create.js +26 -0
- package/dist/api/graphql/extension_create.js.map +1 -0
- package/dist/api/graphql/extension_specifications.d.ts +18 -0
- package/dist/api/graphql/extension_specifications.js +18 -0
- package/dist/api/graphql/extension_specifications.js.map +1 -0
- package/dist/api/graphql/find_app.d.ts +13 -0
- package/dist/api/graphql/find_app.js +16 -0
- package/dist/api/graphql/find_app.js.map +1 -0
- package/dist/api/graphql/find_org.d.ts +23 -0
- package/dist/api/graphql/find_org.js +26 -0
- package/dist/api/graphql/find_org.js.map +1 -0
- package/dist/api/graphql/find_org_basic.d.ts +11 -0
- package/dist/api/graphql/find_org_basic.js +14 -0
- package/dist/api/graphql/find_org_basic.js.map +1 -0
- package/dist/api/graphql/functions/app_function_set.d.ts +43 -0
- package/dist/api/graphql/functions/app_function_set.js +52 -0
- package/dist/api/graphql/functions/app_function_set.js.map +1 -0
- package/dist/api/graphql/functions/compile_module.d.ts +15 -0
- package/dist/api/graphql/functions/compile_module.js +13 -0
- package/dist/api/graphql/functions/compile_module.js.map +1 -0
- package/dist/api/graphql/functions/function_service_proxy.d.ts +4 -0
- package/dist/api/graphql/functions/function_service_proxy.js +7 -0
- package/dist/api/graphql/functions/function_service_proxy.js.map +1 -0
- package/dist/api/graphql/functions/get_app_functions.d.ts +1 -0
- package/dist/api/graphql/functions/get_app_functions.js +10 -0
- package/dist/api/graphql/functions/get_app_functions.js.map +1 -0
- package/dist/api/graphql/functions/module_compilation_status.d.ts +15 -0
- package/dist/api/graphql/functions/module_compilation_status.js +13 -0
- package/dist/api/graphql/functions/module_compilation_status.js.map +1 -0
- package/dist/api/graphql/functions/module_upload_url_generate.d.ts +18 -0
- package/dist/api/graphql/functions/module_upload_url_generate.js +17 -0
- package/dist/api/graphql/functions/module_upload_url_generate.js.map +1 -0
- package/dist/api/graphql/generate_signed_upload_url.d.ts +15 -0
- package/dist/api/graphql/generate_signed_upload_url.js +15 -0
- package/dist/api/graphql/generate_signed_upload_url.js.map +1 -0
- package/dist/api/graphql/get_variant_id.d.ts +17 -0
- package/dist/api/graphql/get_variant_id.js +20 -0
- package/dist/api/graphql/get_variant_id.js.map +1 -0
- package/dist/api/graphql/index.d.ts +21 -0
- package/dist/api/graphql/index.js +22 -0
- package/dist/api/graphql/index.js.map +1 -0
- package/dist/api/graphql/update_draft.d.ts +33 -0
- package/dist/api/graphql/update_draft.js +24 -0
- package/dist/api/graphql/update_draft.js.map +1 -0
- package/dist/api/graphql/update_urls.d.ts +14 -0
- package/dist/api/graphql/update_urls.js +12 -0
- package/dist/api/graphql/update_urls.js.map +1 -0
- package/dist/api/identity.d.ts +1 -0
- package/dist/api/identity.js +32 -0
- package/dist/api/identity.js.map +1 -0
- package/dist/api/partners.d.ts +25 -0
- package/dist/api/partners.js +100 -0
- package/dist/api/partners.js.map +1 -0
- package/dist/api.d.ts +5 -0
- package/dist/api.js +6 -0
- package/dist/api.js.map +1 -0
- package/dist/cli.d.ts +7 -0
- package/dist/cli.js +13 -0
- package/dist/cli.js.map +1 -0
- package/dist/colors.d.ts +1 -0
- package/dist/colors.js +8 -0
- package/dist/colors.js.map +1 -0
- package/dist/constants.d.ts +43 -0
- package/dist/constants.js +63 -0
- package/dist/constants.js.map +1 -0
- package/dist/dependency.d.ts +128 -0
- package/dist/dependency.js +302 -0
- package/dist/dependency.js.map +1 -0
- package/dist/environment/fqdn.d.ts +23 -0
- package/dist/environment/fqdn.js +61 -0
- package/dist/environment/fqdn.js.map +1 -0
- package/dist/environment/local.d.ts +48 -0
- package/dist/environment/local.js +82 -0
- package/dist/environment/local.js.map +1 -0
- package/dist/environment/service.d.ts +17 -0
- package/dist/environment/service.js +41 -0
- package/dist/environment/service.js.map +1 -0
- package/dist/environment/spin.d.ts +47 -0
- package/dist/environment/spin.js +83 -0
- package/dist/environment/spin.js.map +1 -0
- package/dist/environment/utilities.d.ts +6 -0
- package/dist/environment/utilities.js +12 -0
- package/dist/environment/utilities.js.map +1 -0
- package/dist/environment.d.ts +5 -0
- package/dist/environment.js +6 -0
- package/dist/environment.js.map +1 -0
- package/dist/error.d.ts +44 -0
- package/dist/error.js +91 -0
- package/dist/error.js.map +1 -0
- package/dist/file.d.ts +67 -0
- package/dist/file.js +165 -0
- package/dist/file.js.map +1 -0
- package/dist/git.d.ts +15 -0
- package/dist/git.js +48 -0
- package/dist/git.js.map +1 -0
- package/dist/github.d.ts +33 -0
- package/dist/github.js +56 -0
- package/dist/github.js.map +1 -0
- package/dist/haiku.d.ts +1 -0
- package/dist/haiku.js +8 -0
- package/dist/haiku.js.map +1 -0
- package/dist/http/fetch.d.ts +16 -0
- package/dist/http/fetch.js +18 -0
- package/dist/http/fetch.js.map +1 -0
- package/dist/http/formdata.d.ts +3 -0
- package/dist/http/formdata.js +6 -0
- package/dist/http/formdata.js.map +1 -0
- package/dist/http.d.ts +2 -0
- package/dist/http.js +3 -0
- package/dist/http.js.map +1 -0
- package/dist/id.d.ts +6 -0
- package/dist/id.js +18 -0
- package/dist/id.js.map +1 -0
- package/dist/index.d.ts +34 -2115
- package/dist/index.js +35 -46
- package/dist/index.js.map +1 -1
- package/dist/network/api.d.ts +2 -0
- package/dist/network/api.js +2 -0
- package/dist/network/api.js.map +1 -0
- package/dist/network/service.d.ts +16 -0
- package/dist/network/service.js +12 -0
- package/dist/network/service.js.map +1 -0
- package/dist/node/archiver.d.ts +6 -0
- package/dist/node/archiver.js +24 -0
- package/dist/node/archiver.js.map +1 -0
- package/dist/node/checksum.d.ts +20 -0
- package/dist/node/checksum.js +32 -0
- package/dist/node/checksum.js.map +1 -0
- package/dist/node/cli.d.ts +18 -0
- package/dist/node/cli.js +91 -0
- package/dist/node/cli.js.map +1 -0
- package/dist/node/dot-env.d.ts +33 -0
- package/dist/node/dot-env.js +36 -0
- package/dist/node/dot-env.js.map +1 -0
- package/dist/node/ruby.d.ts +30 -0
- package/dist/node/ruby.js +197 -0
- package/dist/node/ruby.js.map +1 -0
- package/dist/npm.d.ts +27 -0
- package/dist/npm.js +20 -0
- package/dist/npm.js.map +1 -0
- package/dist/os.d.ts +10 -0
- package/dist/os.js +70 -0
- package/dist/os.js.map +1 -0
- package/dist/output.d.ts +142 -0
- package/dist/output.js +505 -0
- package/dist/output.js.map +1 -0
- package/dist/path.d.ts +22 -0
- package/dist/path.js +43 -0
- package/dist/path.js.map +1 -0
- package/dist/plugins.d.ts +9 -0
- package/dist/plugins.js +12 -0
- package/dist/plugins.js.map +1 -0
- package/dist/port.d.ts +5 -0
- package/dist/port.js +13 -0
- package/dist/port.js.map +1 -0
- package/dist/schema.d.ts +1 -0
- package/dist/schema.js +2 -0
- package/dist/schema.js.map +1 -0
- package/dist/secure-store.d.ts +19 -0
- package/dist/secure-store.js +63 -0
- package/dist/secure-store.js.map +1 -0
- package/dist/semver.d.ts +3 -0
- package/dist/semver.js +6 -0
- package/dist/semver.js.map +1 -0
- package/dist/session/authorize.d.ts +7 -0
- package/dist/session/authorize.js +40 -0
- package/dist/session/authorize.js.map +1 -0
- package/dist/session/exchange.d.ts +42 -0
- package/dist/session/exchange.js +144 -0
- package/dist/session/exchange.js.map +1 -0
- package/dist/session/identity.d.ts +3 -0
- package/dist/session/identity.js +58 -0
- package/dist/session/identity.js.map +1 -0
- package/dist/session/post-auth.d.ts +13 -0
- package/dist/session/post-auth.js +56 -0
- package/dist/session/post-auth.js.map +1 -0
- package/dist/session/redirect-listener.d.ts +34 -0
- package/dist/session/redirect-listener.js +97 -0
- package/dist/session/redirect-listener.js.map +1 -0
- package/dist/session/schema.d.ts +174 -0
- package/dist/session/schema.js +59 -0
- package/dist/session/schema.js.map +1 -0
- package/dist/session/scopes.d.ts +16 -0
- package/dist/session/scopes.js +53 -0
- package/dist/session/scopes.js.map +1 -0
- package/dist/session/store.d.ts +24 -0
- package/dist/session/store.js +88 -0
- package/dist/session/store.js.map +1 -0
- package/dist/session/token.d.ts +40 -0
- package/dist/session/token.js +22 -0
- package/dist/session/token.js.map +1 -0
- package/dist/session/validate.d.ts +17 -0
- package/dist/session/validate.js +75 -0
- package/dist/session/validate.js.map +1 -0
- package/dist/session.d.ts +88 -0
- package/dist/session.js +251 -0
- package/dist/session.js.map +1 -0
- package/dist/store/schema.d.ts +3 -0
- package/dist/store/schema.js +27 -0
- package/dist/store/schema.js.map +1 -0
- package/dist/store.d.ts +32 -0
- package/dist/store.js +102 -0
- package/dist/store.js.map +1 -0
- package/dist/string.d.ts +22 -0
- package/dist/string.js +38 -0
- package/dist/string.js.map +1 -0
- package/dist/system.d.ts +53 -0
- package/dist/system.js +109 -0
- package/dist/system.js.map +1 -0
- package/dist/template.d.ts +11 -0
- package/dist/template.js +50 -0
- package/dist/template.js.map +1 -0
- package/dist/testing/output.d.ts +9 -0
- package/dist/testing/output.js +15 -0
- package/dist/testing/output.js.map +1 -0
- package/dist/testing/store.d.ts +7 -0
- package/dist/testing/store.js +26 -0
- package/dist/testing/store.js.map +1 -0
- package/dist/toml.d.ts +3 -0
- package/dist/toml.js +8 -0
- package/dist/toml.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/ui/autocomplete.d.ts +7 -0
- package/dist/ui/autocomplete.js +43 -0
- package/dist/ui/autocomplete.js.map +1 -0
- package/dist/ui/input.d.ts +7 -0
- package/dist/ui/input.js +48 -0
- package/dist/ui/input.js.map +1 -0
- package/dist/ui/select.d.ts +6 -0
- package/dist/ui/select.js +30 -0
- package/dist/ui/select.js.map +1 -0
- package/dist/ui.d.ts +36 -0
- package/dist/ui.js +124 -0
- package/dist/ui.js.map +1 -0
- package/dist/version.d.ts +19 -0
- package/dist/version.js +34 -0
- package/dist/version.js.map +1 -0
- package/dist/vscode.d.ts +8 -0
- package/dist/vscode.js +36 -0
- package/dist/vscode.js.map +1 -0
- package/dist/yaml.d.ts +2 -0
- package/dist/yaml.js +8 -0
- package/dist/yaml.js.map +1 -0
- package/package.json +32 -21
- package/dist/index-eb280c22.js +0 -175294
- package/dist/index-eb280c22.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/multipart-parser-84c10b92.js +0 -477
- package/dist/multipart-parser-84c10b92.js.map +0 -1
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import * as file from '../file.js';
|
|
2
|
+
import * as ui from '../ui.js';
|
|
3
|
+
import * as system from '../system.js';
|
|
4
|
+
import { Abort } from '../error.js';
|
|
5
|
+
import { glob, join } from '../path.js';
|
|
6
|
+
import constants from '../constants.js';
|
|
7
|
+
import { coerce } from '../semver.js';
|
|
8
|
+
import { content, token } from '../output.js';
|
|
9
|
+
// eslint-disable-next-line no-restricted-imports
|
|
10
|
+
import { spawn } from 'child_process';
|
|
11
|
+
import { Writable } from 'node:stream';
|
|
12
|
+
const RubyCLIVersion = '2.16.0';
|
|
13
|
+
const ThemeCheckVersion = '1.10.2';
|
|
14
|
+
const MinBundlerVersion = '2.3.8';
|
|
15
|
+
const MinRubyVersion = '2.3.0';
|
|
16
|
+
const MinRubyGemVersion = '2.5.0';
|
|
17
|
+
/**
|
|
18
|
+
* Execute CLI 2.0 commands.
|
|
19
|
+
* Installs a version of RubyCLI as a vendor dependency in a hidden folder in the system.
|
|
20
|
+
* User must have a valid ruby+bundler environment to run any command.
|
|
21
|
+
*
|
|
22
|
+
* @param args {string[]} List of argumets to execute. (ex: ['theme', 'pull'])
|
|
23
|
+
* @param adminSession {AdminSession} Contains token and store to pass to CLI 2.0, which will be set as environment variables
|
|
24
|
+
*/
|
|
25
|
+
export async function execCLI2(args, adminSession) {
|
|
26
|
+
await installCLIDependencies();
|
|
27
|
+
const env = {
|
|
28
|
+
...process.env,
|
|
29
|
+
SHOPIFY_CLI_ADMIN_AUTH_TOKEN: adminSession?.token,
|
|
30
|
+
SHOPIFY_CLI_STORE: adminSession?.storeFqdn,
|
|
31
|
+
};
|
|
32
|
+
spawn('bundle', ['exec', 'shopify'].concat(args), {
|
|
33
|
+
stdio: 'inherit',
|
|
34
|
+
cwd: shopifyCLIDirectory(),
|
|
35
|
+
shell: true,
|
|
36
|
+
env,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* A function that installs (if needed) and runs the theme-check CLI.
|
|
41
|
+
* @param options {ExecThemeCheckCLIOptions} Options to customize the execution of theme-check.
|
|
42
|
+
* @returns {Promise<void>} A promise that resolves or rejects depending on the result of the underlying theme-check process.
|
|
43
|
+
*/
|
|
44
|
+
export async function execThemeCheckCLI({ directories, args, stdout, stderr, }) {
|
|
45
|
+
await installThemeCheckCLIDependencies(stdout);
|
|
46
|
+
const processes = directories.map(async (directory) => {
|
|
47
|
+
// Check that there are files aside from the extension TOML config file,
|
|
48
|
+
// otherwise theme-check will return a false failure.
|
|
49
|
+
const files = await glob(join(directory, '/**/*'));
|
|
50
|
+
const fileCount = files.filter((file) => !file.match(/\.toml$/)).length;
|
|
51
|
+
if (fileCount === 0)
|
|
52
|
+
return;
|
|
53
|
+
const customStderr = new Writable({
|
|
54
|
+
write(chunk, ...args) {
|
|
55
|
+
// For some reason, theme-check reports this initial status line to stderr
|
|
56
|
+
// See https://github.com/Shopify/theme-check/blob/1092737cfb58a73ca397ffb1371665dc55df2976/lib/theme_check/language_server/diagnostics_engine.rb#L31
|
|
57
|
+
// which leads to https://github.com/Shopify/theme-check/blob/1092737cfb58a73ca397ffb1371665dc55df2976/lib/theme_check/language_server/io_messenger.rb#L65
|
|
58
|
+
if (chunk.toString('ascii').match(/^Checking/)) {
|
|
59
|
+
stdout.write(chunk, ...args);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
stderr.write(chunk, ...args);
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
await system.exec('bundle', ['exec', 'theme-check'].concat([directory, ...(args || [])]), {
|
|
67
|
+
stdout,
|
|
68
|
+
stderr: customStderr,
|
|
69
|
+
cwd: themeCheckDirectory(),
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
return Promise.all(processes);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Validate Ruby Enviroment
|
|
76
|
+
* Install Theme Check CLI and its dependencies
|
|
77
|
+
* Shows a loading message if it's the first time installing dependencies
|
|
78
|
+
* or if we are installing a new version of Theme Check CLI
|
|
79
|
+
*/
|
|
80
|
+
async function installThemeCheckCLIDependencies(stdout) {
|
|
81
|
+
const exists = await file.exists(themeCheckDirectory());
|
|
82
|
+
if (!exists)
|
|
83
|
+
stdout.write('Installing theme dependencies...');
|
|
84
|
+
const list = ui.newListr([
|
|
85
|
+
{
|
|
86
|
+
title: 'Installing theme dependencies',
|
|
87
|
+
task: async () => {
|
|
88
|
+
await validateRubyEnv();
|
|
89
|
+
await createThemeCheckCLIWorkingDirectory();
|
|
90
|
+
await createThemeCheckGemfile();
|
|
91
|
+
await bundleInstallThemeCheck();
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
], { renderer: 'silent' });
|
|
95
|
+
await list.run();
|
|
96
|
+
if (!exists)
|
|
97
|
+
stdout.write('Installed theme dependencies!');
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Validate Ruby Enviroment
|
|
101
|
+
* Install RubyCLI and its dependencies
|
|
102
|
+
* Shows a loading spinner if it's the first time installing dependencies
|
|
103
|
+
* or if we are installing a new version of RubyCLI
|
|
104
|
+
*/
|
|
105
|
+
async function installCLIDependencies() {
|
|
106
|
+
const exists = await file.exists(shopifyCLIDirectory());
|
|
107
|
+
const renderer = exists ? 'silent' : 'default';
|
|
108
|
+
const list = ui.newListr([
|
|
109
|
+
{
|
|
110
|
+
title: 'Installing theme dependencies',
|
|
111
|
+
task: async () => {
|
|
112
|
+
await validateRubyEnv();
|
|
113
|
+
await createShopifyCLIWorkingDirectory();
|
|
114
|
+
await createShopifyCLIGemfile();
|
|
115
|
+
await bundleInstallShopifyCLI();
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
], { renderer });
|
|
119
|
+
await list.run();
|
|
120
|
+
}
|
|
121
|
+
async function validateRubyEnv() {
|
|
122
|
+
await validateRuby();
|
|
123
|
+
await validateRubyGems();
|
|
124
|
+
await validateBundler();
|
|
125
|
+
}
|
|
126
|
+
async function validateRuby() {
|
|
127
|
+
let version;
|
|
128
|
+
try {
|
|
129
|
+
const stdout = await system.captureOutput('ruby', ['-v']);
|
|
130
|
+
version = coerce(stdout);
|
|
131
|
+
}
|
|
132
|
+
catch {
|
|
133
|
+
throw new Abort('Ruby environment not found', `Make sure you have Ruby installed on your system: ${content `${token.link('', 'https://www.ruby-lang.org/en/documentation/installation/')}`.value}`);
|
|
134
|
+
}
|
|
135
|
+
const isValid = version?.compare(MinRubyVersion);
|
|
136
|
+
if (isValid === -1 || isValid === undefined) {
|
|
137
|
+
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('', 'https://www.ruby-lang.org/en/documentation/installation/')}`.value}`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
async function validateRubyGems() {
|
|
141
|
+
const stdout = await system.captureOutput('gem', ['-v']);
|
|
142
|
+
const version = coerce(stdout);
|
|
143
|
+
const isValid = version?.compare(MinRubyGemVersion);
|
|
144
|
+
if (isValid === -1 || isValid === undefined) {
|
|
145
|
+
throw new Abort(`RubyGems version ${content `${token.yellow(version.raw)}`.value} is not supported`, `To update to the latest version of RubyGems, run ${content `${token.genericShellCommand('gem update --system')}`.value}`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
async function validateBundler() {
|
|
149
|
+
let version;
|
|
150
|
+
try {
|
|
151
|
+
const stdout = await system.captureOutput('bundler', ['-v']);
|
|
152
|
+
version = coerce(stdout);
|
|
153
|
+
}
|
|
154
|
+
catch {
|
|
155
|
+
throw new Abort('Bundler not found', `To install the latest version of Bundler, run ${content `${token.genericShellCommand('gem install bundler')}`.value}`);
|
|
156
|
+
}
|
|
157
|
+
const isValid = version?.compare(MinBundlerVersion);
|
|
158
|
+
if (isValid === -1 || isValid === undefined) {
|
|
159
|
+
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('gem install bundler')}`.value}`);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
function createShopifyCLIWorkingDirectory() {
|
|
163
|
+
return file.mkdir(shopifyCLIDirectory());
|
|
164
|
+
}
|
|
165
|
+
function createThemeCheckCLIWorkingDirectory() {
|
|
166
|
+
return file.mkdir(themeCheckDirectory());
|
|
167
|
+
}
|
|
168
|
+
async function createShopifyCLIGemfile() {
|
|
169
|
+
const gemPath = join(shopifyCLIDirectory(), 'Gemfile');
|
|
170
|
+
await file.write(gemPath, `source 'https://rubygems.org'\ngem 'shopify-cli', '${RubyCLIVersion}'`);
|
|
171
|
+
}
|
|
172
|
+
async function createThemeCheckGemfile() {
|
|
173
|
+
const gemPath = join(themeCheckDirectory(), 'Gemfile');
|
|
174
|
+
await file.write(gemPath, `source 'https://rubygems.org'\ngem 'theme-check', '${ThemeCheckVersion}'`);
|
|
175
|
+
}
|
|
176
|
+
async function bundleInstallShopifyCLI() {
|
|
177
|
+
await system.exec('bundle', ['config', 'set', '--local', 'path', shopifyCLIDirectory()], { cwd: shopifyCLIDirectory() });
|
|
178
|
+
await system.exec('bundle', ['install'], { cwd: shopifyCLIDirectory() });
|
|
179
|
+
}
|
|
180
|
+
async function bundleInstallThemeCheck() {
|
|
181
|
+
await system.exec('bundle', ['config', 'set', '--local', 'path', themeCheckDirectory()], { cwd: themeCheckDirectory() });
|
|
182
|
+
await system.exec('bundle', ['install'], { cwd: themeCheckDirectory() });
|
|
183
|
+
}
|
|
184
|
+
function shopifyCLIDirectory() {
|
|
185
|
+
return join(constants.paths.directories.cache.vendor.path(), 'ruby-cli', RubyCLIVersion);
|
|
186
|
+
}
|
|
187
|
+
function themeCheckDirectory() {
|
|
188
|
+
return join(constants.paths.directories.cache.vendor.path(), 'theme-check', ThemeCheckVersion);
|
|
189
|
+
}
|
|
190
|
+
export async function version() {
|
|
191
|
+
const parseOutput = (version) => version.match(/ruby (\d+\.\d+\.\d+)/)?.[1];
|
|
192
|
+
return system
|
|
193
|
+
.captureOutput('ruby', ['-v'])
|
|
194
|
+
.then(parseOutput)
|
|
195
|
+
.catch(() => undefined);
|
|
196
|
+
}
|
|
197
|
+
//# sourceMappingURL=ruby.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ruby.js","sourceRoot":"","sources":["../../src/node/ruby.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,YAAY,CAAA;AAClC,OAAO,KAAK,EAAE,MAAM,UAAU,CAAA;AAC9B,OAAO,KAAK,MAAM,MAAM,cAAc,CAAA;AACtC,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAA;AACjC,OAAO,EAAC,IAAI,EAAE,IAAI,EAAC,MAAM,YAAY,CAAA;AACrC,OAAO,SAAS,MAAM,iBAAiB,CAAA;AACvC,OAAO,EAAC,MAAM,EAAC,MAAM,cAAc,CAAA;AAEnC,OAAO,EAAC,OAAO,EAAE,KAAK,EAAC,MAAM,cAAc,CAAA;AAC3C,iDAAiD;AACjD,OAAO,EAAC,KAAK,EAAC,MAAM,eAAe,CAAA;AACnC,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,MAAM,iBAAiB,GAAG,OAAO,CAAA;AAEjC;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,IAAc,EAAE,YAA2B;IACxE,MAAM,sBAAsB,EAAE,CAAA;IAC9B,MAAM,GAAG,GAAG;QACV,GAAG,OAAO,CAAC,GAAG;QACd,4BAA4B,EAAE,YAAY,EAAE,KAAK;QACjD,iBAAiB,EAAE,YAAY,EAAE,SAAS;KAC3C,CAAA;IAED,KAAK,CAAC,QAAQ,EAAE,CAAC,MAA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,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,SAAS,CAAC,EAAE,EAAC,GAAG,EAAE,mBAAmB,EAAE,EAAC,CAAC,CAAA;AACxE,CAAC;AAED,SAAS,mBAAmB;IAC1B,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,UAAU,EAAE,cAAc,CAAC,CAAA;AAC1F,CAAC;AAED,SAAS,mBAAmB;IAC1B,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,aAAa,EAAE,iBAAiB,CAAC,CAAA;AAChG,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,OAAO;IAC3B,MAAM,WAAW,GAAG,CAAC,OAAe,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,sBAAsB,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;IACnF,OAAO,MAAM;SACV,aAAa,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,CAAC;SAC7B,IAAI,CAAC,WAAW,CAAC;SACjB,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAA;AAC3B,CAAC","sourcesContent":["import * as file from '../file.js'\nimport * as ui from '../ui.js'\nimport * as system from '../system.js'\nimport {Abort} from '../error.js'\nimport {glob, join} from '../path.js'\nimport constants from '../constants.js'\nimport {coerce} from '../semver.js'\nimport {AdminSession} from '../session.js'\nimport {content, token} from '../output.js'\n// eslint-disable-next-line no-restricted-imports\nimport {spawn} from 'child_process'\nimport {Writable} from 'node:stream'\n\nconst RubyCLIVersion = '2.16.0'\nconst ThemeCheckVersion = '1.10.2'\nconst MinBundlerVersion = '2.3.8'\nconst MinRubyVersion = '2.3.0'\nconst MinRubyGemVersion = '2.5.0'\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 {string[]} List of argumets to execute. (ex: ['theme', 'pull'])\n * @param adminSession {AdminSession} Contains token and store to pass to CLI 2.0, which will be set as environment variables\n */\nexport async function execCLI2(args: string[], adminSession?: AdminSession) {\n await installCLIDependencies()\n const env = {\n ...process.env,\n SHOPIFY_CLI_ADMIN_AUTH_TOKEN: adminSession?.token,\n SHOPIFY_CLI_STORE: adminSession?.storeFqdn,\n }\n\n spawn('bundle', ['exec', 'shopify'].concat(args), {\n stdio: 'inherit',\n cwd: shopifyCLIDirectory(),\n shell: true,\n env,\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 {ExecThemeCheckCLIOptions} Options to customize the execution of theme-check.\n * @returns {Promise<void>} 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('bundle', ['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 await validateRubyEnv()\n await createShopifyCLIWorkingDirectory()\n await createShopifyCLIGemfile()\n await bundleInstallShopifyCLI()\n },\n },\n ],\n {renderer},\n )\n await list.run()\n}\n\nasync function validateRubyEnv() {\n await validateRuby()\n await validateRubyGems()\n await validateBundler()\n}\n\nasync function validateRuby() {\n let version\n try {\n const stdout = await system.captureOutput('ruby', ['-v'])\n version = coerce(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('', '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('', 'https://www.ruby-lang.org/en/documentation/installation/')}`.value\n }`,\n )\n }\n}\n\nasync function validateRubyGems() {\n const stdout = await system.captureOutput('gem', ['-v'])\n const version = coerce(stdout)\n\n const isValid = version?.compare(MinRubyGemVersion)\n if (isValid === -1 || isValid === undefined) {\n throw new Abort(\n `RubyGems version ${content`${token.yellow(version!.raw)}`.value} is not supported`,\n `To update to the latest version of RubyGems, run ${\n content`${token.genericShellCommand('gem update --system')}`.value\n }`,\n )\n }\n}\n\nasync function validateBundler() {\n let version\n try {\n const stdout = await system.captureOutput('bundler', ['-v'])\n version = coerce(stdout)\n } catch {\n throw new Abort(\n 'Bundler not found',\n `To install the latest version of Bundler, run ${\n content`${token.genericShellCommand('gem 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('gem 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 await file.write(gemPath, `source 'https://rubygems.org'\\ngem 'shopify-cli', '${RubyCLIVersion}'`)\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 bundleInstallShopifyCLI() {\n await system.exec('bundle', ['config', 'set', '--local', 'path', shopifyCLIDirectory()], {cwd: shopifyCLIDirectory()})\n await system.exec('bundle', ['install'], {cwd: shopifyCLIDirectory()})\n}\n\nasync function bundleInstallThemeCheck() {\n await system.exec('bundle', ['config', 'set', '--local', 'path', themeCheckDirectory()], {cwd: themeCheckDirectory()})\n await system.exec('bundle', ['install'], {cwd: themeCheckDirectory()})\n}\n\nfunction shopifyCLIDirectory() {\n return join(constants.paths.directories.cache.vendor.path(), 'ruby-cli', RubyCLIVersion)\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('ruby', ['-v'])\n .then(parseOutput)\n .catch(() => undefined)\n}\n"]}
|
package/dist/npm.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
interface JSON {
|
|
2
|
+
[key: string]: JSONValue;
|
|
3
|
+
}
|
|
4
|
+
declare type JSONValue = string | number | boolean | JSON | JSONValue[];
|
|
5
|
+
export interface PackageJSON extends JSON {
|
|
6
|
+
name: string;
|
|
7
|
+
author: string;
|
|
8
|
+
dependencies: {
|
|
9
|
+
[key: string]: string;
|
|
10
|
+
};
|
|
11
|
+
devDependencies: {
|
|
12
|
+
[key: string]: string;
|
|
13
|
+
};
|
|
14
|
+
resolutions: {
|
|
15
|
+
[key: string]: string;
|
|
16
|
+
};
|
|
17
|
+
overrides: {
|
|
18
|
+
[key: string]: string;
|
|
19
|
+
};
|
|
20
|
+
scripts: {
|
|
21
|
+
[key: string]: string;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export declare function readPackageJSON(directory: string): Promise<PackageJSON>;
|
|
25
|
+
export declare function writePackageJSON(directory: string, packageJSON: JSON): Promise<void>;
|
|
26
|
+
export declare function updateAppData(packageJSON: JSON, name: string): Promise<void>;
|
|
27
|
+
export {};
|
package/dist/npm.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { join } from './path.js';
|
|
2
|
+
import * as file from './file.js';
|
|
3
|
+
import * as os from './os.js';
|
|
4
|
+
import { debug, token, content } from './output.js';
|
|
5
|
+
export async function readPackageJSON(directory) {
|
|
6
|
+
debug(content `Reading and decoding the content from package.json at ${token.path(directory)}...`);
|
|
7
|
+
const packagePath = join(directory, 'package.json');
|
|
8
|
+
const packageJSON = JSON.parse(await file.read(packagePath));
|
|
9
|
+
return packageJSON;
|
|
10
|
+
}
|
|
11
|
+
export async function writePackageJSON(directory, packageJSON) {
|
|
12
|
+
debug(content `JSON-encoding and writing content to package.json at ${token.path(directory)}...`);
|
|
13
|
+
const packagePath = join(directory, 'package.json');
|
|
14
|
+
await file.write(packagePath, JSON.stringify(packageJSON, null, 2));
|
|
15
|
+
}
|
|
16
|
+
export async function updateAppData(packageJSON, name) {
|
|
17
|
+
packageJSON.name = name;
|
|
18
|
+
packageJSON.author = (await os.username()) ?? '';
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=npm.js.map
|
package/dist/npm.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"npm.js","sourceRoot":"","sources":["../src/npm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAA;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAA;AAC7B,OAAO,EAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAC,MAAM,aAAa,CAAA;AAkBjD,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,SAAiB;IACrD,KAAK,CAAC,OAAO,CAAA,yDAAyD,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;IACjG,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,CAAA;IACnD,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAA;IAE5D,OAAO,WAAW,CAAA;AACpB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,SAAiB,EAAE,WAAiB;IACzE,KAAK,CAAC,OAAO,CAAA,wDAAwD,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;IAChG,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,CAAA;IACnD,MAAM,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAA;AACrE,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,WAAiB,EAAE,IAAY;IACjE,WAAW,CAAC,IAAI,GAAG,IAAI,CAAA;IACvB,WAAW,CAAC,MAAM,GAAG,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAA;AAClD,CAAC","sourcesContent":["import {join} from './path.js'\nimport * as file from './file.js'\nimport * as os from './os.js'\nimport {debug, token, content} from './output.js'\n\ninterface JSON {\n [key: string]: JSONValue\n}\n\ntype JSONValue = string | number | boolean | JSON | JSONValue[]\n\nexport interface PackageJSON extends JSON {\n name: string\n author: string\n dependencies: {[key: string]: string}\n devDependencies: {[key: string]: string}\n resolutions: {[key: string]: string}\n overrides: {[key: string]: string}\n scripts: {[key: string]: string}\n}\n\nexport async function readPackageJSON(directory: string): Promise<PackageJSON> {\n debug(content`Reading and decoding the content from package.json at ${token.path(directory)}...`)\n const packagePath = join(directory, 'package.json')\n const packageJSON = JSON.parse(await file.read(packagePath))\n\n return packageJSON\n}\n\nexport async function writePackageJSON(directory: string, packageJSON: JSON): Promise<void> {\n debug(content`JSON-encoding and writing content to package.json at ${token.path(directory)}...`)\n const packagePath = join(directory, 'package.json')\n await file.write(packagePath, JSON.stringify(packageJSON, null, 2))\n}\n\nexport async function updateAppData(packageJSON: JSON, name: string): Promise<void> {\n packageJSON.name = name\n packageJSON.author = (await os.username()) ?? ''\n}\n"]}
|
package/dist/os.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { platform as processPlatform } from 'node:process';
|
|
2
|
+
export declare const username: (platform?: typeof processPlatform) => Promise<string | null>;
|
|
3
|
+
/**
|
|
4
|
+
* Returns the platform and architecture.
|
|
5
|
+
* @returns {{platform: string, arch: string}} Returns the current platform and architecture.
|
|
6
|
+
*/
|
|
7
|
+
export declare const platformAndArch: (platform?: typeof processPlatform) => {
|
|
8
|
+
platform: string;
|
|
9
|
+
arch: string;
|
|
10
|
+
};
|
package/dist/os.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { debug, content } from './output.js';
|
|
2
|
+
import { execa } from 'execa';
|
|
3
|
+
import { platform as processPlatform } from 'node:process';
|
|
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}`;
|
|
20
|
+
// This code has been vendored from https://github.com/sindresorhus/username
|
|
21
|
+
// because adding it as a transtive dependency causes conflicts with other
|
|
22
|
+
// packages that haven't been yet migrated to the latest version.
|
|
23
|
+
export const username = async (platform = processPlatform) => {
|
|
24
|
+
debug(content `Obtaining user name...`);
|
|
25
|
+
const environmentVariable = getEnvironmentVariable();
|
|
26
|
+
if (environmentVariable) {
|
|
27
|
+
return environmentVariable;
|
|
28
|
+
}
|
|
29
|
+
const userInfoUsername = getUsernameFromOsUserInfo();
|
|
30
|
+
if (userInfoUsername) {
|
|
31
|
+
return userInfoUsername;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
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.
|
|
35
|
+
*/
|
|
36
|
+
try {
|
|
37
|
+
if (platform === 'win32') {
|
|
38
|
+
const { stdout } = await execa('whoami');
|
|
39
|
+
return cleanWindowsCommand(stdout);
|
|
40
|
+
}
|
|
41
|
+
const { stdout: userId } = await execa('id', ['-u']);
|
|
42
|
+
try {
|
|
43
|
+
const { stdout } = await execa('id', ['-un', userId]);
|
|
44
|
+
return stdout;
|
|
45
|
+
// eslint-disable-next-line no-catch-all/no-catch-all,no-empty
|
|
46
|
+
}
|
|
47
|
+
catch { }
|
|
48
|
+
return makeUsernameFromId(userId);
|
|
49
|
+
// eslint-disable-next-line no-catch-all/no-catch-all
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Returns the platform and architecture.
|
|
57
|
+
* @returns {{platform: string, arch: string}} Returns the current platform and architecture.
|
|
58
|
+
*/
|
|
59
|
+
export const platformAndArch = (platform = processPlatform) => {
|
|
60
|
+
let arch = osArch();
|
|
61
|
+
if (arch === 'x64') {
|
|
62
|
+
arch = 'amd64';
|
|
63
|
+
}
|
|
64
|
+
let platformString = platform;
|
|
65
|
+
if (platform.match(/^win.+/)) {
|
|
66
|
+
platformString = 'windows';
|
|
67
|
+
}
|
|
68
|
+
return { platform: platformString, arch };
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=os.js.map
|
package/dist/os.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"os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AG,yBAAyB,EAAE,CAAA;IACpD,IAAI,gBAAgB,EAAE;QACpB,OAAO,gBAAgB,CAAA;KACxB;IAED;;QAEC;IACD,IAAI;QACF,IAAI,QAAQ,KAAK,OAAO,EAAE;YACxB,MAAM,EAAC,MAAM,EAAC,GAAG,MAAM,KAAK,CAAC,QAAQ,CAAC,CAAA;YACtC,OAAO,mBAAmB,CAAC,MAAM,CAAC,CAAA;SACnC;QAED,MAAM,EAAC,MAAM,EAAE,MAAM,EAAC,GAAG,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,CAAC,CAAA;QAClD,IAAI;YACF,MAAM,EAAC,MAAM,EAAC,GAAG,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAA;YACnD,OAAO,MAAM,CAAA;YAEb,8DAA8D;SAC/D;QAAC,MAAM,GAAE;QACV,OAAO,kBAAkB,CAAC,MAAM,CAAC,CAAA;QACjC,qDAAqD;KACtD;IAAC,MAAM;QACN,OAAO,IAAI,CAAA;KACZ;AACH,CAAC,CAAA;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,WAAmC,eAAe,EAChB,EAAE;IACpC,IAAI,IAAI,GAAG,MAAM,EAAE,CAAA;IACnB,IAAI,IAAI,KAAK,KAAK,EAAE;QAClB,IAAI,GAAG,OAAO,CAAA;KACf;IACD,IAAI,cAAc,GAAG,QAAkB,CAAA;IACvC,IAAI,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE;QAC5B,cAAc,GAAG,SAAS,CAAA;KAC3B;IACD,OAAO,EAAC,QAAQ,EAAE,cAAc,EAAE,IAAI,EAAC,CAAA;AACzC,CAAC,CAAA","sourcesContent":["import {debug, content} from './output.js'\nimport {execa} from 'execa'\nimport {platform as processPlatform} from 'node:process'\nimport {userInfo as osUserInfo, arch as osArch} from 'node:os'\n\nconst getEnvironmentVariable = () => {\n const {env} = process\n\n return env.SUDO_USER || env.C9_USER || env.LOGNAME || env.USER || env.LNAME || env.USERNAME\n}\n\nconst 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\nconst cleanWindowsCommand = (value: string) => value.replace(/^.*\\\\/, '')\n\nconst makeUsernameFromId = (userId: string) => `no-username-${userId}`\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.\nexport const username = async (platform: typeof processPlatform = processPlatform): 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\tFirst 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\t*/\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\n/**\n * Returns the platform and architecture.\n * @returns {{platform: string, arch: string}} Returns the current platform and architecture.\n */\nexport const platformAndArch = (\n platform: typeof processPlatform = processPlatform,\n): {platform: string; arch: string} => {\n let arch = osArch()\n if (arch === 'x64') {\n arch = 'amd64'\n }\n let platformString = platform as string\n if (platform.match(/^win.+/)) {\n platformString = 'windows'\n }\n return {platform: platformString, arch}\n}\n"]}
|
package/dist/output.d.ts
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Fatal } from './error.js';
|
|
3
|
+
import { DependencyManager } from './dependency.js';
|
|
4
|
+
import { AbortSignal } from 'abort-controller';
|
|
5
|
+
import { Writable } from 'node:stream';
|
|
6
|
+
export declare function initiateLogging({ logDir, filename, }: {
|
|
7
|
+
logDir?: string;
|
|
8
|
+
filename?: string;
|
|
9
|
+
}): void;
|
|
10
|
+
declare enum ContentTokenType {
|
|
11
|
+
Raw = 0,
|
|
12
|
+
Command = 1,
|
|
13
|
+
Json = 2,
|
|
14
|
+
Path = 3,
|
|
15
|
+
Link = 4,
|
|
16
|
+
Heading = 5,
|
|
17
|
+
SubHeading = 6,
|
|
18
|
+
Italic = 7,
|
|
19
|
+
ErrorText = 8,
|
|
20
|
+
Yellow = 9,
|
|
21
|
+
Cyan = 10,
|
|
22
|
+
Magenta = 11,
|
|
23
|
+
Green = 12
|
|
24
|
+
}
|
|
25
|
+
interface ContentMetadata {
|
|
26
|
+
link?: string;
|
|
27
|
+
}
|
|
28
|
+
declare class ContentToken {
|
|
29
|
+
type: ContentTokenType;
|
|
30
|
+
value: Message;
|
|
31
|
+
metadata: ContentMetadata;
|
|
32
|
+
constructor(value: Message, metadata: ContentMetadata | undefined, type: ContentTokenType);
|
|
33
|
+
}
|
|
34
|
+
export declare const token: {
|
|
35
|
+
raw: (value: Message) => ContentToken;
|
|
36
|
+
genericShellCommand: (value: Message) => ContentToken;
|
|
37
|
+
json: (value: any) => ContentToken;
|
|
38
|
+
path: (value: Message) => ContentToken;
|
|
39
|
+
link: (value: Message, link: string) => ContentToken;
|
|
40
|
+
heading: (value: Message) => ContentToken;
|
|
41
|
+
subheading: (value: Message) => ContentToken;
|
|
42
|
+
italic: (value: Message) => ContentToken;
|
|
43
|
+
errorText: (value: Message) => ContentToken;
|
|
44
|
+
cyan: (value: Message) => ContentToken;
|
|
45
|
+
yellow: (value: Message) => ContentToken;
|
|
46
|
+
magenta: (value: Message) => ContentToken;
|
|
47
|
+
green: (value: Message) => ContentToken;
|
|
48
|
+
packagejsonScript: (dependencyManager: DependencyManager, scriptName: string, ...scriptArgs: string[]) => ContentToken;
|
|
49
|
+
successIcon: () => ContentToken;
|
|
50
|
+
failIcon: () => ContentToken;
|
|
51
|
+
};
|
|
52
|
+
export declare class TokenizedString {
|
|
53
|
+
value: string;
|
|
54
|
+
constructor(value: string);
|
|
55
|
+
}
|
|
56
|
+
export declare type Message = string | TokenizedString;
|
|
57
|
+
export declare function content(strings: TemplateStringsArray, ...keys: (ContentToken | string)[]): TokenizedString;
|
|
58
|
+
/** Log levels */
|
|
59
|
+
export declare type LogLevel = 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace' | 'silent';
|
|
60
|
+
/**
|
|
61
|
+
*
|
|
62
|
+
* @returns {LogLevel} It returns the log level set by the user.
|
|
63
|
+
*/
|
|
64
|
+
export declare const currentLogLevel: () => LogLevel;
|
|
65
|
+
export declare const shouldOutput: (logLevel: LogLevel) => boolean;
|
|
66
|
+
export declare let collectedLogs: {
|
|
67
|
+
[key: string]: string[];
|
|
68
|
+
};
|
|
69
|
+
export declare const clearCollectedLogs: () => void;
|
|
70
|
+
/**
|
|
71
|
+
* Ouputs information to the user. This is akin to "console.log"
|
|
72
|
+
* Info messages don't get additional formatting.
|
|
73
|
+
* Note: Info messages are sent through the standard output.
|
|
74
|
+
* @param content {string} The content to be output to the user.
|
|
75
|
+
*/
|
|
76
|
+
export declare const info: (content: Message) => void;
|
|
77
|
+
/**
|
|
78
|
+
* Outputs a success message to the user.
|
|
79
|
+
* Success message receive a special formatting to make them stand out in the console.
|
|
80
|
+
* Note: Success messages are sent through the standard output.
|
|
81
|
+
* @param content {string} The content to be output to the user.
|
|
82
|
+
*/
|
|
83
|
+
export declare const success: (content: Message) => void;
|
|
84
|
+
/**
|
|
85
|
+
* Outputs a completed message to the user.
|
|
86
|
+
* Completed message receive a special formatting to make them stand out in the console.
|
|
87
|
+
* Note: Completed messages are sent through the standard output.
|
|
88
|
+
* @param content {string} The content to be output to the user.
|
|
89
|
+
*/
|
|
90
|
+
export declare const completed: (content: Message) => void;
|
|
91
|
+
/**
|
|
92
|
+
* Ouputs debug information to the user. By default these output is hidden unless the user calls the CLI with --verbose.
|
|
93
|
+
* Debug messages don't get additional formatting.
|
|
94
|
+
* Note: Debug messages are sent through the standard output.
|
|
95
|
+
* @param content {string} The content to be output to the user.
|
|
96
|
+
*/
|
|
97
|
+
export declare const debug: (content: Message) => void;
|
|
98
|
+
/**
|
|
99
|
+
* Outputs a warning message to the user.
|
|
100
|
+
* Warning messages receive a special formatting to make them stand out in the console.
|
|
101
|
+
* Note: Warning messages are sent through the standard output.
|
|
102
|
+
* @param content {string} The content to be output to the user.
|
|
103
|
+
*/
|
|
104
|
+
export declare const warn: (content: Message) => void;
|
|
105
|
+
/**
|
|
106
|
+
* Prints a new line in the terminal.
|
|
107
|
+
*/
|
|
108
|
+
export declare const newline: () => void;
|
|
109
|
+
/**
|
|
110
|
+
* Formats and outputs a fatal error.
|
|
111
|
+
* Note: This API is not intended to be used internally. If you want to
|
|
112
|
+
* abort the execution due to an error, raise a fatal error and let the
|
|
113
|
+
* error handler handle and format it.
|
|
114
|
+
* @param content {Fatal} The fatal error to be output.
|
|
115
|
+
*/
|
|
116
|
+
export declare const error: (content: Fatal) => Promise<void>;
|
|
117
|
+
export declare function stringifyMessage(message: Message): string;
|
|
118
|
+
export interface OutputProcess {
|
|
119
|
+
/** The prefix to include in the logs
|
|
120
|
+
* [vite] Output coming from Vite
|
|
121
|
+
*/
|
|
122
|
+
prefix: string;
|
|
123
|
+
/**
|
|
124
|
+
* A callback to invoke the process. stdout and stderr should be used
|
|
125
|
+
* to send standard output and error data that gets formatted with the
|
|
126
|
+
* right prefix.
|
|
127
|
+
*/
|
|
128
|
+
action: (stdout: Writable, stderr: Writable, signal: AbortSignal) => Promise<void>;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Use this function when you have multiple concurrent processes that send data events
|
|
132
|
+
* and we need to output them ensuring that they can visually differenciated by the user.
|
|
133
|
+
*
|
|
134
|
+
* @param processes {OutputProcess[]} A list of processes to run concurrently.
|
|
135
|
+
*/
|
|
136
|
+
export declare function concurrent(processes: OutputProcess[], callback?: ((signal: AbortSignal) => void) | undefined): Promise<void>;
|
|
137
|
+
export declare function logFileExists(): boolean;
|
|
138
|
+
export declare function logToFile(message: string, logLevel: string): void;
|
|
139
|
+
export declare function unstyled(message: string): string;
|
|
140
|
+
export declare function shouldDisplayColors(): boolean;
|
|
141
|
+
export declare function pageLogs(): Promise<void>;
|
|
142
|
+
export {};
|