-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(create-catalyst): enhance CLI commands and update Jest confi…
…guration - Updated Jest configuration to include source maps and module type settings. - Refactored CLI commands to utilize a dependency injection container for better service management. - Enhanced the 'create' command with additional options for BigCommerce integration. - Improved error handling in CLI commands for better user feedback. - Updated the 'init' command to connect to existing BigCommerce channels with improved environment variable configuration. - Added telemetry management options to the CLI. These changes improve the overall structure and usability of the CLI tool, making it more robust and user-friendly.
- Loading branch information
1 parent
1c9b880
commit 2bcf3f1
Showing
21 changed files
with
1,149 additions
and
400 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,25 @@ | ||
module.exports = { | ||
transformIgnorePatterns: [], | ||
transformIgnorePatterns: [ | ||
'node_modules/(?!(fs-extra|@inquirer|chalk|commander|conf|dotenv|giget|lodash.kebabcase|nypm|ora|semver|std-env|zod|zod-validation-error)/)', | ||
], | ||
transform: { | ||
'^.+\\.(t|j)s?$': '@swc/jest', | ||
'^.+\\.(t|j)s?$': ['@swc/jest', { | ||
sourceMaps: true, | ||
module: { | ||
type: 'commonjs' | ||
}, | ||
jsc: { | ||
target: 'es2021', | ||
parser: { | ||
syntax: 'typescript', | ||
tsx: false, | ||
decorators: true, | ||
}, | ||
}, | ||
}] | ||
}, | ||
moduleNameMapper: { | ||
'^chalk$': '<rootDir>/src/test-mocks/chalk.ts', | ||
}, | ||
setupFiles: ['<rootDir>/src/test/setup.ts'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { BigCommerceServiceImpl } from './services/bigcommerce'; | ||
import { GitServiceImpl } from './services/git'; | ||
import { ProjectServiceImpl } from './services/project'; | ||
|
||
interface Config { | ||
bigCommerceHostname: string; | ||
cliApiHostname: string; | ||
} | ||
|
||
interface Container { | ||
getProjectService: () => ProjectServiceImpl; | ||
} | ||
|
||
export function createContainer(config: Config): Container { | ||
const gitService = new GitServiceImpl(); | ||
const bigCommerceService = new BigCommerceServiceImpl({ | ||
bigCommerceApiUrl: `https://api.${config.bigCommerceHostname}`, | ||
bigCommerceAuthUrl: `https://login.${config.bigCommerceHostname}`, | ||
cliApiUrl: `https://${config.cliApiHostname}`, | ||
}); | ||
|
||
return { | ||
getProjectService: () => new ProjectServiceImpl(gitService, bigCommerceService), | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { CatalystError } from './catalyst-error'; | ||
|
||
export class AuthenticationError extends CatalystError { | ||
constructor(message: string) { | ||
super(message, 'AUTHENTICATION_ERROR'); | ||
this.name = 'AuthenticationError'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export class CatalystError extends Error { | ||
constructor( | ||
message: string, | ||
public code: string, | ||
) { | ||
super(message); | ||
this.name = 'CatalystError'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { CatalystError } from './catalyst-error'; | ||
|
||
export class DependencyError extends CatalystError { | ||
constructor(message: string) { | ||
super(message, 'DEPENDENCY_ERROR'); | ||
this.name = 'DependencyError'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export class ValidationError extends Error { | ||
constructor(message: string) { | ||
super(message); | ||
Object.setPrototypeOf(this, ValidationError.prototype); | ||
this.name = 'ValidationError'; | ||
} | ||
} |
Oops, something went wrong.