Skip to content

Commit

Permalink
Refactor shared logic for generating package.json scripts for FF and …
Browse files Browse the repository at this point in the history
…FE (#2386)

* refactoring shared logic for adding package json scriots for FF and FE

* add changeset

* add docs

* pnpm recursive install

* revert translations mockOnlyWarning

* fix sonar issues

* resolving conflictas after merge

* revise export of function

* change name to getPackageScripts

* fix test name

* test fix

* add lint ignore escape chars

* add lint ignore escape chars

* es lint

* add a comment explaining not to remove escape chars from command

---------

Co-authored-by: Austin Devine <[email protected]>
  • Loading branch information
2 people authored and emrecevik06 committed Oct 11, 2024
1 parent 7ef7727 commit 26d9fb8
Show file tree
Hide file tree
Showing 18 changed files with 325 additions and 296 deletions.
7 changes: 7 additions & 0 deletions .changeset/eighty-ways-approve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@sap-ux/fiori-freestyle-writer': minor
'@sap-ux/fiori-generator-shared': minor
'@sap-ux/fiori-elements-writer': minor
---

Refactor shared logic for generating package.json scripts for FF and FE
5 changes: 2 additions & 3 deletions packages/fiori-elements-writer/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import type { App, Package } from '@sap-ux/ui5-application-writer';
import { generate as generateUi5Project } from '@sap-ux/ui5-application-writer';
import { generate as addOdataService, OdataVersion, ServiceType } from '@sap-ux/odata-service-writer';
import { generateOPAFiles } from '@sap-ux/ui5-test-writer';
import { getPackageJsonTasks } from './packageConfig';
import cloneDeep from 'lodash/cloneDeep';
import type { FioriElementsApp } from './types';
import { TemplateType } from './types';
Expand All @@ -20,7 +19,7 @@ import {
import { extendManifestJson } from './data/manifestSettings';
import semVer from 'semver';
import { initI18n } from './i18n';
import { getBootstrapResourceUrls } from '@sap-ux/fiori-generator-shared';
import { getBootstrapResourceUrls, getPackageScripts } from '@sap-ux/fiori-generator-shared';
import { generateFpmConfig } from './fpmConfig';

export const V2_FE_TYPES_AVAILABLE = '1.108.0';
Expand Down Expand Up @@ -177,7 +176,7 @@ async function generate<T extends {}>(basePath: string, data: FioriElementsApp<T
if (isEdmxProjectType) {
// Add scripts to package.json only for non-CAP projects
packageJson.scripts = Object.assign(packageJson.scripts ?? {}, {
...getPackageJsonTasks({
...getPackageScripts({
localOnly: !feApp.service?.url,
addMock: !!feApp.service?.metadata,
addTest,
Expand Down
84 changes: 0 additions & 84 deletions packages/fiori-elements-writer/src/packageConfig.ts

This file was deleted.

12 changes: 0 additions & 12 deletions packages/fiori-elements-writer/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,3 @@ export interface FioriElementsApp<T> extends Ui5App {

// We need this for the service version
export { OdataVersion } from '@sap-ux/odata-service-writer';

/**
Represents a set of scripts defined in a package.json file.
*/
export interface PackageJsonScripts {
start: string;
'start-local': string;
'start-noflp'?: string;
'start-mock'?: string;
'int-test'?: string;
'start-variants-management'?: string;
}
5 changes: 2 additions & 3 deletions packages/fiori-freestyle-writer/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ import { render } from 'ejs';
import type { Package } from '@sap-ux/ui5-application-writer';
import { generate as generateUi5Project } from '@sap-ux/ui5-application-writer';
import { generate as addOdataService } from '@sap-ux/odata-service-writer';
import { getPackageJsonTasks } from './packageConfig';
import cloneDeep from 'lodash/cloneDeep';
import type { BasicAppSettings } from './types';
import { FreestyleApp, TemplateType } from './types';
import { setDefaults, escapeFLPText } from './defaults';
import { UI5Config } from '@sap-ux/ui5-config';
import { initI18n } from './i18n';
import { getBootstrapResourceUrls } from '@sap-ux/fiori-generator-shared';
import { getBootstrapResourceUrls, getPackageScripts } from '@sap-ux/fiori-generator-shared';

/**
* Generate a UI5 application based on the specified Fiori Freestyle floorplan template.
Expand Down Expand Up @@ -98,7 +97,7 @@ async function generate<T>(basePath: string, data: FreestyleApp<T>, fs?: Editor)
// Add scripts for non-CAP applications
packageJson.scripts = {
...packageJson.scripts,
...getPackageJsonTasks({
...getPackageScripts({
localOnly: !!ffApp.service && !ffApp.service?.url,
addMock: !!ffApp.service?.metadata,
sapClient: ffApp.service?.client,
Expand Down
77 changes: 0 additions & 77 deletions packages/fiori-freestyle-writer/src/packageConfig.ts

This file was deleted.

11 changes: 0 additions & 11 deletions packages/fiori-freestyle-writer/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,3 @@ export interface FreestyleApp<T> extends Ui5App {

// We need this for the service version
export { OdataVersion } from '@sap-ux/odata-service-writer';

/**
Represents a set of scripts defined in a package.json file.
*/
export interface PackageJsonScripts {
start: string;
'start-local': string;
'start-noflp'?: string;
'start-mock'?: string;
'start-variants-management'?: string;
}
54 changes: 0 additions & 54 deletions packages/fiori-freestyle-writer/test/packageConfig.test.ts

This file was deleted.

1 change: 1 addition & 0 deletions packages/fiori-generator-shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"dependencies": {
"@sap-ux/btp-utils": "workspace:*",
"@sap-ux/project-access": "workspace:*",
"i18next": "20.6.1",
"mem-fs": "2.1.0",
"mem-fs-editor": "9.4.0"
},
Expand Down
Loading

0 comments on commit 26d9fb8

Please sign in to comment.