-
Notifications
You must be signed in to change notification settings - Fork 32
refactor: comprehensive code cleanup and modernization #172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
- Streamline DiagnosticReport class and improve property handling - Update FolderDetails class for better async file handling and directory management - Clean up index exports for better readability - Simplify interfaces for app categories and login info - Enhance unicodeSymbols for better structure - Optimize VariousUtils class methods for clarity and performance - Adjust template files for consistent formatting and readability - Add typings for 'conf' and 'fetch-with-proxy' modules - Comment out deploy command tests for future implementation - Update package and watch command tests for consistency - Clean up init.js and simplify tsconfig configurations - Update main tsconfig for ES2022 compatibility and stricter checks - Remove deprecated tslint.json file This refactoring improves code maintainability, performance, and follows modern TypeScript best practices while ensuring consistent formatting across the codebase.
…ed token handling
- Removed unused dependencies from package.json and package-lock.json, including figures, open, pascal-case, @types/inquirer, and others. - Refactored import statements to use local implementations of pascalCase and openExternal. - Updated the create and watch commands to utilize the new openExternal function for opening URLs. - Introduced a new textTransforms module for the pascalCase function. - Enhanced folderDetails to use unicode symbols for better logging output. - Cleaned up the cloudAuth module to use the new openExternal function.
- Removed the usage of fetch-with-proxy and form-data from the project. - Replaced file reading and uploading logic with native Node.js fs and File API. - Updated the server implementation in cloudAuth to use the native http module. - Adjusted TypeScript typings and configuration to reflect the removal of fetch-with-proxy. - Enhanced error handling and server lifecycle management in cloudAuth.
- Removed appJsonSchema and its usage in favor of a new appJsonValidator using zod. - Introduced a new validation structure for app.json using zod's schema validation. - Updated FolderDetails to report validation issues using the new zod-based validator. - Refactored CloudAuth to manage configuration storage with encryption and improved file handling. - Cleaned up package.json by removing unused dependencies and adding zod. - Added a minimal zod implementation for app.json validation.
| if (flags.update) { | ||
| url += `/${fd.info.id}`; | ||
| } | ||
| const res = await fetch(url, { |
Check warning
Code scanning / CodeQL
File data in outbound network request Medium
file data
| throw new Error('') | ||
| } | ||
|
|
||
| const response = await fetch(normalizeUrl(url, '/api/info')) |
Check warning
Code scanning / CodeQL
File data in outbound network request Medium
file data
|
|
||
| // expects the `path` to start with the / | ||
|
|
||
| authResult = await fetch(normalizeUrl(url, '/api/v1/login'), { |
Check warning
Code scanning / CodeQL
File data in outbound network request Medium
file data
| headers: { | ||
| 'Content-Type': 'application/json', | ||
| }, | ||
| body: JSON.stringify(credentials), |
Check warning
Code scanning / CodeQL
File data in outbound network request Medium
file data
| const token = typeof flags.token === 'string' ? flags.token : undefined | ||
| const userId = typeof flags.userId === 'string' ? flags.userId : undefined | ||
|
|
||
| const verificationResult = await fetch(normalizeUrl(url, '/api/v1/me'), { |
Check warning
Code scanning / CodeQL
File data in outbound network request Medium
file data
| headers: { | ||
| 'Content-Type': 'application/json', | ||
| }, | ||
| body: JSON.stringify(credentials), |
Check warning
Code scanning / CodeQL
File data in outbound network request Medium
file data
| const token = typeof flags.token === 'string' ? flags.token : undefined | ||
| const userId = typeof flags.userId === 'string' ? flags.userId : undefined | ||
|
|
||
| const verificationResult = await fetch(normalizeUrl(url, '/api/v1/me'), { |
Check warning
Code scanning / CodeQL
File data in outbound network request Medium
file data
| headers: { | ||
| 'Content-Type': 'application/json', | ||
| 'X-Auth-Token': token ?? '', | ||
| 'X-User-Id': userId ?? '', | ||
| }, |
Check warning
Code scanning / CodeQL
File data in outbound network request Medium
file data
| throw new Error('Invalid authentication response') | ||
| } | ||
|
|
||
| const deployResult = await fetch(normalizeUrl(url, endpoint), { |
Check warning
Code scanning / CodeQL
File data in outbound network request Medium
file data
Outbound network request depends on
file data
| headers: { | ||
| 'X-Auth-Token': authResult.data.authToken, | ||
| 'X-User-Id': authResult.data.userId, | ||
| }, |
Check warning
Code scanning / CodeQL
File data in outbound network request Medium
This pull request modernizes and upgrades the Rocket.Chat Apps CLI project, focusing on updating dependencies, streamlining configuration, and improving code quality and maintainability. The changes include major dependency upgrades, migration to newer CLI and linting tools, and updates to scripts and documentation to reflect these improvements.
Dependency and Tooling Upgrades
package.json(including@oclif/core,@rocket.chat/apps-engine,chalk,conf,typescript, and others) to their latest versions, and removed deprecated packages such as@oclif/command,cli-ux, anduuid. Also updated Node.js engine requirement to>=22.0.0.src/commands/create.ts,src/commands/deploy.ts) from@oclif/commandandcli-uxto@oclif/coreand@inquirer/prompts, refactored to use modern APIs, and replaced deprecated logic (e.g., usingrandomUUIDinstead ofuuid). [1] [2]Linting and Formatting Improvements
.prettierrc.js,eslint.config.js) with recommended settings and integrated them into the project scripts for code formatting and linting. [1] [2].prettierignorefile to exclude build and dependency directories from formatting.Scripts and Configuration Updates
package.jsonscripts to use the new linting and formatting tools, removed TSLint, and refactored build/test commands for clarity and compatibility with upgraded dependencies.package.jsonto reflect new directory structure and options, includingdirname,topicSeparator, and plugin settings.Documentation Updates
README.mdformatting and updated instructions to reflect new CLI usage and configuration options. [1] [2] [3] [4]References:
[1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]