npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@sap-ux/cap-config-writer

v0.7.60

Published

Add or update configuration for SAP CAP projects

Downloads

2,841

Readme

@sap-ux/cap-config-writer

Adds or removes configuration to a SAP CAP projects.

Installation

Npm npm install --save @sap-ux/cap-config-writer

Yarn yarn add @sap-ux/cap-config-writer

Pnpm pnpm add @sap-ux/cap-config-writer

Usage

import { enableCdsUi5Plugin } from '@sap-ux/cap-config-writer';

const fs = await enableCdsUi5Plugin('path/to/cap-project');

fs.commit();

API

updatePomXml

This utility function updates the pom.xml file for Java-based CAP projects. The function reads the contents of the pom.xml file specified by pomPath, parses it, and searches for the spring-boot-maven-plugin configuration. If found, it adds certain workspace elements to it and writes back the updated pom.xml.

import { updatePomXml } from '@sap-ux/cap-config-writer';

// Usage example
const fsMock: Editor = {}; // mem-fs file editor
const pomPath: string = 'path/to/pom.xml';
const logger: Logger = {}; // logger instance from @sap-ux/logger

updatePomXml(fsMock, pomPath, logger);

updateTsConfig

The function constructs the path to the tsconfig.json file based on the provided appRoot. If the file exists, it reads its contents and checks if the typeRoots property is defined in the compilerOptions. The function extends the tsconfig.json file with the modified compilerOptions.

import { updateTsConfig } from '@sap-ux/cap-config-writer';

// Usage example
const fsMock: Editor = {}; // mem-fs file editor
const appRoot: string = 'path/to/your/app'; // The root directory of the application

updateTsConfig(fsMock, appRoot);

updateStaticLocationsInApplicationYaml

The function reads the contents of the application YAML file specified by applicationYamlPath, parses it, and checks if the static resource locations are already defined. If not, it adds the custom paths specified by capCustomPathsApp to the web.resources.static-locations property.

import { updateStaticLocationsInApplicationYaml } from '@sap-ux/cap-config-writer';

// Usage example
const fsMock: Editor = {}; // mem-fs file editor
const applicationYamlPath: string = 'path/to/application.yaml';
const capCustomPathsApp: string = 'path/to/static/resources'; // Custom paths for CAP application
const logger: Logger = {}; // logger instance from @sap-ux/logger

await updateStaticLocationsInApplicationYaml(fsMock, applicationYamlPath, capCustomPathsApp, logger);

updateRootPackageJson

Updates the package.json file of a CAP project app based on project requirements such as enableNPMWorkspaces

import { updateRootPackageJson } from '@sap-ux/cap-config-writer';

// Usage example
const fsMock: Editor = {}; // mem-fs file editor
const projectName: string = 'your-project-name';
const sapux: boolean = true; // Whether to add the app name to the sapux array
const capService: CapService = {}; // CAP service instance
const appId: string = 'your-app-id';
const log: Logger = {}; //// mem-fs file editor
const enableNPMWorkspaces: boolean = true; // npm workspaces (optional)

await updateRootPackageJson(fsMock, projectName, sapux, capService, appId, log, enableNPMWorkspaces);

updateAppPackageJsonCAP

The function constructs the path to the package.json file based on the provided appRoot. It then reads the contents of the package.json file and removes the sapux property, the int-test script, and any scripts starting with 'start' that are not required for the app.

import { updateAppPackageJson } from '@sap-ux/cap-config-writer';

// Usage example
const fsMock: Editor = {}; // mem-fs file editor
const appRoot: string = 'path/to/your/app'; // The root directory of the application

updateAppPackageJson(fsMock, appRoot);

Keywords

SAP Fiori elements SAP CAP SAP CAP writer SAP UI5