@shopify/cli-kit 3.31.1 → 3.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +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/index.d.ts +0 -3
- package/dist/index.js +0 -3
- 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/os.d.ts +4 -3
- package/dist/os.js +3 -4
- package/dist/os.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/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/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 +34 -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 +1 -1
- 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 +1 -1
- package/dist/public/common/object.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/archiver.js +1 -1
- package/dist/public/node/archiver.js.map +1 -1
- package/dist/public/node/base-command.js.map +1 -1
- 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/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/presets.d.ts +1 -1
- package/dist/public/node/presets.js.map +1 -1
- package/dist/public/node/ruby.d.ts +2 -2
- package/dist/public/node/ruby.js +2 -2
- package/dist/public/node/ruby.js.map +1 -1
- 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/session/authorize.js +1 -1
- package/dist/session/authorize.js.map +1 -1
- package/dist/session/redirect-listener.js +6 -3
- package/dist/session/redirect-listener.js.map +1 -1
- package/dist/system.d.ts +2 -2
- 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.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 +29 -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/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/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/README.md
CHANGED
|
@@ -54,7 +54,7 @@ If you encounter issues using the CLI or have feedback you'd like to share with
|
|
|
54
54
|
|
|
55
55
|
## Contribute 👩🏽💻
|
|
56
56
|
|
|
57
|
-
If you'd like to contribute to the project, check out the [contributors docs](/docs) and the [steps to get started](/docs/get-started.md).
|
|
57
|
+
If you'd like to contribute to the project, check out the [contributors docs](/docs) and the [steps to get started](/docs/cli/get-started.md).
|
|
58
58
|
|
|
59
59
|
<p> </p>
|
|
60
60
|
|
package/dist/constants.d.ts
CHANGED
package/dist/constants.js
CHANGED
|
@@ -27,6 +27,7 @@ const constants = {
|
|
|
27
27
|
unitTest: 'SHOPIFY_UNIT_TEST',
|
|
28
28
|
verbose: 'SHOPIFY_FLAG_VERBOSE',
|
|
29
29
|
functionMatching: 'SHOPIFY_CLI_FUNCTION_MATCHING',
|
|
30
|
+
themeBundling: 'SHOPIFY_THEME_BUNDLING',
|
|
30
31
|
// Variables to detect if the CLI is running in a cloud environment
|
|
31
32
|
codespaceName: 'CODESPACE_NAME',
|
|
32
33
|
codespaces: 'CODESPACES',
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,IAAI,QAAQ,EAAC,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAC,oBAAoB,EAAC,MAAM,uCAAuC,CAAA;AAC1E,OAAO,QAAQ,MAAM,WAAW,CAAA;AAEhC,MAAM,UAAU,GAAG,aAAa,CAAA;AAEhC,MAAM,WAAW,GAAG,GAAG,EAAE;IACvB,IAAI,OAAO,CAAC,GAAG,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AQ,EAAE;QACR,MAAM,EAAE,KAAK,IAAI,EAAE;YACjB,OAAO,oBAAoB,CAAC,EAAC,aAAa,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,EAAC,CAAC,CAAA;QAC/D,CAAC;KACF;IACD,QAAQ,EAAE;QACR,OAAO,EAAE,aAAa;KACvB;IACD,OAAO,EAAE;QACP,6BAA6B,EAAE,CAAC;KACjC;CACF,CAAA;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,kCAAkC,CAAA;AAE/D,eAAe,SAAS,CAAA","sourcesContent":["import {join as pathJoin} from './path.js'\nimport {findPackageVersionUp} from './public/node/node-package-manager.js'\nimport envPaths from 'env-paths'\n\nconst identifier = 'shopify-cli'\n\nconst cacheFolder = () => {\n if (process.env.XDG_CACHE_HOME) return process.env.XDG_CACHE_HOME\n return envPaths(identifier).cache\n}\n\nconst constants = {\n environmentVariables: {\n alwaysLogAnalytics: 'SHOPIFY_CLI_ALWAYS_LOG_ANALYTICS',\n deviceAuth: 'SHOPIFY_CLI_DEVICE_AUTH',\n enableCliRedirect: 'SHOPIFY_CLI_ENABLE_CLI_REDIRECT',\n env: 'SHOPIFY_CLI_ENV',\n firstPartyDev: 'SHOPIFY_CLI_1P_DEV',\n noAnalytics: 'SHOPIFY_CLI_NO_ANALYTICS',\n partnersToken: 'SHOPIFY_CLI_PARTNERS_TOKEN',\n runAsUser: 'SHOPIFY_RUN_AS_USER',\n serviceEnv: 'SHOPIFY_SERVICE_ENV',\n skipCliRedirect: 'SHOPIFY_CLI_SKIP_CLI_REDIRECT',\n spinHost: 'SPIN_HOST',\n spinInstance: 'SPIN_INSTANCE',\n spinNamespace: 'SPIN_NAMESPACE',\n spinWorkspace: 'SPIN_WORKSPACE',\n themeToken: 'SHOPIFY_CLI_THEME_TOKEN',\n unitTest: 'SHOPIFY_UNIT_TEST',\n verbose: 'SHOPIFY_FLAG_VERBOSE',\n functionMatching: 'SHOPIFY_CLI_FUNCTION_MATCHING',\n // Variables to detect if the CLI is running in a cloud environment\n codespaceName: 'CODESPACE_NAME',\n codespaces: 'CODESPACES',\n gitpod: 'GITPOD_WORKSPACE_URL',\n spin: 'SPIN',\n },\n paths: {\n executables: {\n dev: '/opt/dev/bin/dev',\n },\n directories: {\n cache: {\n path: () => {\n return cacheFolder()\n },\n vendor: {\n path: () => {\n return pathJoin(cacheFolder(), 'vendor')\n },\n binaries: () => {\n return pathJoin(cacheFolder(), 'vendor', 'binaries')\n },\n },\n },\n },\n },\n versions: {\n cliKit: async () => {\n return findPackageVersionUp({fromModuleURL: import.meta.url})\n },\n },\n keychain: {\n service: 'shopify-cli',\n },\n session: {\n expirationTimeMarginInMinutes: 4,\n },\n}\n\nexport const bugsnagApiKey = '9e1e6889176fd0c795d5c659225e0fae'\n\nexport default constants\n"]}
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,IAAI,QAAQ,EAAC,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAC,oBAAoB,EAAC,MAAM,uCAAuC,CAAA;AAC1E,OAAO,QAAQ,MAAM,WAAW,CAAA;AAEhC,MAAM,UAAU,GAAG,aAAa,CAAA;AAEhC,MAAM,WAAW,GAAG,GAAG,EAAE;IACvB,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc;QAAE,OAAO,OAAO,CAAC,GAAG,CAAC,cAAc,CAAA;IACjE,OAAO,QAAQ,CAAC,UAAU,CAAC,CAAC,KAAK,CAAA;AACnC,CAAC,CAAA;AAED,MAAM,SAAS,GAAG;IAChB,oBAAoB,EAAE;QACpB,kBAAkB,EAAE,kCAAkC;QACtD,UAAU,EAAE,yBAAyB;QACrC,iBAAiB,EAAE,iCAAiC;QACpD,GAAG,EAAE,iBAAiB;QACtB,aAAa,EAAE,oBAAoB;QACnC,WAAW,EAAE,0BAA0B;QACvC,aAAa,EAAE,4BAA4B;QAC3C,SAAS,EAAE,qBAAqB;QAChC,UAAU,EAAE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'./public/node/node-package-manager.js'\nimport envPaths from 'env-paths'\n\nconst identifier = 'shopify-cli'\n\nconst cacheFolder = () => {\n if (process.env.XDG_CACHE_HOME) return process.env.XDG_CACHE_HOME\n return envPaths(identifier).cache\n}\n\nconst constants = {\n environmentVariables: {\n alwaysLogAnalytics: 'SHOPIFY_CLI_ALWAYS_LOG_ANALYTICS',\n deviceAuth: 'SHOPIFY_CLI_DEVICE_AUTH',\n enableCliRedirect: 'SHOPIFY_CLI_ENABLE_CLI_REDIRECT',\n env: 'SHOPIFY_CLI_ENV',\n firstPartyDev: 'SHOPIFY_CLI_1P_DEV',\n noAnalytics: 'SHOPIFY_CLI_NO_ANALYTICS',\n partnersToken: 'SHOPIFY_CLI_PARTNERS_TOKEN',\n runAsUser: 'SHOPIFY_RUN_AS_USER',\n serviceEnv: 'SHOPIFY_SERVICE_ENV',\n skipCliRedirect: 'SHOPIFY_CLI_SKIP_CLI_REDIRECT',\n spinHost: 'SPIN_HOST',\n spinInstance: 'SPIN_INSTANCE',\n spinNamespace: 'SPIN_NAMESPACE',\n spinWorkspace: 'SPIN_WORKSPACE',\n themeToken: 'SHOPIFY_CLI_THEME_TOKEN',\n unitTest: 'SHOPIFY_UNIT_TEST',\n verbose: 'SHOPIFY_FLAG_VERBOSE',\n functionMatching: 'SHOPIFY_CLI_FUNCTION_MATCHING',\n themeBundling: 'SHOPIFY_THEME_BUNDLING',\n // Variables to detect if the CLI is running in a cloud environment\n codespaceName: 'CODESPACE_NAME',\n codespaces: 'CODESPACES',\n gitpod: 'GITPOD_WORKSPACE_URL',\n spin: 'SPIN',\n },\n paths: {\n executables: {\n dev: '/opt/dev/bin/dev',\n },\n directories: {\n cache: {\n path: () => {\n return cacheFolder()\n },\n vendor: {\n path: () => {\n return pathJoin(cacheFolder(), 'vendor')\n },\n binaries: () => {\n return pathJoin(cacheFolder(), 'vendor', 'binaries')\n },\n },\n },\n },\n },\n versions: {\n cliKit: async () => {\n return findPackageVersionUp({fromModuleURL: import.meta.url})\n },\n },\n keychain: {\n service: 'shopify-cli',\n },\n session: {\n expirationTimeMarginInMinutes: 4,\n },\n}\n\nexport const bugsnagApiKey = '9e1e6889176fd0c795d5c659225e0fae'\n\nexport default constants\n"]}
|
|
@@ -46,6 +46,7 @@ export declare function alwaysLogAnalytics(env?: NodeJS.ProcessEnv): boolean;
|
|
|
46
46
|
export declare function firstPartyDev(env?: NodeJS.ProcessEnv): boolean;
|
|
47
47
|
export declare function useDeviceAuth(env?: NodeJS.ProcessEnv): boolean;
|
|
48
48
|
export declare function useFunctionMatching(env?: NodeJS.ProcessEnv): boolean;
|
|
49
|
+
export declare function useThemeBundling(env?: NodeJS.ProcessEnv): boolean;
|
|
49
50
|
export declare function gitpodURL(env?: NodeJS.ProcessEnv): string | undefined;
|
|
50
51
|
export declare function codespaceURL(env?: NodeJS.ProcessEnv): string | undefined;
|
|
51
52
|
/**
|
|
@@ -5,7 +5,7 @@ import { exists as fileExists } from '../file.js';
|
|
|
5
5
|
import { exec } from '../system.js';
|
|
6
6
|
import isInteractive from 'is-interactive';
|
|
7
7
|
import macaddress from 'macaddress';
|
|
8
|
-
import { homedir } from '
|
|
8
|
+
import { homedir } from 'os';
|
|
9
9
|
/**
|
|
10
10
|
* It returns true if the terminal is interactive.
|
|
11
11
|
* @returns True if the terminal is interactive.
|
|
@@ -79,6 +79,9 @@ export function useDeviceAuth(env = process.env) {
|
|
|
79
79
|
export function useFunctionMatching(env = process.env) {
|
|
80
80
|
return isTruthy(env[constants.environmentVariables.functionMatching]);
|
|
81
81
|
}
|
|
82
|
+
export function useThemeBundling(env = process.env) {
|
|
83
|
+
return isTruthy(env[constants.environmentVariables.themeBundling]);
|
|
84
|
+
}
|
|
82
85
|
// https://www.gitpod.io/docs/environment-variables#default-environment-variables
|
|
83
86
|
export function gitpodURL(env = process.env) {
|
|
84
87
|
return env[constants.environmentVariables.gitpod];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local.js","sourceRoot":"","sources":["../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AAC,WAAW,CAAC,CAAC,CAAA;QAChC,OAAO,IAAI,CAAA;QACX,qDAAqD;KACtD;IAAC,MAAM;QACN,OAAO,KAAK,CAAA;KACb;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IAC1C,IAAI,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;QACpB,IAAI,IAAI,GAAG,SAAS,CAAA;QACpB,IAAI,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;YAC1B,IAAI,GAAG,UAAU,CAAA;SAClB;aAAM,IAAI,KAAK,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE;YACnC,IAAI,GAAG,QAAQ,CAAA;SAChB;aAAM,IAAI,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;YAClC,IAAI,GAAG,QAAQ,CAAA;SAChB;QAED,OAAO;YACL,IAAI,EAAE,IAAI;YACV,IAAI;SACL,CAAA;KACF;IACD,OAAO;QACL,IAAI,EAAE,KAAK;KACZ,CAAA;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU;IACxB,OAAO,UAAU,CAAC,GAAG,EAAE,CAAA;AACzB,CAAC","sourcesContent":["import {isTruthy, isSet} from './utilities.js'\nimport {isSpin} from './spin.js'\nimport constants from '../constants.js'\nimport {exists as fileExists} from '../file.js'\nimport {exec} from '../system.js'\nimport isInteractive from 'is-interactive'\nimport macaddress from 'macaddress'\nimport {homedir} from 'node:os'\n\n/**\n * It returns true if the terminal is interactive.\n * @returns True if the terminal is interactive.\n */\nexport function isTerminalInteractive(): boolean {\n return isInteractive()\n}\n\n/**\n * Returns the path to the user's home directory.\n * @returns The path to the user's home directory.\n */\nexport function homeDirectory(): string {\n return homedir()\n}\n\n/**\n * Returns true if the CLI is running in debug mode.\n * @param env - The environment variables from the environment of the current process.\n * @returns true if SHOPIFY_ENV is development\n */\nexport function isDevelopment(env = process.env): boolean {\n return env[constants.environmentVariables.env] === 'development'\n}\n\n/**\n * Returns true if the CLI is running in verbose mode.\n * @param env - The environment variables from the environment of the current process.\n * @returns true if SHOPIFY_FLAG_VERBOSE is truthy or the flag --verbose has been passed\n */\nexport function isVerbose(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.verbose]) || process.argv.includes('--verbose')\n}\n\n/**\n * Returns true if the environment in which the CLI is running is either\n * a local environment (where dev is present) or a cloud environment (spin).\n * @returns True if the CLI is used in a Shopify environment.\n */\nexport async function isShopify(env = process.env): Promise<boolean> {\n if (Object.prototype.hasOwnProperty.call(env, constants.environmentVariables.runAsUser)) {\n return !isTruthy(env[constants.environmentVariables.runAsUser])\n }\n const devInstalled = await fileExists(constants.paths.executables.dev)\n return devInstalled || isSpin(env)\n}\n\n/**\n * This variable is used when running unit tests to indicate that the CLI's business logic\n * is run as a subject of a unit test. We can use this variable to disable output through\n * the standard streams.\n * @param env - The environment variables from the environment of the current process.\n * @returns True if the SHOPIFY_UNIT_TEST environment variable is truthy.\n */\nexport function isUnitTest(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.unitTest])\n}\n\n/**\n * Returns true if reporting analytics is enabled.\n * @param env - The environment variables from the environment of the current process.\n * @returns true unless SHOPIFY_CLI_NO_ANALYTICS is truthy or debug mode is enabled.\n */\nexport function analyticsDisabled(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.noAnalytics]) || isDevelopment(env)\n}\n\n/** Returns true if reporting analytics should always happen, regardless of DEBUG mode etc. */\nexport function alwaysLogAnalytics(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.alwaysLogAnalytics])\n}\n\nexport function firstPartyDev(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.firstPartyDev])\n}\n\nexport function useDeviceAuth(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.deviceAuth]) || isCloudEnvironment(env)\n}\n\nexport function useFunctionMatching(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.functionMatching])\n}\n\n// https://www.gitpod.io/docs/environment-variables#default-environment-variables\nexport function gitpodURL(env = process.env): string | undefined {\n return env[constants.environmentVariables.gitpod]\n}\n\n// https://docs.github.com/en/codespaces/developing-in-codespaces/default-environment-variables-for-your-codespace#list-of-default-environment-variables\nexport function codespaceURL(env = process.env): string | undefined {\n return env[constants.environmentVariables.codespaceName]\n}\n\n/**\n * Checks if the CLI is run from a cloud environment\n *\n * @param env - Environment variables used when the cli is launched\n *\n * @returns True in case the CLI is run from a cloud environment\n */\nexport function isCloudEnvironment(env: NodeJS.ProcessEnv = process.env): boolean {\n return cloudEnvironment(env).platform !== 'localhost'\n}\n\n/**\n * Returns the cloud environment platform name and if the platform support online IDE in case the CLI is run from one of\n * them. Platform name 'localhost' is returned otherwise\n *\n * @param env - Environment variables used when the cli is launched\n *\n * @returns Cloud platform information\n */\nexport function cloudEnvironment(env: NodeJS.ProcessEnv = process.env): {\n platform: 'spin' | 'codespaces' | 'gitpod' | 'localhost'\n editor: boolean\n} {\n if (isSet(env[constants.environmentVariables.codespaces])) {\n return {platform: 'codespaces', editor: true}\n }\n if (isSet(env[constants.environmentVariables.gitpod])) {\n return {platform: 'gitpod', editor: true}\n }\n if (isSpin(env)) {\n return {platform: 'spin', editor: false}\n }\n return {platform: 'localhost', editor: false}\n}\n\n/**\n * Returns whether the environment has Git available.\n * @returns A promise that resolves with the value.\n */\nexport async function hasGit(): Promise<boolean> {\n try {\n await exec('git', ['--version'])\n return true\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return false\n }\n}\n\n/**\n * Gets info on the CI platform the CLI is running on, if applicable\n */\nexport function ciPlatform(env = process.env): {isCI: true; name: string} | {isCI: false; name?: undefined} {\n if (isTruthy(env.CI)) {\n let name = 'unknown'\n if (isTruthy(env.CIRCLECI)) {\n name = 'circleci'\n } else if (isSet(env.GITHUB_ACTION)) {\n name = 'github'\n } else if (isTruthy(env.GITLAB_CI)) {\n name = 'gitlab'\n }\n\n return {\n isCI: true,\n name,\n }\n }\n return {\n isCI: false,\n }\n}\n\n/**\n * Returns the first mac address found\n *\n * @returns Mac address\n */\nexport function macAddress() {\n return macaddress.one()\n}\n"]}
|
|
1
|
+
{"version":3,"file":"local.js","sourceRoot":"","sources":["../../src/environment/local.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,KAAK,EAAC,MAAM,gBAAgB,CAAA;AAC9C,OAAO,EAAC,MAAM,EAAC,MAAM,WAAW,CAAA;AAChC,OAAO,SAAS,MAAM,iBAAiB,CAAA;AACvC,OAAO,EAAC,MAAM,IAAI,UAAU,EAAC,MAAM,YAAY,CAAA;AAC/C,OAAO,EAAC,IAAI,EAAC,MAAM,cAAc,CAAA;AACjC,OAAO,aAAa,MAAM,gBAAgB,CAAA;AAC1C,OAAO,UAAU,MAAM,YAAY,CAAA;AACnC,OAAO,EAAC,OAAO,EAAC,MAAM,IAAI,CAAA;AAE1B;;;GAGG;AACH,MAAM,UAAU,qBAAqB;IACnC,OAAO,aAAa,EAAE,CAAA;AACxB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,OAAO,EAAE,CAAA;AAClB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IAC7C,OAAO,GAAG,CAAC,SAAS,CAAC,oBAAoB,CAAC,GAAG,CAAC,KAAK,aAAa,CAAA;AAClE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IACzC,OAAO,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAA;AACpG,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IAC/C,IAAI,MAAM,CAAC,SA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KAC1C;IACD,IAAI,MAAM,CAAC,GAAG,CAAC,EAAE;QACf,OAAO,EAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAC,CAAA;KACzC;IACD,OAAO,EAAC,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,EAAC,CAAA;AAC/C,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM;IAC1B,IAAI;QACF,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC,WAAW,CAAC,CAAC,CAAA;QAChC,OAAO,IAAI,CAAA;QACX,qDAAqD;KACtD;IAAC,MAAM;QACN,OAAO,KAAK,CAAA;KACb;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IAC1C,IAAI,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;QACpB,IAAI,IAAI,GAAG,SAAS,CAAA;QACpB,IAAI,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;YAC1B,IAAI,GAAG,UAAU,CAAA;SAClB;aAAM,IAAI,KAAK,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE;YACnC,IAAI,GAAG,QAAQ,CAAA;SAChB;aAAM,IAAI,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;YAClC,IAAI,GAAG,QAAQ,CAAA;SAChB;QAED,OAAO;YACL,IAAI,EAAE,IAAI;YACV,IAAI;SACL,CAAA;KACF;IACD,OAAO;QACL,IAAI,EAAE,KAAK;KACZ,CAAA;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU;IACxB,OAAO,UAAU,CAAC,GAAG,EAAE,CAAA;AACzB,CAAC","sourcesContent":["import {isTruthy, isSet} from './utilities.js'\nimport {isSpin} from './spin.js'\nimport constants from '../constants.js'\nimport {exists as fileExists} from '../file.js'\nimport {exec} from '../system.js'\nimport isInteractive from 'is-interactive'\nimport macaddress from 'macaddress'\nimport {homedir} from 'os'\n\n/**\n * It returns true if the terminal is interactive.\n * @returns True if the terminal is interactive.\n */\nexport function isTerminalInteractive(): boolean {\n return isInteractive()\n}\n\n/**\n * Returns the path to the user's home directory.\n * @returns The path to the user's home directory.\n */\nexport function homeDirectory(): string {\n return homedir()\n}\n\n/**\n * Returns true if the CLI is running in debug mode.\n * @param env - The environment variables from the environment of the current process.\n * @returns true if SHOPIFY_ENV is development\n */\nexport function isDevelopment(env = process.env): boolean {\n return env[constants.environmentVariables.env] === 'development'\n}\n\n/**\n * Returns true if the CLI is running in verbose mode.\n * @param env - The environment variables from the environment of the current process.\n * @returns true if SHOPIFY_FLAG_VERBOSE is truthy or the flag --verbose has been passed\n */\nexport function isVerbose(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.verbose]) || process.argv.includes('--verbose')\n}\n\n/**\n * Returns true if the environment in which the CLI is running is either\n * a local environment (where dev is present) or a cloud environment (spin).\n * @returns True if the CLI is used in a Shopify environment.\n */\nexport async function isShopify(env = process.env): Promise<boolean> {\n if (Object.prototype.hasOwnProperty.call(env, constants.environmentVariables.runAsUser)) {\n return !isTruthy(env[constants.environmentVariables.runAsUser])\n }\n const devInstalled = await fileExists(constants.paths.executables.dev)\n return devInstalled || isSpin(env)\n}\n\n/**\n * This variable is used when running unit tests to indicate that the CLI's business logic\n * is run as a subject of a unit test. We can use this variable to disable output through\n * the standard streams.\n * @param env - The environment variables from the environment of the current process.\n * @returns True if the SHOPIFY_UNIT_TEST environment variable is truthy.\n */\nexport function isUnitTest(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.unitTest])\n}\n\n/**\n * Returns true if reporting analytics is enabled.\n * @param env - The environment variables from the environment of the current process.\n * @returns true unless SHOPIFY_CLI_NO_ANALYTICS is truthy or debug mode is enabled.\n */\nexport function analyticsDisabled(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.noAnalytics]) || isDevelopment(env)\n}\n\n/** Returns true if reporting analytics should always happen, regardless of DEBUG mode etc. */\nexport function alwaysLogAnalytics(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.alwaysLogAnalytics])\n}\n\nexport function firstPartyDev(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.firstPartyDev])\n}\n\nexport function useDeviceAuth(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.deviceAuth]) || isCloudEnvironment(env)\n}\n\nexport function useFunctionMatching(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.functionMatching])\n}\n\nexport function useThemeBundling(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.themeBundling])\n}\n\n// https://www.gitpod.io/docs/environment-variables#default-environment-variables\nexport function gitpodURL(env = process.env): string | undefined {\n return env[constants.environmentVariables.gitpod]\n}\n\n// https://docs.github.com/en/codespaces/developing-in-codespaces/default-environment-variables-for-your-codespace#list-of-default-environment-variables\nexport function codespaceURL(env = process.env): string | undefined {\n return env[constants.environmentVariables.codespaceName]\n}\n\n/**\n * Checks if the CLI is run from a cloud environment\n *\n * @param env - Environment variables used when the cli is launched\n *\n * @returns True in case the CLI is run from a cloud environment\n */\nexport function isCloudEnvironment(env: NodeJS.ProcessEnv = process.env): boolean {\n return cloudEnvironment(env).platform !== 'localhost'\n}\n\n/**\n * Returns the cloud environment platform name and if the platform support online IDE in case the CLI is run from one of\n * them. Platform name 'localhost' is returned otherwise\n *\n * @param env - Environment variables used when the cli is launched\n *\n * @returns Cloud platform information\n */\nexport function cloudEnvironment(env: NodeJS.ProcessEnv = process.env): {\n platform: 'spin' | 'codespaces' | 'gitpod' | 'localhost'\n editor: boolean\n} {\n if (isSet(env[constants.environmentVariables.codespaces])) {\n return {platform: 'codespaces', editor: true}\n }\n if (isSet(env[constants.environmentVariables.gitpod])) {\n return {platform: 'gitpod', editor: true}\n }\n if (isSpin(env)) {\n return {platform: 'spin', editor: false}\n }\n return {platform: 'localhost', editor: false}\n}\n\n/**\n * Returns whether the environment has Git available.\n * @returns A promise that resolves with the value.\n */\nexport async function hasGit(): Promise<boolean> {\n try {\n await exec('git', ['--version'])\n return true\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return false\n }\n}\n\n/**\n * Gets info on the CI platform the CLI is running on, if applicable\n */\nexport function ciPlatform(env = process.env): {isCI: true; name: string} | {isCI: false; name?: undefined} {\n if (isTruthy(env.CI)) {\n let name = 'unknown'\n if (isTruthy(env.CIRCLECI)) {\n name = 'circleci'\n } else if (isSet(env.GITHUB_ACTION)) {\n name = 'github'\n } else if (isTruthy(env.GITLAB_CI)) {\n name = 'gitlab'\n }\n\n return {\n isCI: true,\n name,\n }\n }\n return {\n isCI: false,\n }\n}\n\n/**\n * Returns the first mac address found\n *\n * @returns Mac address\n */\nexport function macAddress() {\n return macaddress.one()\n}\n"]}
|
package/dist/file.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
|
|
2
|
+
/// <reference types="node" />
|
|
3
3
|
export declare function stripUp(path: string, strip: number): string;
|
|
4
4
|
/**
|
|
5
5
|
* Creates a temporary directory and ties its lifecycle to the lifecycle of the callback.
|
|
@@ -12,7 +12,14 @@ export declare function inTemporaryDirectory<T>(callback: (tmpDir: string) => T
|
|
|
12
12
|
* @param path - Path to the file to read.
|
|
13
13
|
* @returns A promise that resolves with the content of the file.
|
|
14
14
|
*/
|
|
15
|
-
export declare
|
|
15
|
+
export declare type ReadOptions = undefined | {
|
|
16
|
+
flag?: string | undefined;
|
|
17
|
+
} | {
|
|
18
|
+
encoding: BufferEncoding | string;
|
|
19
|
+
flag?: string | undefined;
|
|
20
|
+
};
|
|
21
|
+
export declare function read(path: string, options?: ReadOptions): Promise<string>;
|
|
22
|
+
export declare function read(path: string, options?: ReadOptions): Promise<Buffer>;
|
|
16
23
|
/**
|
|
17
24
|
* Given a path, it determines the actual path. This is useful when working
|
|
18
25
|
* with paths that represent symlinks.
|
|
@@ -44,7 +51,7 @@ export declare function mkTmpDir(): Promise<string>;
|
|
|
44
51
|
export declare function isDirectory(path: string): Promise<boolean>;
|
|
45
52
|
export declare function size(path: string): Promise<number>;
|
|
46
53
|
export declare function sizeSync(path: string): number;
|
|
47
|
-
export declare function createReadStream(path: string): fs.ReadStream;
|
|
54
|
+
export declare function createReadStream(path: string): import("fs").ReadStream;
|
|
48
55
|
/**
|
|
49
56
|
* Returns the Date object for the last modification of a file.
|
|
50
57
|
* @param path - Path to the directory or file.
|
package/dist/file.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { content as outputContent, token, debug } from './output.js';
|
|
2
|
-
import
|
|
2
|
+
import { copy as fsCopy, ensureFile as fsEnsureFile, ensureFileSync as fsEnsureFileSync, remove as fsRemove, removeSync as fsRemoveSync, move as fsMove,
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
4
|
+
// @ts-ignore
|
|
5
|
+
} from 'fs-extra/esm';
|
|
3
6
|
import { temporaryDirectoryTask } from 'tempy';
|
|
4
7
|
import { sep, join, extname } from 'pathe';
|
|
8
|
+
import { mkdirSync as fsMkdirSync, readFileSync as fsReadFileSync, writeFileSync as fsWriteFileSync, appendFileSync as fsAppendFileSync, statSync as fsStatSync, createReadStream as fsCreateReadStream, constants as fsConstants, } from 'fs';
|
|
9
|
+
import { mkdir as fsMkdir, writeFile as fsWriteFile, readFile as fsReadFile, realpath as fsRealPath, appendFile as fsAppendFile, mkdtemp as fsMkdtemp, stat as fsStat, lstat as fsLstat, chmod as fsChmod, access as fsAccess, } from 'fs/promises';
|
|
5
10
|
const DEFAULT_PRETTIER_CONFIG = {
|
|
6
11
|
arrowParens: 'always',
|
|
7
12
|
singleQuote: true,
|
|
@@ -19,16 +24,11 @@ export function stripUp(path, strip) {
|
|
|
19
24
|
export async function inTemporaryDirectory(callback) {
|
|
20
25
|
return temporaryDirectoryTask(callback);
|
|
21
26
|
}
|
|
22
|
-
|
|
23
|
-
* It reads a file and returns its content as a string using the
|
|
24
|
-
* utf-8 encoding
|
|
25
|
-
* @param path - Path to the file to read.
|
|
26
|
-
* @returns A promise that resolves with the content of the file.
|
|
27
|
-
*/
|
|
28
|
-
export async function read(path, options = { encoding: 'utf-8' }) {
|
|
27
|
+
export async function read(path, options = { encoding: 'utf8' }) {
|
|
29
28
|
debug(outputContent `Reading the content of file at ${token.path(path)}...`);
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
30
|
+
// @ts-ignore
|
|
31
|
+
return fsReadFile(path, options);
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
34
|
* Given a path, it determines the actual path. This is useful when working
|
|
@@ -36,11 +36,11 @@ export async function read(path, options = { encoding: 'utf-8' }) {
|
|
|
36
36
|
* @param path - Path whose real path will be returned.
|
|
37
37
|
*/
|
|
38
38
|
export async function realpath(path) {
|
|
39
|
-
return
|
|
39
|
+
return fsRealPath(path);
|
|
40
40
|
}
|
|
41
41
|
export function readSync(path, options = { encoding: 'utf-8' }) {
|
|
42
42
|
debug(outputContent `Sync-reading the content of file at ${token.path(path)}...`);
|
|
43
|
-
const content =
|
|
43
|
+
const content = fsReadFileSync(path, options);
|
|
44
44
|
return content.toString();
|
|
45
45
|
}
|
|
46
46
|
/**
|
|
@@ -50,11 +50,11 @@ export function readSync(path, options = { encoding: 'utf-8' }) {
|
|
|
50
50
|
*/
|
|
51
51
|
export async function copy(from, to) {
|
|
52
52
|
debug(outputContent `Copying file from ${token.path(from)} to ${token.path(to)}...`);
|
|
53
|
-
await
|
|
53
|
+
await fsCopy(from, to);
|
|
54
54
|
}
|
|
55
55
|
export async function touch(path) {
|
|
56
56
|
debug(outputContent `Creating an empty file at ${token.path(path)}...`);
|
|
57
|
-
await
|
|
57
|
+
await fsEnsureFile(path);
|
|
58
58
|
}
|
|
59
59
|
export async function appendFile(path, content) {
|
|
60
60
|
debug(outputContent `Appending the following content to ${token.path(path)}:
|
|
@@ -63,41 +63,41 @@ export async function appendFile(path, content) {
|
|
|
63
63
|
.map((line) => ` ${line}`)
|
|
64
64
|
.join('\n')}
|
|
65
65
|
`);
|
|
66
|
-
await
|
|
66
|
+
await fsAppendFile(path, content);
|
|
67
67
|
}
|
|
68
68
|
export function touchSync(path) {
|
|
69
69
|
debug(outputContent `Creating an empty file at ${token.path(path)}...`);
|
|
70
|
-
|
|
70
|
+
fsEnsureFileSync(path);
|
|
71
71
|
}
|
|
72
72
|
export async function write(path, data) {
|
|
73
73
|
debug(outputContent `Writing some content to file at ${token.path(path)}...`);
|
|
74
|
-
await
|
|
74
|
+
await fsWriteFile(path, data, { encoding: 'utf8' });
|
|
75
75
|
}
|
|
76
76
|
export function writeSync(path, data) {
|
|
77
77
|
debug(outputContent `File-writing some content to file at ${token.path(path)}...`);
|
|
78
|
-
|
|
78
|
+
fsWriteFileSync(path, data);
|
|
79
79
|
}
|
|
80
80
|
export async function append(path, data) {
|
|
81
|
-
await
|
|
81
|
+
await fsAppendFile(path, data);
|
|
82
82
|
}
|
|
83
83
|
export function appendSync(path, data) {
|
|
84
|
-
|
|
84
|
+
fsAppendFileSync(path, data);
|
|
85
85
|
}
|
|
86
86
|
export async function mkdir(path) {
|
|
87
87
|
debug(outputContent `Creating directory at ${token.path(path)}...`);
|
|
88
|
-
await
|
|
88
|
+
await fsMkdir(path, { recursive: true });
|
|
89
89
|
}
|
|
90
90
|
export function mkdirSync(path) {
|
|
91
91
|
debug(outputContent `Sync-creating directory at ${token.path(path)}...`);
|
|
92
|
-
|
|
92
|
+
fsMkdirSync(path, { recursive: true });
|
|
93
93
|
}
|
|
94
94
|
export async function remove(path) {
|
|
95
95
|
debug(outputContent `Removing file at ${token.path(path)}...`);
|
|
96
|
-
await
|
|
96
|
+
await fsRemove(path);
|
|
97
97
|
}
|
|
98
98
|
export function removeSync(path) {
|
|
99
99
|
debug(outputContent `Sync-removing file at ${token.path(path)}...`);
|
|
100
|
-
|
|
100
|
+
fsRemoveSync(path);
|
|
101
101
|
}
|
|
102
102
|
export async function rmdir(path, { force } = {}) {
|
|
103
103
|
const { default: del } = await import('del');
|
|
@@ -106,23 +106,23 @@ export async function rmdir(path, { force } = {}) {
|
|
|
106
106
|
}
|
|
107
107
|
export async function mkTmpDir() {
|
|
108
108
|
debug(outputContent `Creating a temporary directory...`);
|
|
109
|
-
const directory = await
|
|
109
|
+
const directory = await fsMkdtemp('tmp-');
|
|
110
110
|
return directory;
|
|
111
111
|
}
|
|
112
112
|
export async function isDirectory(path) {
|
|
113
113
|
debug(outputContent `Checking if ${token.path(path)} is a directory...`);
|
|
114
|
-
return (await
|
|
114
|
+
return (await fsLstat(path)).isDirectory();
|
|
115
115
|
}
|
|
116
116
|
export async function size(path) {
|
|
117
117
|
debug(outputContent `Getting the size of file file at ${token.path(path)}...`);
|
|
118
|
-
return (await
|
|
118
|
+
return (await fsStat(path)).size;
|
|
119
119
|
}
|
|
120
120
|
export function sizeSync(path) {
|
|
121
121
|
debug(outputContent `Sync-getting the size of file file at ${token.path(path)}...`);
|
|
122
|
-
return
|
|
122
|
+
return fsStatSync(path).size;
|
|
123
123
|
}
|
|
124
124
|
export function createReadStream(path) {
|
|
125
|
-
return
|
|
125
|
+
return fsCreateReadStream(path);
|
|
126
126
|
}
|
|
127
127
|
/**
|
|
128
128
|
* Returns the Date object for the last modification of a file.
|
|
@@ -131,7 +131,7 @@ export function createReadStream(path) {
|
|
|
131
131
|
*/
|
|
132
132
|
export async function lastUpdated(path) {
|
|
133
133
|
debug(outputContent `Getting last updated timestamp for file at ${token.path(path)}...`);
|
|
134
|
-
return (await
|
|
134
|
+
return (await fsStat(path)).ctime;
|
|
135
135
|
}
|
|
136
136
|
/**
|
|
137
137
|
* Returns the unix timestamp of the last modification of a file.
|
|
@@ -155,7 +155,7 @@ export async function lastUpdatedTimestamp(path) {
|
|
|
155
155
|
* @param options - Moving options.
|
|
156
156
|
*/
|
|
157
157
|
export async function move(src, dest, options = {}) {
|
|
158
|
-
await
|
|
158
|
+
await fsMove(src, dest, options);
|
|
159
159
|
}
|
|
160
160
|
/**
|
|
161
161
|
* Changes the permissions of a directory or file.
|
|
@@ -163,7 +163,7 @@ export async function move(src, dest, options = {}) {
|
|
|
163
163
|
* @param mode - Permissions to set to the file or directory.
|
|
164
164
|
*/
|
|
165
165
|
export async function chmod(path, mode) {
|
|
166
|
-
await
|
|
166
|
+
await fsChmod(path, mode);
|
|
167
167
|
}
|
|
168
168
|
/**
|
|
169
169
|
* Checks if a file has executable permissions.
|
|
@@ -171,7 +171,7 @@ export async function chmod(path, mode) {
|
|
|
171
171
|
*/
|
|
172
172
|
export async function hasExecutablePermissions(path) {
|
|
173
173
|
try {
|
|
174
|
-
await
|
|
174
|
+
await fsAccess(path, fsConstants.X_OK);
|
|
175
175
|
return true;
|
|
176
176
|
// eslint-disable-next-line no-catch-all/no-catch-all
|
|
177
177
|
}
|
|
@@ -186,7 +186,7 @@ export async function hasExecutablePermissions(path) {
|
|
|
186
186
|
*/
|
|
187
187
|
export async function exists(path) {
|
|
188
188
|
try {
|
|
189
|
-
await
|
|
189
|
+
await fsAccess(path);
|
|
190
190
|
return true;
|
|
191
191
|
// eslint-disable-next-line no-catch-all/no-catch-all
|
|
192
192
|
}
|
package/dist/file.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file.js","sourceRoot":"","sources":["../src/file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,IAAI,aAAa,EAAE,KAAK,EAAE,KAAK,EAAC,MAAM,aAAa,CAAA;AAClE,OAAO,EAAE,MAAM,UAAU,CAAA;AACzB,OAAO,EAAC,sBAAsB,EAAC,MAAM,OAAO,CAAA;AAC5C,OAAO,EAAC,GAAG,EAAE,IAAI,EAAE,OAAO,EAAC,MAAM,OAAO,CAAA;AAGxC,MAAM,uBAAuB,GAAY;IACvC,WAAW,EAAE,QAAQ;IACrB,WAAW,EAAE,IAAI;IACjB,cAAc,EAAE,KAAK;IACrB,aAAa,EAAE,KAAK;CACrB,CAAA;AAED,MAAM,UAAU,OAAO,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IAAI;QACF,MAAM,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QAC9B,OAAO,IAAI,CAAA;QACX,qDAAqD;KACtD;IAAC,MAAM;QACN,OAAO,KAAK,CAAA;KACb;AACH,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,OAAe,EAAE,OAAuB;IACnE,MAAM,EAAC,OAAO,EAAE,QAAQ,EAAC,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,CAAA;IAEpD,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IACjC,MAAM,cAAc,GAAY;QAC9B,GAAG,uBAAuB;QAC1B,MAAM,EAAE,OAAO;KAChB,CAAA;IAED,QAAQ,GAAG,EAAE;QACX,KAAK,OAAO,CAAC;QACb,KAAK,MAAM;YACT,cAAc,CAAC,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;YACpC,MAAK;KACR;IAED,MAAM,gBAAgB,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE,cAAc,CAAC,CAAA;IAEvE,OAAO,gBAAgB,CAAA;AACzB,CAAC","sourcesContent":["import {content as outputContent, token, debug} from './output.js'\nimport fs from 'fs-extra'\nimport {temporaryDirectoryTask} from 'tempy'\nimport {sep, join, extname} from 'pathe'\nimport type {Options} from 'prettier'\n\nconst DEFAULT_PRETTIER_CONFIG: Options = {\n arrowParens: 'always',\n singleQuote: true,\n bracketSpacing: false,\n trailingComma: 'all',\n}\n\nexport function stripUp(path: string, strip: number) {\n const parts = path.split(sep)\n return join(...parts.slice(strip))\n}\n\n/**\n * Creates a temporary directory and ties its lifecycle to the lifecycle of the callback.\n * @param callback - The callback that receives the temporary directory.\n */\nexport async function inTemporaryDirectory<T>(callback: (tmpDir: string) => T | Promise<T>): Promise<T> {\n return temporaryDirectoryTask(callback)\n}\n\n/**\n * It reads a file and returns its content as a string using the\n * utf-8 encoding\n * @param path - Path to the file to read.\n * @returns A promise that resolves with the content of the file.\n */\nexport async function read(path: string, options: object = {encoding: 'utf-8'}): Promise<string> {\n debug(outputContent`Reading the content of file at ${token.path(path)}...`)\n const content = await fs.readFile(path, options)\n return content\n}\n\n/**\n * Given a path, it determines the actual path. This is useful when working\n * with paths that represent symlinks.\n * @param path - Path whose real path will be returned.\n */\nexport async function realpath(path: string): Promise<string> {\n return fs.promises.realpath(path)\n}\n\nexport function readSync(path: string, options: object = {encoding: 'utf-8'}): string {\n debug(outputContent`Sync-reading the content of file at ${token.path(path)}...`)\n const content = fs.readFileSync(path, options)\n return content.toString()\n}\n\n/**\n * Copies a file\n * @param from - Path to the directory or file to be copied.\n * @param to - Destination path.\n */\nexport async function copy(from: string, to: string): Promise<void> {\n debug(outputContent`Copying file from ${token.path(from)} to ${token.path(to)}...`)\n await fs.copy(from, to)\n}\n\nexport async function touch(path: string): Promise<void> {\n debug(outputContent`Creating an empty file at ${token.path(path)}...`)\n await fs.ensureFile(path)\n}\n\nexport async function appendFile(path: string, content: string): Promise<void> {\n debug(outputContent`Appending the following content to ${token.path(path)}:\n ${content\n .split('\\n')\n .map((line) => ` ${line}`)\n .join('\\n')}\n `)\n await fs.appendFile(path, content)\n}\n\nexport function touchSync(path: string) {\n debug(outputContent`Creating an empty file at ${token.path(path)}...`)\n fs.ensureFileSync(path)\n}\n\nexport async function write(path: string, data: string): Promise<void> {\n debug(outputContent`Writing some content to file at ${token.path(path)}...`)\n await fs.writeFile(path, data)\n}\n\nexport function writeSync(path: string, data: string): void {\n debug(outputContent`File-writing some content to file at ${token.path(path)}...`)\n fs.writeFileSync(path, data)\n}\n\nexport async function append(path: string, data: string): Promise<void> {\n await fs.appendFile(path, data)\n}\n\nexport function appendSync(path: string, data: string): void {\n fs.appendFileSync(path, data)\n}\n\nexport async function mkdir(path: string): Promise<void> {\n debug(outputContent`Creating directory at ${token.path(path)}...`)\n await fs.mkdirp(path)\n}\n\nexport function mkdirSync(path: string): void {\n debug(outputContent`Sync-creating directory at ${token.path(path)}...`)\n fs.mkdirpSync(path)\n}\n\nexport async function remove(path: string): Promise<void> {\n debug(outputContent`Removing file at ${token.path(path)}...`)\n await fs.remove(path)\n}\n\nexport function removeSync(path: string) {\n debug(outputContent`Sync-removing file at ${token.path(path)}...`)\n fs.removeSync(path)\n}\n\nexport async function rmdir(path: string, {force}: {force?: boolean} = {}): Promise<void> {\n const {default: del} = await import('del')\n debug(outputContent`Removing directory at ${token.path(path)}...`)\n await del(path, {force})\n}\n\nexport async function mkTmpDir(): Promise<string> {\n debug(outputContent`Creating a temporary directory...`)\n const directory = await fs.mkdtemp('tmp-')\n return directory\n}\n\nexport async function isDirectory(path: string): Promise<boolean> {\n debug(outputContent`Checking if ${token.path(path)} is a directory...`)\n return (await fs.promises.lstat(path)).isDirectory()\n}\n\nexport async function size(path: string): Promise<number> {\n debug(outputContent`Getting the size of file file at ${token.path(path)}...`)\n return (await fs.stat(path)).size\n}\n\nexport function sizeSync(path: string): number {\n debug(outputContent`Sync-getting the size of file file at ${token.path(path)}...`)\n return fs.statSync(path).size\n}\n\nexport function createReadStream(path: string) {\n return fs.createReadStream(path)\n}\n\n/**\n * Returns the Date object for the last modification of a file.\n * @param path - Path to the directory or file.\n * @returns A unix timestamp.\n */\nexport async function lastUpdated(path: string): Promise<Date> {\n debug(outputContent`Getting last updated timestamp for file at ${token.path(path)}...`)\n return (await fs.stat(path)).ctime\n}\n\n/**\n * Returns the unix timestamp of the last modification of a file.\n * @param path - Path to the directory or file.\n * @returns A unix timestamp.\n */\nexport async function lastUpdatedTimestamp(path: string): Promise<number | undefined> {\n try {\n const lastUpdatedDateTime = await lastUpdated(path)\n return lastUpdatedDateTime.getTime()\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return undefined\n }\n}\n\n/**\n * Moves a file.\n * @param src - File to be moved.\n * @param dest - Path to be moved to.\n * @param options - Moving options.\n */\nexport async function move(src: string, dest: string, options: {overwrite?: boolean} = {}): Promise<void> {\n await fs.move(src, dest, options)\n}\n\n/**\n * Changes the permissions of a directory or file.\n * @param path - Path to the file or directory whose permissions will be modified.\n * @param mode - Permissions to set to the file or directory.\n */\nexport async function chmod(path: string, mode: number | string): Promise<void> {\n await fs.promises.chmod(path, mode)\n}\n\n/**\n * Checks if a file has executable permissions.\n * @param path - Path to the file whose permissions will be checked.\n */\nexport async function hasExecutablePermissions(path: string): Promise<boolean> {\n try {\n await fs.promises.access(path, fs.constants.X_OK)\n return true\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return false\n }\n}\n\n/**\n * Returns true if a file or directory exists\n * @param path - Path to the directory or file.\n * @returns True if it exists.\n */\nexport async function exists(path: string): Promise<boolean> {\n try {\n await fs.promises.access(path)\n return true\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return false\n }\n}\n\n/**\n * Format a string using prettier. Return the formatted content.\n */\nexport async function format(content: string, options: {path: string}) {\n const {default: prettier} = await import('prettier')\n\n const ext = extname(options.path)\n const prettierConfig: Options = {\n ...DEFAULT_PRETTIER_CONFIG,\n parser: 'babel',\n }\n\n switch (ext) {\n case '.html':\n case '.css':\n prettierConfig.parser = ext.slice(1)\n break\n }\n\n const formattedContent = await prettier.format(content, prettierConfig)\n\n return formattedContent\n}\n"]}
|
|
1
|
+
{"version":3,"file":"file.js","sourceRoot":"","sources":["../src/file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,IAAI,aAAa,EAAE,KAAK,EAAE,KAAK,EAAC,MAAM,aAAa,CAAA;AAClE,OAAO,EACL,IAAI,IAAI,MAAM,EACd,UAAU,IAAI,YAAY,EAC1B,cAAc,IAAI,gBAAgB,EAClC,MAAM,IAAI,QAAQ,EAClB,UAAU,IAAI,YAAY,EAC1B,IAAI,IAAI,MAAM;AACd,6DAA6D;AAC7D,aAAa;EACd,MAAM,cAAc,CAAA;AAErB,OAAO,EAAC,sBAAsB,EAAC,MAAM,OAAO,CAAA;AAC5C,OAAO,EAAC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GAIG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,IAAY,EAAE,IAAqB;IAC7D,MAAM,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;AAC3B,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAAC,IAAY;IACzD,IAAI;QACF,MAAM,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC,CAAA;QACtC,OAAO,IAAI,CAAA;QACX,qDAAqD;KACtD;IAAC,MAAM;QACN,OAAO,KAAK,CAAA;KACb;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,IAAY;IACvC,IAAI;QACF,MAAM,QAAQ,CAAC,IAAI,CAAC,CAAA;QACpB,OAAO,IAAI,CAAA;QACX,qDAAqD;KACtD;IAAC,MAAM;QACN,OAAO,KAAK,CAAA;KACb;AACH,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,OAAe,EAAE,OAAuB;IACnE,MAAM,EAAC,OAAO,EAAE,QAAQ,EAAC,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,CAAA;IAEpD,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IACjC,MAAM,cAAc,GAAY;QAC9B,GAAG,uBAAuB;QAC1B,MAAM,EAAE,OAAO;KAChB,CAAA;IAED,QAAQ,GAAG,EAAE;QACX,KAAK,OAAO,CAAC;QACb,KAAK,MAAM;YACT,cAAc,CAAC,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;YACpC,MAAK;KACR;IAED,MAAM,gBAAgB,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE,cAAc,CAAC,CAAA;IAEvE,OAAO,gBAAgB,CAAA;AACzB,CAAC","sourcesContent":["import {content as outputContent, token, debug} from './output.js'\nimport {\n copy as fsCopy,\n ensureFile as fsEnsureFile,\n ensureFileSync as fsEnsureFileSync,\n remove as fsRemove,\n removeSync as fsRemoveSync,\n move as fsMove,\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n} from 'fs-extra/esm'\n\nimport {temporaryDirectoryTask} from 'tempy'\nimport {sep, join, extname} from 'pathe'\nimport {\n mkdirSync as fsMkdirSync,\n readFileSync as fsReadFileSync,\n writeFileSync as fsWriteFileSync,\n appendFileSync as fsAppendFileSync,\n statSync as fsStatSync,\n createReadStream as fsCreateReadStream,\n constants as fsConstants,\n} from 'fs'\nimport {\n mkdir as fsMkdir,\n writeFile as fsWriteFile,\n readFile as fsReadFile,\n realpath as fsRealPath,\n appendFile as fsAppendFile,\n mkdtemp as fsMkdtemp,\n stat as fsStat,\n lstat as fsLstat,\n chmod as fsChmod,\n access as fsAccess,\n} from 'fs/promises'\nimport type {Options} from 'prettier'\n\nconst DEFAULT_PRETTIER_CONFIG: Options = {\n arrowParens: 'always',\n singleQuote: true,\n bracketSpacing: false,\n trailingComma: 'all',\n}\n\nexport function stripUp(path: string, strip: number) {\n const parts = path.split(sep)\n return join(...parts.slice(strip))\n}\n\n/**\n * Creates a temporary directory and ties its lifecycle to the lifecycle of the callback.\n * @param callback - The callback that receives the temporary directory.\n */\nexport async function inTemporaryDirectory<T>(callback: (tmpDir: string) => T | Promise<T>): Promise<T> {\n return temporaryDirectoryTask(callback)\n}\n\n/**\n * It reads a file and returns its content as a string using the\n * utf-8 encoding\n * @param path - Path to the file to read.\n * @returns A promise that resolves with the content of the file.\n */\n\nexport type ReadOptions =\n | undefined\n | {flag?: string | undefined}\n | {\n encoding: BufferEncoding | string\n flag?: string | undefined\n }\nexport async function read(path: string, options?: ReadOptions): Promise<string>\nexport async function read(path: string, options?: ReadOptions): Promise<Buffer>\n\nexport async function read(path: string, options: ReadOptions = {encoding: 'utf8'}): Promise<string | Buffer> {\n debug(outputContent`Reading the content of file at ${token.path(path)}...`)\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return fsReadFile(path, options)\n}\n\n/**\n * Given a path, it determines the actual path. This is useful when working\n * with paths that represent symlinks.\n * @param path - Path whose real path will be returned.\n */\nexport async function realpath(path: string): Promise<string> {\n return fsRealPath(path)\n}\n\nexport function readSync(path: string, options: object = {encoding: 'utf-8'}): string {\n debug(outputContent`Sync-reading the content of file at ${token.path(path)}...`)\n const content = fsReadFileSync(path, options)\n return content.toString()\n}\n\n/**\n * Copies a file\n * @param from - Path to the directory or file to be copied.\n * @param to - Destination path.\n */\nexport async function copy(from: string, to: string): Promise<void> {\n debug(outputContent`Copying file from ${token.path(from)} to ${token.path(to)}...`)\n await fsCopy(from, to)\n}\n\nexport async function touch(path: string): Promise<void> {\n debug(outputContent`Creating an empty file at ${token.path(path)}...`)\n await fsEnsureFile(path)\n}\n\nexport async function appendFile(path: string, content: string): Promise<void> {\n debug(outputContent`Appending the following content to ${token.path(path)}:\n ${content\n .split('\\n')\n .map((line) => ` ${line}`)\n .join('\\n')}\n `)\n await fsAppendFile(path, content)\n}\n\nexport function touchSync(path: string) {\n debug(outputContent`Creating an empty file at ${token.path(path)}...`)\n fsEnsureFileSync(path)\n}\n\nexport async function write(path: string, data: string): Promise<void> {\n debug(outputContent`Writing some content to file at ${token.path(path)}...`)\n await fsWriteFile(path, data, {encoding: 'utf8'})\n}\n\nexport function writeSync(path: string, data: string): void {\n debug(outputContent`File-writing some content to file at ${token.path(path)}...`)\n fsWriteFileSync(path, data)\n}\n\nexport async function append(path: string, data: string): Promise<void> {\n await fsAppendFile(path, data)\n}\n\nexport function appendSync(path: string, data: string): void {\n fsAppendFileSync(path, data)\n}\n\nexport async function mkdir(path: string): Promise<void> {\n debug(outputContent`Creating directory at ${token.path(path)}...`)\n await fsMkdir(path, {recursive: true})\n}\n\nexport function mkdirSync(path: string): void {\n debug(outputContent`Sync-creating directory at ${token.path(path)}...`)\n fsMkdirSync(path, {recursive: true})\n}\n\nexport async function remove(path: string): Promise<void> {\n debug(outputContent`Removing file at ${token.path(path)}...`)\n await fsRemove(path)\n}\n\nexport function removeSync(path: string) {\n debug(outputContent`Sync-removing file at ${token.path(path)}...`)\n fsRemoveSync(path)\n}\n\nexport async function rmdir(path: string, {force}: {force?: boolean} = {}): Promise<void> {\n const {default: del} = await import('del')\n debug(outputContent`Removing directory at ${token.path(path)}...`)\n await del(path, {force})\n}\n\nexport async function mkTmpDir(): Promise<string> {\n debug(outputContent`Creating a temporary directory...`)\n const directory = await fsMkdtemp('tmp-')\n return directory\n}\n\nexport async function isDirectory(path: string): Promise<boolean> {\n debug(outputContent`Checking if ${token.path(path)} is a directory...`)\n return (await fsLstat(path)).isDirectory()\n}\n\nexport async function size(path: string): Promise<number> {\n debug(outputContent`Getting the size of file file at ${token.path(path)}...`)\n return (await fsStat(path)).size\n}\n\nexport function sizeSync(path: string): number {\n debug(outputContent`Sync-getting the size of file file at ${token.path(path)}...`)\n return fsStatSync(path).size\n}\n\nexport function createReadStream(path: string) {\n return fsCreateReadStream(path)\n}\n\n/**\n * Returns the Date object for the last modification of a file.\n * @param path - Path to the directory or file.\n * @returns A unix timestamp.\n */\nexport async function lastUpdated(path: string): Promise<Date> {\n debug(outputContent`Getting last updated timestamp for file at ${token.path(path)}...`)\n return (await fsStat(path)).ctime\n}\n\n/**\n * Returns the unix timestamp of the last modification of a file.\n * @param path - Path to the directory or file.\n * @returns A unix timestamp.\n */\nexport async function lastUpdatedTimestamp(path: string): Promise<number | undefined> {\n try {\n const lastUpdatedDateTime = await lastUpdated(path)\n return lastUpdatedDateTime.getTime()\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return undefined\n }\n}\n\n/**\n * Moves a file.\n * @param src - File to be moved.\n * @param dest - Path to be moved to.\n * @param options - Moving options.\n */\nexport async function move(src: string, dest: string, options: {overwrite?: boolean} = {}): Promise<void> {\n await fsMove(src, dest, options)\n}\n\n/**\n * Changes the permissions of a directory or file.\n * @param path - Path to the file or directory whose permissions will be modified.\n * @param mode - Permissions to set to the file or directory.\n */\nexport async function chmod(path: string, mode: number | string): Promise<void> {\n await fsChmod(path, mode)\n}\n\n/**\n * Checks if a file has executable permissions.\n * @param path - Path to the file whose permissions will be checked.\n */\nexport async function hasExecutablePermissions(path: string): Promise<boolean> {\n try {\n await fsAccess(path, fsConstants.X_OK)\n return true\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return false\n }\n}\n\n/**\n * Returns true if a file or directory exists\n * @param path - Path to the directory or file.\n * @returns True if it exists.\n */\nexport async function exists(path: string): Promise<boolean> {\n try {\n await fsAccess(path)\n return true\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return false\n }\n}\n\n/**\n * Format a string using prettier. Return the formatted content.\n */\nexport async function format(content: string, options: {path: string}) {\n const {default: prettier} = await import('prettier')\n\n const ext = extname(options.path)\n const prettierConfig: Options = {\n ...DEFAULT_PRETTIER_CONFIG,\n parser: 'babel',\n }\n\n switch (ext) {\n case '.html':\n case '.css':\n prettierConfig.parser = ext.slice(1)\n break\n }\n\n const formattedContent = await prettier.format(content, prettierConfig)\n\n return formattedContent\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
export { default as constants } from './constants.js';
|
|
2
|
-
export * as abort from './abort.js';
|
|
3
|
-
export * as analytics from './analytics.js';
|
|
4
2
|
export * as api from './api.js';
|
|
5
3
|
export * as cli from './cli.js';
|
|
6
4
|
export * as environment from './environment.js';
|
|
@@ -8,7 +6,6 @@ export * as error from './error.js';
|
|
|
8
6
|
export * as file from './file.js';
|
|
9
7
|
export * as git from './git.js';
|
|
10
8
|
export * as http from './http.js';
|
|
11
|
-
export * as id from './id.js';
|
|
12
9
|
export * as npm from './npm.js';
|
|
13
10
|
export * as os from './os.js';
|
|
14
11
|
export * as output from './output.js';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
export { default as constants } from './constants.js';
|
|
2
|
-
export * as abort from './abort.js';
|
|
3
|
-
export * as analytics from './analytics.js';
|
|
4
2
|
export * as api from './api.js';
|
|
5
3
|
export * as cli from './cli.js';
|
|
6
4
|
export * as environment from './environment.js';
|
|
@@ -8,7 +6,6 @@ export * as error from './error.js';
|
|
|
8
6
|
export * as file from './file.js';
|
|
9
7
|
export * as git from './git.js';
|
|
10
8
|
export * as http from './http.js';
|
|
11
|
-
export * as id from './id.js';
|
|
12
9
|
export * as npm from './npm.js';
|
|
13
10
|
export * as os from './os.js';
|
|
14
11
|
export * as output from './output.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,IAAI,SAAS,EAAC,MAAM,gBAAgB,CAAA;AACnD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,IAAI,SAAS,EAAC,MAAM,gBAAgB,CAAA;AACnD,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAA;AAC/C,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,EAAE,MAAM,SAAS,CAAA;AAC7B,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AACzC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAA;AAC7B,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,YAAY,MAAM,qBAAqB,CAAA;AACnD,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AACzC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA","sourcesContent":["export {default as constants} from './constants.js'\nexport * as api from './api.js'\nexport * as cli from './cli.js'\nexport * as environment from './environment.js'\nexport * as error from './error.js'\nexport * as file from './file.js'\nexport * as git from './git.js'\nexport * as http from './http.js'\nexport * as npm from './npm.js'\nexport * as os from './os.js'\nexport * as output from './output.js'\nexport * as path from './path.js'\nexport * as plugins from './plugins.js'\nexport * as schema from './schema.js'\nexport * as session from './session.js'\nexport * as store from './store.js'\nexport * as string from './string.js'\nexport * as system from './system.js'\nexport * as template from './template.js'\nexport * as toml from './toml.js'\nexport * as ui from './ui.js'\nexport * as vscode from './vscode.js'\nexport * as outputMocker from './testing/output.js'\nexport * as metadata from './metadata.js'\nexport * as monorail from './monorail.js'\n"]}
|
package/dist/metadata.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnyJson } from './json.js';
|
|
1
|
+
import { AnyJson } from './private/common/json.js';
|
|
2
2
|
import { MonorailEventPublic } from './monorail.js';
|
|
3
3
|
import { PickByPrefix } from './typing/pick-by-prefix.js';
|
|
4
4
|
declare type ProvideMetadata<T> = () => Partial<T> | Promise<Partial<T>>;
|
package/dist/metadata.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata.js","sourceRoot":"","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;IAED,OAAO;QACL,YAAY,EAAE,GAAG,EAAE;YACjB,OAAO,EAAC,GAAG,GAAG,CAAC,MAAM,EAAC,CAAA;QACxB,CAAC;QACD,eAAe,EAAE,GAAG,EAAE;YACpB,OAAO,EAAC,GAAG,GAAG,CAAC,SAAS,EAAC,CAAA;QAC3B,CAAC;QACD,SAAS,EAAE,KAAK,EAAE,OAAiC,EAAE,UAAiC,MAAM,EAAE,EAAE;YAC9F,OAAO,WAAW,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;QACjD,CAAC;QACD,YAAY,EAAE,KAAK,EAAE,OAAoC,EAAE,UAAiC,MAAM,EAAE,EAAE;YACpG,OAAO,WAAW,CAAC,YAAY,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;QACpD,CAAC;KACF,CAAA;AACH,CAAC;AAOD,MAAM,QAAQ,GAAG,8BAA8B,EAU5C,CAAA;AAEH,MAAM,CAAC,MAAM,EAAC,YAAY,EAAE,eAAe,EAAE,SAAS,EAAE,YAAY,EAAC,GAAG,QAAQ,CAAA","sourcesContent":["import {isUnitTest} from './environment/local.js'\nimport {AnyJson} from './json.js'\nimport {MonorailEventPublic} from './monorail.js'\nimport {sendErrorToBugsnag} from './public/node/error-handler.js'\nimport {PickByPrefix} from './typing/pick-by-prefix.js'\n\ntype ProvideMetadata<T> = () => Partial<T> | Promise<Partial<T>>\n\ntype MetadataErrorHandling =\n // Mute & report errors in production, throw them whilst testing\n | 'auto'\n // Errors are not reported to the user and do not stop execution, but they are reported to Bugsnag\n | 'mute-and-report'\n // Errors are not caught and will bubble out as normal\n | 'bubble'\n\nfunction getMetadataErrorHandlingStrategy(): 'mute-and-report' | 'bubble' {\n if (isUnitTest()) {\n return 'bubble'\n }\n return 'mute-and-report'\n}\n\nexport interface RuntimeMetadataManager<TPublic extends AnyJson, TSensitive extends AnyJson> {\n /** Add some public metadata -- this should not contain any PII */\n addPublic: (getData: ProvideMetadata<TPublic>, onError?: MetadataErrorHandling) => Promise<void>\n /** Add some potentially sensitive metadata -- this may include PII, but unnecessary data should never be tracked (this is a good fit for command args for instance) */\n addSensitive: (getData: ProvideMetadata<TSensitive>, onError?: MetadataErrorHandling) => Promise<void>\n /** Get a snapshot of the tracked public data */\n getAllPublic: () => Partial<TPublic>\n /** Get a snapshot of the tracked sensitive data */\n getAllSensitive: () => Partial<TSensitive>\n}\n\nexport type PublicSchema<T> = T extends RuntimeMetadataManager<infer TPublic, infer _TSensitive> ? TPublic : never\nexport type SensitiveSchema<T> = T extends RuntimeMetadataManager<infer _TPublic, infer TSensitive> ? TSensitive : never\n\n/**\n * Creates a container for metadata collected at runtime.\n *\n * The container provides async-safe functions for extracting the gathered metadata, and for setting it.\n *\n */\nexport function createRuntimeMetadataContainer<\n TPublic extends AnyJson,\n TSensitive extends AnyJson = {[key: string]: never},\n>(): RuntimeMetadataManager<TPublic, TSensitive> {\n const raw: {sensitive: Partial<TSensitive>; public: Partial<TPublic>} = {\n sensitive: {},\n public: {},\n }\n const addPublic = (data: Partial<TPublic>) => {\n Object.assign(raw.public, data)\n }\n const addSensitive = (data: Partial<TSensitive>) => {\n Object.assign(raw.sensitive, data)\n }\n\n const addMetadata = async <T>(\n addFn: (data: Partial<T>) => void,\n getFn: ProvideMetadata<T>,\n onError: MetadataErrorHandling,\n ) => {\n const errorHandling = onError === 'auto' ? getMetadataErrorHandlingStrategy() : onError\n const getAndSet = async () => {\n const data = await getFn()\n addFn(data)\n }\n\n if (errorHandling === 'bubble') {\n await getAndSet()\n } else {\n try {\n await getAndSet()\n // eslint-disable-next-line no-catch-all/no-catch-all, @typescript-eslint/no-explicit-any\n } catch (error: any) {\n await sendErrorToBugsnag(error)\n }\n }\n }\n\n return {\n getAllPublic: () => {\n return {...raw.public}\n },\n getAllSensitive: () => {\n return {...raw.sensitive}\n },\n addPublic: async (getData: ProvideMetadata<TPublic>, onError: MetadataErrorHandling = 'auto') => {\n return addMetadata(addPublic, getData, onError)\n },\n addSensitive: async (getData: ProvideMetadata<TSensitive>, onError: MetadataErrorHandling = 'auto') => {\n return addMetadata(addSensitive, getData, onError)\n },\n }\n}\n\n// We want to track anything that ends up getting sent to monorail as `cmd_all_*` and\n// `cmd_app_*`\ntype CmdFieldsFromMonorail = PickByPrefix<MonorailEventPublic, 'cmd_all_'> &\n PickByPrefix<MonorailEventPublic, 'cmd_app_'>\n\nconst coreData = createRuntimeMetadataContainer<\n CmdFieldsFromMonorail,\n {\n commandStartOptions: {\n startTime: number\n startCommand: string\n startTopic?: string\n startArgs: string[]\n }\n }\n>()\n\nexport const {getAllPublic, getAllSensitive, addPublic, addSensitive} = coreData\n\nexport type Public = PublicSchema<typeof coreData>\nexport type Sensitive = SensitiveSchema<typeof coreData>\n"]}
|
|
1
|
+
{"version":3,"file":"metadata.js","sourceRoot":"","sources":["../src/metadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,wBAAwB,CAAA;AAGjD,OAAO,EAAC,kBAAkB,EAAC,MAAM,gCAAgC,CAAA;AAajE,SAAS,gCAAgC;IACvC,IAAI,UAAU,EAAE,EAAE;QAChB,OAAO,QAAQ,CAAA;KAChB;IACD,OAAO,iBAAiB,CAAA;AAC1B,CAAC;AAgBD;;;;;GAKG;AACH,MAAM,UAAU,8BAA8B;IAI5C,MAAM,GAAG,GAA+D;QACtE,SAAS,EAAE,EAAE;QACb,MAAM,EAAE,EAAE;KACX,CAAA;IACD,MAAM,SAAS,GAAG,CAAC,IAAsB,EAAE,EAAE;QAC3C,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IACjC,CAAC,CAAA;IACD,MAAM,YAAY,GAAG,CAAC,IAAyB,EAAE,EAAE;QACjD,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,CAAA;IACpC,CAAC,CAAA;IAED,MAAM,WAAW,GAAG,KAAK,EACvB,KAAiC,EACjC,KAAyB,EACzB,OAA8B,EAC9B,EAAE;QACF,MAAM,aAAa,GAAG,OAAO,KAAK,MAAM,CAAC,CAAC,CAAC,gCAAgC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAA;QACvF,MAAM,SAAS,GAAG,KAAK,IAAI,EAAE;YAC3B,MAAM,IAAI,GAAG,MAAM,KAAK,EAAE,CAAA;YAC1B,KAAK,CAAC,IAAI,CAAC,CAAA;QACb,CAAC,CAAA;QAED,IAAI,aAAa,KAAK,QAAQ,EAAE;YAC9B,MAAM,SAAS,EAAE,CAAA;SAClB;aAAM;YACL,IAAI;gBACF,MAAM,SAAS,EAAE,CAAA;gBACjB,yFAAyF;aAC1F;YAAC,OAAO,KAAU,EAAE;gBACnB,MAAM,kBAAkB,CAAC,KAAK,CAAC,CAAA;aAChC;SACF;IACH,CAAC,CAAA;IAED,OAAO;QACL,YAAY,EAAE,GAAG,EAAE;YACjB,OAAO,EAAC,GAAG,GAAG,CAAC,MAAM,EAAC,CAAA;QACxB,CAAC;QACD,eAAe,EAAE,GAAG,EAAE;YACpB,OAAO,EAAC,GAAG,GAAG,CAAC,SAAS,EAAC,CAAA;QAC3B,CAAC;QACD,SAAS,EAAE,KAAK,EAAE,OAAiC,EAAE,UAAiC,MAAM,EAAE,EAAE;YAC9F,OAAO,WAAW,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;QACjD,CAAC;QACD,YAAY,EAAE,KAAK,EAAE,OAAoC,EAAE,UAAiC,MAAM,EAAE,EAAE;YACpG,OAAO,WAAW,CAAC,YAAY,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;QACpD,CAAC;KACF,CAAA;AACH,CAAC;AAOD,MAAM,QAAQ,GAAG,8BAA8B,EAU5C,CAAA;AAEH,MAAM,CAAC,MAAM,EAAC,YAAY,EAAE,eAAe,EAAE,SAAS,EAAE,YAAY,EAAC,GAAG,QAAQ,CAAA","sourcesContent":["import {isUnitTest} from './environment/local.js'\nimport {AnyJson} from './private/common/json.js'\nimport {MonorailEventPublic} from './monorail.js'\nimport {sendErrorToBugsnag} from './public/node/error-handler.js'\nimport {PickByPrefix} from './typing/pick-by-prefix.js'\n\ntype ProvideMetadata<T> = () => Partial<T> | Promise<Partial<T>>\n\ntype MetadataErrorHandling =\n // Mute & report errors in production, throw them whilst testing\n | 'auto'\n // Errors are not reported to the user and do not stop execution, but they are reported to Bugsnag\n | 'mute-and-report'\n // Errors are not caught and will bubble out as normal\n | 'bubble'\n\nfunction getMetadataErrorHandlingStrategy(): 'mute-and-report' | 'bubble' {\n if (isUnitTest()) {\n return 'bubble'\n }\n return 'mute-and-report'\n}\n\nexport interface RuntimeMetadataManager<TPublic extends AnyJson, TSensitive extends AnyJson> {\n /** Add some public metadata -- this should not contain any PII */\n addPublic: (getData: ProvideMetadata<TPublic>, onError?: MetadataErrorHandling) => Promise<void>\n /** Add some potentially sensitive metadata -- this may include PII, but unnecessary data should never be tracked (this is a good fit for command args for instance) */\n addSensitive: (getData: ProvideMetadata<TSensitive>, onError?: MetadataErrorHandling) => Promise<void>\n /** Get a snapshot of the tracked public data */\n getAllPublic: () => Partial<TPublic>\n /** Get a snapshot of the tracked sensitive data */\n getAllSensitive: () => Partial<TSensitive>\n}\n\nexport type PublicSchema<T> = T extends RuntimeMetadataManager<infer TPublic, infer _TSensitive> ? TPublic : never\nexport type SensitiveSchema<T> = T extends RuntimeMetadataManager<infer _TPublic, infer TSensitive> ? TSensitive : never\n\n/**\n * Creates a container for metadata collected at runtime.\n *\n * The container provides async-safe functions for extracting the gathered metadata, and for setting it.\n *\n */\nexport function createRuntimeMetadataContainer<\n TPublic extends AnyJson,\n TSensitive extends AnyJson = {[key: string]: never},\n>(): RuntimeMetadataManager<TPublic, TSensitive> {\n const raw: {sensitive: Partial<TSensitive>; public: Partial<TPublic>} = {\n sensitive: {},\n public: {},\n }\n const addPublic = (data: Partial<TPublic>) => {\n Object.assign(raw.public, data)\n }\n const addSensitive = (data: Partial<TSensitive>) => {\n Object.assign(raw.sensitive, data)\n }\n\n const addMetadata = async <T>(\n addFn: (data: Partial<T>) => void,\n getFn: ProvideMetadata<T>,\n onError: MetadataErrorHandling,\n ) => {\n const errorHandling = onError === 'auto' ? getMetadataErrorHandlingStrategy() : onError\n const getAndSet = async () => {\n const data = await getFn()\n addFn(data)\n }\n\n if (errorHandling === 'bubble') {\n await getAndSet()\n } else {\n try {\n await getAndSet()\n // eslint-disable-next-line no-catch-all/no-catch-all, @typescript-eslint/no-explicit-any\n } catch (error: any) {\n await sendErrorToBugsnag(error)\n }\n }\n }\n\n return {\n getAllPublic: () => {\n return {...raw.public}\n },\n getAllSensitive: () => {\n return {...raw.sensitive}\n },\n addPublic: async (getData: ProvideMetadata<TPublic>, onError: MetadataErrorHandling = 'auto') => {\n return addMetadata(addPublic, getData, onError)\n },\n addSensitive: async (getData: ProvideMetadata<TSensitive>, onError: MetadataErrorHandling = 'auto') => {\n return addMetadata(addSensitive, getData, onError)\n },\n }\n}\n\n// We want to track anything that ends up getting sent to monorail as `cmd_all_*` and\n// `cmd_app_*`\ntype CmdFieldsFromMonorail = PickByPrefix<MonorailEventPublic, 'cmd_all_'> &\n PickByPrefix<MonorailEventPublic, 'cmd_app_'>\n\nconst coreData = createRuntimeMetadataContainer<\n CmdFieldsFromMonorail,\n {\n commandStartOptions: {\n startTime: number\n startCommand: string\n startTopic?: string\n startArgs: string[]\n }\n }\n>()\n\nexport const {getAllPublic, getAllSensitive, addPublic, addSensitive} = coreData\n\nexport type Public = PublicSchema<typeof coreData>\nexport type Sensitive = SensitiveSchema<typeof coreData>\n"]}
|
package/dist/monorail.d.ts
CHANGED
package/dist/monorail.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"monorail.js","sourceRoot":"","sources":["../src/monorail.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,WAAW,CAAA;AAC/B,OAAO,EAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAC,MAAM,aAAa,CAAA;AAIjD,MAAM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,EAAE,OAAO,EAAE,OAAO,EAAC,CAAA;KAChC;AACH,CAAC;AAED,MAAM,YAAY,GAAG,CAAC,WAAmB,EAAE,EAAE;IAC3C,OAAO;QACL,cAAc,EAAE,iCAAiC;QACjD,qCAAqC,EAAE,WAAW,CAAC,QAAQ,EAAE;QAC7D,kCAAkC,EAAE,WAAW,CAAC,QAAQ,EAAE;KAC3D,CAAA;AACH,CAAC,CAAA","sourcesContent":["import {fetch} from './http.js'\nimport {debug, content, token} from './output.js'\nimport {JsonMap} from './json.js'\nimport {DeepRequired} from './typing/deep-required.js'\n\nconst url = 'https://monorail-edge.shopifysvc.com/v1/produce'\n\ntype Optional<T> = T | null\n\n// This is the topic name of the main event we log to Monorail, the command tracker\nexport const MONORAIL_COMMAND_TOPIC = 'app_cli3_command/1.2' as const\n\nexport interface Schemas {\n [MONORAIL_COMMAND_TOPIC]: {\n sensitive: {\n args: string\n error_message?: Optional<string>\n app_name?: Optional<string>\n metadata?: Optional<string>\n store_fqdn?: Optional<string>\n\n // Dev related commands\n cmd_dev_tunnel_custom?: Optional<string>\n\n // Environment\n env_plugin_installed_all?: Optional<string>\n }\n public: {\n partner_id?: Optional<number>\n command: string\n project_type?: Optional<string>\n time_start: number\n time_end: number\n total_time: number\n success: boolean\n api_key?: Optional<string>\n cli_version: string\n uname: string\n ruby_version: string\n node_version: string\n is_employee: boolean\n store_fqdn_hash?: Optional<string>\n\n // Any and all commands\n cmd_all_alias_used?: Optional<string>\n cmd_all_launcher?: Optional<string>\n cmd_all_path_override?: Optional<boolean>\n cmd_all_path_override_hash?: Optional<string>\n cmd_all_plugin?: Optional<string>\n cmd_all_topic?: Optional<string>\n cmd_all_verbose?: Optional<boolean>\n\n // Any extension related command\n cmd_extensions_binary_from_source?: Optional<boolean>\n\n // Scaffolding related commands\n cmd_scaffold_required_auth?: Optional<boolean>\n cmd_scaffold_template_custom?: Optional<boolean>\n cmd_scaffold_template_flavor?: Optional<string>\n cmd_scaffold_type?: Optional<string>\n cmd_scaffold_type_category?: Optional<string>\n cmd_scaffold_type_gated?: Optional<boolean>\n cmd_scaffold_type_owner?: Optional<string>\n cmd_scaffold_used_prompts_for_type?: Optional<boolean>\n\n // Used in several but not all commands\n cmd_app_dependency_installation_skipped?: Optional<boolean>\n cmd_app_reset_used?: Optional<boolean>\n\n // Dev related commands\n cmd_dev_tunnel_type?: Optional<string>\n cmd_dev_tunnel_custom_hash?: Optional<string>\n cmd_dev_urls_updated?: Optional<boolean>\n\n // App setup\n app_extensions_any?: Optional<boolean>\n app_extensions_breakdown?: Optional<string>\n app_extensions_count?: Optional<number>\n app_extensions_custom_layout?: Optional<boolean>\n app_extensions_function_any?: Optional<boolean>\n app_extensions_function_count?: Optional<number>\n app_extensions_function_custom_layout?: Optional<boolean>\n app_extensions_theme_any?: Optional<boolean>\n app_extensions_theme_count?: Optional<number>\n app_extensions_theme_custom_layout?: Optional<boolean>\n app_extensions_ui_any?: Optional<boolean>\n app_extensions_ui_count?: Optional<number>\n app_extensions_ui_custom_layout?: Optional<boolean>\n app_name_hash?: Optional<string>\n app_path_hash?: Optional<string>\n app_scopes?: Optional<string>\n app_web_backend_any?: Optional<boolean>\n app_web_backend_count?: Optional<number>\n app_web_custom_layout?: Optional<boolean>\n app_web_framework?: Optional<string>\n app_web_frontend_any?: Optional<boolean>\n app_web_frontend_count?: Optional<number>\n\n // Environment\n env_ci?: Optional<boolean>\n env_ci_platform?: Optional<string>\n env_device_id?: Optional<string>\n env_package_manager?: Optional<string>\n env_package_manager_workspaces?: Optional<boolean>\n env_plugin_installed_any_custom?: Optional<boolean>\n env_plugin_installed_shopify?: Optional<string>\n env_shell?: Optional<string>\n env_web_ide?: Optional<string>\n env_cloud?: Optional<string>\n }\n }\n [schemaId: string]: {sensitive: JsonMap; public: JsonMap}\n}\n\n// In reality, we're normally most interested in just this from Schemas, so export it for ease of use.\n// The monorail schema itself has lots of optional values as it must be backwards-compatible. For our schema we want mandatory values instead.\nexport type MonorailEventPublic = DeepRequired<Schemas[typeof MONORAIL_COMMAND_TOPIC]['public']>\nexport type MonorailEventSensitive = Schemas[typeof MONORAIL_COMMAND_TOPIC]['sensitive']\n\ntype MonorailResult = {type: 'ok'} | {type: 'error'; message: string}\n\nexport async function publishEvent<TSchemaId extends keyof Schemas, TPayload extends Schemas[TSchemaId]>(\n schemaId: TSchemaId,\n publicData: TPayload['public'],\n sensitiveData: TPayload['sensitive'],\n): Promise<MonorailResult> {\n try {\n const currentTime = new Date().getTime()\n const payload = {...publicData, ...sensitiveData}\n const body = JSON.stringify({schema_id: schemaId, payload})\n const headers = buildHeaders(currentTime)\n\n const response = await fetch(url, {method: 'POST', body, headers})\n\n if (response.status === 200) {\n debug(content`Analytics event sent: ${token.json(payload)}`)\n return {type: 'ok'}\n } else {\n debug(`Failed to report usage analytics: ${response.statusText}`)\n return {type: 'error', message: response.statusText}\n }\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (error) {\n let message = 'Failed to report usage analytics'\n if (error instanceof Error) {\n message = message.concat(`: ${error.message}`)\n }\n debug(message)\n return {type: 'error', message}\n }\n}\n\nconst buildHeaders = (currentTime: number) => {\n return {\n 'Content-Type': 'application/json; charset=utf-8',\n 'X-Monorail-Edge-Event-Created-At-Ms': currentTime.toString(),\n 'X-Monorail-Edge-Event-Sent-At-Ms': currentTime.toString(),\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"monorail.js","sourceRoot":"","sources":["../src/monorail.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,WAAW,CAAA;AAC/B,OAAO,EAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAC,MAAM,aAAa,CAAA;AAIjD,MAAM,GAAG,GAAG,iDAAiD,CAAA;AAI7D,mFAAmF;AACnF,MAAM,CAAC,MAAM,sBAAsB,GAAG,sBAA+B,CAAA;AA+GrE,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,QAAmB,EACnB,UAA8B,EAC9B,aAAoC;IAEpC,IAAI;QAC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D,kCAAkC,EAAE,WAAW,CAAC,QAAQ,EAAE;KAC3D,CAAA;AACH,CAAC,CAAA","sourcesContent":["import {fetch} from './http.js'\nimport {debug, content, token} from './output.js'\nimport {JsonMap} from './private/common/json.js'\nimport {DeepRequired} from './typing/deep-required.js'\n\nconst url = 'https://monorail-edge.shopifysvc.com/v1/produce'\n\ntype Optional<T> = T | null\n\n// This is the topic name of the main event we log to Monorail, the command tracker\nexport const MONORAIL_COMMAND_TOPIC = 'app_cli3_command/1.2' as const\n\nexport interface Schemas {\n [MONORAIL_COMMAND_TOPIC]: {\n sensitive: {\n args: string\n error_message?: Optional<string>\n app_name?: Optional<string>\n metadata?: Optional<string>\n store_fqdn?: Optional<string>\n\n // Dev related commands\n cmd_dev_tunnel_custom?: Optional<string>\n\n // Environment\n env_plugin_installed_all?: Optional<string>\n }\n public: {\n partner_id?: Optional<number>\n command: string\n project_type?: Optional<string>\n time_start: number\n time_end: number\n total_time: number\n success: boolean\n api_key?: Optional<string>\n cli_version: string\n uname: string\n ruby_version: string\n node_version: string\n is_employee: boolean\n store_fqdn_hash?: Optional<string>\n\n // Any and all commands\n cmd_all_alias_used?: Optional<string>\n cmd_all_launcher?: Optional<string>\n cmd_all_path_override?: Optional<boolean>\n cmd_all_path_override_hash?: Optional<string>\n cmd_all_plugin?: Optional<string>\n cmd_all_topic?: Optional<string>\n cmd_all_verbose?: Optional<boolean>\n\n // Any extension related command\n cmd_extensions_binary_from_source?: Optional<boolean>\n\n // Scaffolding related commands\n cmd_scaffold_required_auth?: Optional<boolean>\n cmd_scaffold_template_custom?: Optional<boolean>\n cmd_scaffold_template_flavor?: Optional<string>\n cmd_scaffold_type?: Optional<string>\n cmd_scaffold_type_category?: Optional<string>\n cmd_scaffold_type_gated?: Optional<boolean>\n cmd_scaffold_type_owner?: Optional<string>\n cmd_scaffold_used_prompts_for_type?: Optional<boolean>\n\n // Used in several but not all commands\n cmd_app_dependency_installation_skipped?: Optional<boolean>\n cmd_app_reset_used?: Optional<boolean>\n\n // Dev related commands\n cmd_dev_tunnel_type?: Optional<string>\n cmd_dev_tunnel_custom_hash?: Optional<string>\n cmd_dev_urls_updated?: Optional<boolean>\n\n // App setup\n app_extensions_any?: Optional<boolean>\n app_extensions_breakdown?: Optional<string>\n app_extensions_count?: Optional<number>\n app_extensions_custom_layout?: Optional<boolean>\n app_extensions_function_any?: Optional<boolean>\n app_extensions_function_count?: Optional<number>\n app_extensions_function_custom_layout?: Optional<boolean>\n app_extensions_theme_any?: Optional<boolean>\n app_extensions_theme_count?: Optional<number>\n app_extensions_theme_custom_layout?: Optional<boolean>\n app_extensions_ui_any?: Optional<boolean>\n app_extensions_ui_count?: Optional<number>\n app_extensions_ui_custom_layout?: Optional<boolean>\n app_name_hash?: Optional<string>\n app_path_hash?: Optional<string>\n app_scopes?: Optional<string>\n app_web_backend_any?: Optional<boolean>\n app_web_backend_count?: Optional<number>\n app_web_custom_layout?: Optional<boolean>\n app_web_framework?: Optional<string>\n app_web_frontend_any?: Optional<boolean>\n app_web_frontend_count?: Optional<number>\n\n // Environment\n env_ci?: Optional<boolean>\n env_ci_platform?: Optional<string>\n env_device_id?: Optional<string>\n env_package_manager?: Optional<string>\n env_package_manager_workspaces?: Optional<boolean>\n env_plugin_installed_any_custom?: Optional<boolean>\n env_plugin_installed_shopify?: Optional<string>\n env_shell?: Optional<string>\n env_web_ide?: Optional<string>\n env_cloud?: Optional<string>\n }\n }\n [schemaId: string]: {sensitive: JsonMap; public: JsonMap}\n}\n\n// In reality, we're normally most interested in just this from Schemas, so export it for ease of use.\n// The monorail schema itself has lots of optional values as it must be backwards-compatible. For our schema we want mandatory values instead.\nexport type MonorailEventPublic = DeepRequired<Schemas[typeof MONORAIL_COMMAND_TOPIC]['public']>\nexport type MonorailEventSensitive = Schemas[typeof MONORAIL_COMMAND_TOPIC]['sensitive']\n\ntype MonorailResult = {type: 'ok'} | {type: 'error'; message: string}\n\nexport async function publishEvent<TSchemaId extends keyof Schemas, TPayload extends Schemas[TSchemaId]>(\n schemaId: TSchemaId,\n publicData: TPayload['public'],\n sensitiveData: TPayload['sensitive'],\n): Promise<MonorailResult> {\n try {\n const currentTime = new Date().getTime()\n const payload = {...publicData, ...sensitiveData}\n const body = JSON.stringify({schema_id: schemaId, payload})\n const headers = buildHeaders(currentTime)\n\n const response = await fetch(url, {method: 'POST', body, headers})\n\n if (response.status === 200) {\n debug(content`Analytics event sent: ${token.json(payload)}`)\n return {type: 'ok'}\n } else {\n debug(`Failed to report usage analytics: ${response.statusText}`)\n return {type: 'error', message: response.statusText}\n }\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (error) {\n let message = 'Failed to report usage analytics'\n if (error instanceof Error) {\n message = message.concat(`: ${error.message}`)\n }\n debug(message)\n return {type: 'error', message}\n }\n}\n\nconst buildHeaders = (currentTime: number) => {\n return {\n 'Content-Type': 'application/json; charset=utf-8',\n 'X-Monorail-Edge-Event-Created-At-Ms': currentTime.toString(),\n 'X-Monorail-Edge-Event-Sent-At-Ms': currentTime.toString(),\n }\n}\n"]}
|
package/dist/os.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
export declare const username: (platform?: NodeJS.Platform) => Promise<string | null>;
|
|
3
4
|
/**
|
|
4
5
|
* Returns the platform and architecture.
|
|
5
6
|
* @returns Returns the current platform and architecture.
|
|
6
7
|
*/
|
|
7
|
-
export declare const platformAndArch: (platform?:
|
|
8
|
+
export declare const platformAndArch: (platform?: NodeJS.Platform) => {
|
|
8
9
|
platform: string;
|
|
9
10
|
arch: string;
|
|
10
11
|
};
|
package/dist/os.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
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';
|
|
3
|
+
import { userInfo as osUserInfo, arch as osArch } from 'os';
|
|
5
4
|
const getEnvironmentVariable = () => {
|
|
6
5
|
const { env } = process;
|
|
7
6
|
return env.SUDO_USER || env.C9_USER || env.LOGNAME || env.USER || env.LNAME || env.USERNAME;
|
|
@@ -20,7 +19,7 @@ const makeUsernameFromId = (userId) => `no-username-${userId}`;
|
|
|
20
19
|
// This code has been vendored from https://github.com/sindresorhus/username
|
|
21
20
|
// because adding it as a transtive dependency causes conflicts with other
|
|
22
21
|
// packages that haven't been yet migrated to the latest version.
|
|
23
|
-
export const username = async (platform =
|
|
22
|
+
export const username = async (platform = process.platform) => {
|
|
24
23
|
debug(content `Obtaining user name...`);
|
|
25
24
|
const environmentVariable = getEnvironmentVariable();
|
|
26
25
|
if (environmentVariable) {
|
|
@@ -56,7 +55,7 @@ export const username = async (platform = processPlatform) => {
|
|
|
56
55
|
* Returns the platform and architecture.
|
|
57
56
|
* @returns Returns the current platform and architecture.
|
|
58
57
|
*/
|
|
59
|
-
export const platformAndArch = (platform =
|
|
58
|
+
export const platformAndArch = (platform = process.platform) => {
|
|
60
59
|
let arch = osArch();
|
|
61
60
|
if (arch === 'x64') {
|
|
62
61
|
arch = 'amd64';
|