@shopify/cli-kit
Advanced tools
Comparing version
# @shopify/cli-kit | ||
## 3.1.0 | ||
### Minor Changes | ||
- d17770e8: Massage error stacktraces to be properly formatted on Bugsnag | ||
- d17770e8: Not report unhandled errors that go straight to the Node runtime | ||
### Patch Changes | ||
- 740f73ac: Added a retrying implementation to the method that obtains a random local port. Occasionally that third party logic failed in the middle of the execution of a command and abort the process. Running the command for a second time solved that temporary problem | ||
- de8ee02d: [FEATURE] Add query to fetch shop by domain | ||
- 45f0f0b9: Bump theme-check version | ||
## 3.0.27 | ||
@@ -4,0 +17,0 @@ |
interface startOptions { | ||
command: string; | ||
args: string; | ||
args: string[]; | ||
currentTime?: number; | ||
@@ -11,2 +11,4 @@ } | ||
export declare const reportEvent: (options?: ReportEventOptions) => Promise<void>; | ||
export declare type ProjectType = 'node' | 'php' | 'ruby' | undefined; | ||
export declare function getProjectType(directory: string): Promise<ProjectType>; | ||
export {}; |
@@ -5,6 +5,6 @@ /* eslint-disable @typescript-eslint/naming-convention */ | ||
import { platformAndArch } from './os.js'; | ||
import { join, resolve } from './path.js'; | ||
import { exists as fileExists } from './file.js'; | ||
import { join as joinPath, resolve } from './path.js'; | ||
import { version as rubyVersion } from './node/ruby.js'; | ||
import { debug, content, token } from './output.js'; | ||
import { getProjectType } from './dependency.js'; | ||
import constants from './constants.js'; | ||
@@ -79,5 +79,5 @@ import { cliKitStore } from './store.js'; | ||
payload: { | ||
project_type: await getProjectType(join(directory, 'web')), | ||
project_type: await getProjectType(joinPath(directory, 'web')), | ||
command: startCommand, | ||
args: startArgs, | ||
args: startArgs.join(' '), | ||
time_start: startTime, | ||
@@ -98,2 +98,17 @@ time_end: currentTime, | ||
}; | ||
export async function getProjectType(directory) { | ||
const nodeConfigFile = joinPath(directory, 'package.json'); | ||
const rubyConfigFile = joinPath(directory, 'Gemfile'); | ||
const phpConfigFile = joinPath(directory, 'composer.json'); | ||
if (await fileExists(nodeConfigFile)) { | ||
return 'node'; | ||
} | ||
else if (await fileExists(rubyConfigFile)) { | ||
return 'ruby'; | ||
} | ||
else if (await fileExists(phpConfigFile)) { | ||
return 'php'; | ||
} | ||
return undefined; | ||
} | ||
//# sourceMappingURL=analytics.js.map |
@@ -22,1 +22,2 @@ export * from './find_org.js'; | ||
export * from './find_org_basic.js'; | ||
export * from './find_store_by_domain.js'; |
@@ -22,2 +22,3 @@ export * from './find_org.js'; | ||
export * from './find_org_basic.js'; | ||
export * from './find_store_by_domain.js'; | ||
//# sourceMappingURL=index.js.map |
@@ -6,3 +6,2 @@ export { default as constants } from './constants.js'; | ||
export * as cli from './cli.js'; | ||
export * as dependency from './dependency.js'; | ||
export * as environment from './environment.js'; | ||
@@ -9,0 +8,0 @@ export * as error from './error.js'; |
@@ -6,3 +6,2 @@ export { default as constants } from './constants.js'; | ||
export * as cli from './cli.js'; | ||
export * as dependency from './dependency.js'; | ||
export * as environment from './environment.js'; | ||
@@ -9,0 +8,0 @@ export * as error from './error.js'; |
// CLI | ||
import { findUpAndReadPackageJson } from './node-package-manager.js'; | ||
import { initializeCliKitStore } from '../store.js'; | ||
@@ -8,4 +9,4 @@ import { initiateLogging } from '../output.js'; | ||
import { mapper as errorMapper, handler as errorHandler, AbortSilent, shouldReport as shouldReportError, } from '../error.js'; | ||
import { findUpAndReadPackageJson } from '../dependency.js'; | ||
import { moduleDirectory } from '../path.js'; | ||
import { moduleDirectory, normalize } from '../path.js'; | ||
import StackTracey from 'stacktracey'; | ||
import { run, settings, flush } from '@oclif/core'; | ||
@@ -26,2 +27,3 @@ import Bugsnag from '@bugsnag/js'; | ||
Bugsnag.start({ | ||
appType: 'node', | ||
apiKey: bugsnagApiKey, | ||
@@ -31,2 +33,3 @@ logger: null, | ||
autoTrackSessions: false, | ||
autoDetectErrors: false, | ||
}); | ||
@@ -42,6 +45,6 @@ } | ||
return errorMapper(error) | ||
.then(reportError) | ||
.then((error) => { | ||
return errorHandler(error); | ||
}) | ||
.then(reportError) | ||
.then(() => { | ||
@@ -76,8 +79,10 @@ process.exit(1); | ||
mappedError = new Error(errorToReport.message); | ||
if (errorToReport.stack) { | ||
// For mac/linux, remove `file:///` from stacktrace | ||
// For windows, remove `file:///C:/` from stacktrace | ||
const regex = '\\((.*node_modules.)(@shopify.)?'; | ||
mappedError.stack = errorToReport.stack.replace(new RegExp(regex, 'g'), '('); | ||
} | ||
const mappedStacktrace = new StackTracey(errorToReport) | ||
.clean() | ||
.items.map((item) => { | ||
const filePath = normalize(item.file).replace('file:/', '/').replace('C:/', ''); | ||
return ` at ${item.callee} (${filePath}:${item.line}:${item.column})`; | ||
}) | ||
.join('\n'); | ||
mappedError.stack = `Error: ${errorToReport.message}\n${mappedStacktrace}`; | ||
} | ||
@@ -84,0 +89,0 @@ else if (typeof errorToReport === 'string') { |
@@ -13,3 +13,3 @@ import * as file from '../file.js'; | ||
const RubyCLIVersion = '2.16.0'; | ||
const ThemeCheckVersion = '1.10.2'; | ||
const ThemeCheckVersion = '1.10.3'; | ||
const MinBundlerVersion = '2.3.8'; | ||
@@ -16,0 +16,0 @@ const MinRubyVersion = '2.3.0'; |
/// <reference types="node" /> | ||
import { Fatal } from './error.js'; | ||
import { DependencyManager } from './dependency.js'; | ||
import { PackageManager } from './node/node-package-manager.js'; | ||
import { AbortSignal } from 'abort-controller'; | ||
@@ -48,3 +48,3 @@ import { Writable } from 'node:stream'; | ||
green: (value: Message) => ContentToken; | ||
packagejsonScript: (dependencyManager: DependencyManager, scriptName: string, ...scriptArgs: string[]) => ContentToken; | ||
packagejsonScript: (packageManager: PackageManager, scriptName: string, ...scriptArgs: string[]) => ContentToken; | ||
successIcon: () => ContentToken; | ||
@@ -143,2 +143,9 @@ failIcon: () => ContentToken; | ||
export declare function pageLogs(): Promise<void>; | ||
/** | ||
* | ||
* @param packageManager {PackageManager} The package manager that is being used. | ||
* @param version {string} The version to update to | ||
* @returns {te} | ||
*/ | ||
export declare function getOutputUpdateCLIReminder(packageManager: PackageManager, version: string): string; | ||
export {}; |
@@ -8,3 +8,3 @@ /* eslint-disable no-console */ | ||
import { page } from './system.js'; | ||
import { colors } from './colors.js'; | ||
import { colors } from './node/colors.js'; | ||
import terminalLink from 'terminal-link'; | ||
@@ -103,4 +103,4 @@ import StackTracey from 'stacktracey'; | ||
}, | ||
packagejsonScript: (dependencyManager, scriptName, ...scriptArgs) => { | ||
return new ContentToken(formatPackageManagerCommand(dependencyManager, scriptName, scriptArgs), {}, ContentTokenType.Command); | ||
packagejsonScript: (packageManager, scriptName, ...scriptArgs) => { | ||
return new ContentToken(formatPackageManagerCommand(packageManager, scriptName, scriptArgs), {}, ContentTokenType.Command); | ||
}, | ||
@@ -114,4 +114,4 @@ successIcon: () => { | ||
}; | ||
function formatPackageManagerCommand(dependencyManager, scriptName, scriptArgs) { | ||
switch (dependencyManager) { | ||
function formatPackageManagerCommand(packageManager, scriptName, scriptArgs) { | ||
switch (packageManager) { | ||
case 'yarn': { | ||
@@ -123,3 +123,3 @@ const pieces = ['yarn', scriptName, ...scriptArgs]; | ||
case 'npm': { | ||
const pieces = [dependencyManager, 'run', scriptName]; | ||
const pieces = [packageManager, 'run', scriptName]; | ||
if (scriptArgs.length > 0) { | ||
@@ -370,3 +370,3 @@ pieces.push('--'); | ||
if (stack.items.length !== 0) { | ||
outputString += `\n${padding}${colors.bold('Stack trace:')}`; | ||
outputString += `\n${padding}${colors.bold('Stack trace:')}\n`; | ||
const stackLines = stack.asTable({}).split('\n'); | ||
@@ -509,3 +509,13 @@ for (const stackLine of stackLines) { | ||
} | ||
/** | ||
* | ||
* @param packageManager {PackageManager} The package manager that is being used. | ||
* @param version {string} The version to update to | ||
* @returns {te} | ||
*/ | ||
export function getOutputUpdateCLIReminder(packageManager, version) { | ||
const updateCommand = token.packagejsonScript(packageManager, 'shopify', 'upgrade'); | ||
return content `💡 Version ${version} available! Run ${updateCommand}`.value; | ||
} | ||
/* eslint-enable no-console */ | ||
//# sourceMappingURL=output.js.map |
import { debug, content, token } from './output.js'; | ||
import { Abort } from './error.js'; | ||
import { sleep } from './system.js'; | ||
import * as port from 'get-port-please'; | ||
@@ -9,6 +11,26 @@ /** | ||
debug(content `Getting a random port...`); | ||
const randomPort = await port.getRandomPort(); | ||
const randomPort = retryOnError(() => port.getRandomPort()); | ||
debug(content `Random port obtained: ${token.raw(`${randomPort}`)}`); | ||
return randomPort; | ||
} | ||
async function retryOnError(execute, maxTries = 5, waitTimeInSeconds = 1) { | ||
let retryCount = 1; | ||
while (true) { | ||
try { | ||
// eslint-disable-next-line no-await-in-loop | ||
return await execute(); | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
} | ||
catch (error) { | ||
if (retryCount++ < maxTries) { | ||
debug(content `Unknown problem getting a random port: ${error.message}`); | ||
// eslint-disable-next-line no-await-in-loop | ||
await sleep(waitTimeInSeconds); | ||
} | ||
else { | ||
throw new Abort(error.message); | ||
} | ||
} | ||
} | ||
} | ||
//# sourceMappingURL=port.js.map |
// Enquirer types are totally broken so we need to disable typescript checks for this file | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-nocheck | ||
import { colors } from '../colors.js'; | ||
import { colors } from '../node/colors.js'; | ||
import enquirer from 'enquirer'; | ||
@@ -6,0 +6,0 @@ export class AutoComplete extends enquirer.AutoComplete { |
// Enquirer types are totally broken so we need to disable typescript checks for this file | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-nocheck | ||
import { colors } from '../colors.js'; | ||
import { colors } from '../node/colors.js'; | ||
import enquirer from 'enquirer'; | ||
@@ -6,0 +6,0 @@ export class Input extends enquirer.StringPrompt { |
// Enquirer types are totally broken so we need to disable typescript checks for this file | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-nocheck | ||
import { colors } from '../colors.js'; | ||
import { colors } from '../node/colors.js'; | ||
import enquirer from 'enquirer'; | ||
@@ -6,0 +6,0 @@ export class Select extends enquirer.Select { |
import { content, token, debug } from './output.js'; | ||
import { moduleDirectory } from './path.js'; | ||
import { Bug } from './error.js'; | ||
import { findUpAndReadPackageJson } from './dependency.js'; | ||
import { findUpAndReadPackageJson } from './node/node-package-manager.js'; | ||
import latestVersion from 'latest-version'; | ||
@@ -6,0 +6,0 @@ export const PackageJsonVersionNotFoundError = (packageJsonPath) => { |
{ | ||
"name": "@shopify/cli-kit", | ||
"version": "3.0.27", | ||
"version": "3.1.0", | ||
"private": false, | ||
@@ -24,2 +24,6 @@ "description": "A set of utilities, interfaces, and models that are common across all the platform features", | ||
}, | ||
"./common/*": { | ||
"node": "./dist/common/*.js", | ||
"types": "./dist/common/*.d.ts" | ||
}, | ||
"./testing/*": { | ||
@@ -55,3 +59,3 @@ "node": "./dist/testing/*.js", | ||
"engines": { | ||
"node": "^14.13.1 || ^16.0.0 || ^17.0.0 || ^18.0.0" | ||
"node": ">=14.13.1" | ||
}, | ||
@@ -118,4 +122,4 @@ "os": [ | ||
"@types/semver": "^7.3.9", | ||
"vitest": "^0.15.1" | ||
"vitest": "^0.17.1" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
764484
1.73%286
1.06%6863
2.71%