Skip to content
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

feat: add local module cache to project-access #2066

Merged
merged 30 commits into from
Jul 9, 2024

Conversation

Klaus-Keller
Copy link
Contributor

@Klaus-Keller Klaus-Keller commented Jun 24, 2024

Add feature to locally cache node modules. First consumer of this is specification to cache local versions of @sap/ux-specification.

The cache for node modules is located at ~/.fioritools/module-cache. A folder structure including scope, name, and version will be created for each cached module. For instance, module @scope/[email protected] will installed in ~/.fioritools/module-cache/@scope/module/1.2.3 which will result in following folder structure:

~
└── .fioritools
    └── module-cache
        └── @scope
            └── module
                └── 1.2.3
                    ├── node_modules
                    │   └── @scope
                    │       └── module
                    │            ...
                    ├── package-lock.json
                    └── package.json

New public exported functions:

/**
 * Loads and return specification from project or cache.
 * 1. if package.json contains devDependency to specification, attempts to load from project.
 * 2. if not in package.json of project, attempts to load from cache.
 *
 * @param root - root path of the project/app
 * @param [options] - optional options
 * @param [options.logger] - logger instance
 * @returns - specification instance
 */
export async function getSpecification<T>(root: string, options?: { logger?: Logger }): Promise<T> 

and

/**
 * Refreshes the specification dist-tags cache. Also cleans specification modules in cache that are not required anymore.
 *
 * @param [options] - optional options, like logger
 * @param [options.logger] - logger instance
 */
export async function refreshSpecificationDistTags(options?: { logger?: Logger }): Promise<void>

Copy link

changeset-bot bot commented Jun 24, 2024

🦋 Changeset detected

Latest commit: 499a9c5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 18 packages
Name Type
@sap-ux/project-access Minor
@sap-ux/abap-deploy-config-writer Patch
@sap-ux/adp-tooling Patch
@sap-ux/annotation-generator Patch
@sap-ux/app-config-writer Patch
@sap-ux/cap-config-writer Patch
@sap-ux/cards-editor-middleware Patch
@sap-ux/create Patch
@sap-ux/environment-check Patch
@sap-ux/fiori-annotation-api Patch
@sap-ux/fiori-generator-shared Patch
@sap-ux/odata-service-inquirer Patch
@sap-ux/preview-middleware Patch
@sap-ux/telemetry Patch
@sap-ux/ui5-application-inquirer Patch
@sap-ux/ui5-library-reference-inquirer Patch
@sap-ux/ui5-library-reference-writer Patch
@sap-ux/ui5-library-writer Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Klaus-Keller Klaus-Keller marked this pull request as ready for review July 5, 2024 09:02
@Klaus-Keller Klaus-Keller requested a review from a team as a code owner July 5, 2024 09:02
devinea
devinea previously approved these changes Jul 5, 2024
Copy link
Member

@devinea devinea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice feature. Clearly implemented and tested.
Maybe it could be a separate module by itself, but fine for now.
changeset ✅

@Klaus-Keller
Copy link
Contributor Author

Maybe it could be a separate module by itself, but fine for now.

While implementing this in project-access I was thinking the same. Should be easily possible to extract into an own module if required. For now I think it could remain with project access.

Copy link

sonarcloud bot commented Jul 5, 2024

Please retry analysis of this Pull-Request directly on SonarCloud

Copy link
Contributor

@johannes-kolbe johannes-kolbe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

  • code is easy to understand and structured
  • tests and great coverage provided
  • Manual test ok (consumption via tools-suite with VSIX)
    • check, change, reload of modules

Copy link

sonarcloud bot commented Jul 8, 2024

@Klaus-Keller Klaus-Keller merged commit 0ae685e into main Jul 9, 2024
13 checks passed
@Klaus-Keller Klaus-Keller deleted the feat/project-access-spec-cache branch July 9, 2024 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants