Skip to content

Commit

Permalink
feat: multiversion support (#6)
Browse files Browse the repository at this point in the history
* chore: update ui5 cli, add ui5 stringreplacer

* feat: first version string replacer

* feat: replace ui5stringreplacer with custom

* feat: add test sample app

* chore: update workflow

* chore: update workflow run headless

* chore: update lockfiles

* chore: update lockfiles

* chore: update lockfiles

* fix: update consuming and tests

* chore: update package.json script

* chore: update replace string

* chore: update npm versioning

* fix: replace string

* docs: update

* chore: remove license from example
  • Loading branch information
marianfoo authored Dec 23, 2022
1 parent a86f068 commit 68aa9ca
Show file tree
Hide file tree
Showing 95 changed files with 45,816 additions and 265 deletions.
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Exclude folders
node_modules
dist
webapp
examples

# Include all JS files
!*.js
35 changes: 6 additions & 29 deletions .github/workflows/wdi5-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,6 @@ jobs:
- name: checkout excelUpload Repo
uses: actions/checkout@v3
with:
path: control

- name: Checkout excelUpload Sample Repo
uses: actions/checkout@v3
with:
repository: marianfoo/ui5-cc-excelUpload-sampleapp
path: sample

- name: use node 16
uses: actions/setup-node@v2
Expand All @@ -38,56 +30,41 @@ jobs:
cache-dependency-path: "**/package-lock.json"

- name: install pnpm
working-directory: sample
run: |
npm install -g pnpm
# we need this for workspace mgmt
- name: check npm version >= 7
working-directory: sample
run: npm --version

- name: update npm
working-directory: sample
run: |
npm i -g npm@latest
npm --version
- name: setup excelUpload control
working-directory: control
run: |
npm install
npm run setupExamplespnpm
npm run build
npm link
# install both module + sample app(s) deps
- name: install packages
working-directory: sample
run: |
pnpm i
npm run link
# update chromedriver
- name: update chromedriver to latest
working-directory: sample
run: |
pnpm add chromedriver@latest --save-dev -w
npm run updateChromedriver
- name: install @sap/cds-dk
working-directory: sample
run: |
npm i -g @sap/cds-dk
# run app
- name: run app
working-directory: sample
run: npm run start&
run: npm run start:sample&

# run wdi5 tests
- name: test wdi5 v2
working-directory: sample
run: npm run testv2 -- --headless
run: npm run testv2Headless

# run wdi5 tests
- name: test wdi5 v4
working-directory: sample
run: npm run testv4 -- --headless
run: npm run testv4Headless
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
node_modules
dist
/webapp/

.vscode
.DS_Store
71 changes: 71 additions & 0 deletions dev/replace-string.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/* eslint-disable no-undef */
const replace = require("replace-in-file");
const fs = require("fs");

// copy result to webapp folder
if (!fs.existsSync("webapp")) {
fs.mkdirSync("webapp");
}

function copyDirectorySync(src, dest) {
const files = fs.readdirSync(src);

for (const file of files) {
const srcPath = `${src}/${file}`;
const destPath = `${dest}/${file}`;

if (fs.statSync(srcPath).isFile()) {
fs.copyFileSync(srcPath, destPath);
} else if (fs.statSync(srcPath).isDirectory()) {
fs.mkdirSync(destPath, { recursive: true });
copyDirectorySync(srcPath, destPath);
}
}
}

copyDirectorySync("src", "webapp");

// Read the contents of the package.json file
const packageJson = fs.readFileSync("package.json", "utf8");

// Parse the JSON content
const packageData = JSON.parse(packageJson);

// Get the version from the parsed data
const version = `v${packageData.version}`;
const versionSlash = version.replaceAll(".", "/");

// replace strings in publish folder
const options = {
files: ["**/webapp/**"],
from: [/XXXnamespaceXXX/g, /XXXnamespaceSlashXXX/g],
to: [version, versionSlash],
};
replace.sync(options);

fs.copyFileSync("ui5-publish.yaml", "ui5.yaml");

const optionsYaml = {
files: ["**/ui5.yaml"],
from: [/XXXnamespaceSlashXXX/g],
to: [versionSlash],
};
replace.sync(optionsYaml);

// Read the contents of the package.json file
const manifestV4 = fs.readFileSync("examples/packages/orders/webapp/manifest.json", "utf8");
// Parse the JSON content
let manifestV4Data = JSON.parse(manifestV4);
// Read the contents of the package.json file
const manifestV2 = fs.readFileSync("examples/packages/ordersv2/webapp/manifest.json", "utf8");
// Parse the JSON content
let manifestV2Data = JSON.parse(manifestV2);

manifestV4Data["sap.ui5"].resourceRoots["cc.excelUpload"] = `./thirdparty/customControl/excelUpload/${versionSlash}`;
manifestV2Data["sap.ui5"].resourceRoots["cc.excelUpload"] = `./thirdparty/customControl/excelUpload/${versionSlash}`;

manifestV4Data = JSON.stringify(manifestV4Data, null, 2);
manifestV2Data = JSON.stringify(manifestV2Data, null, 2);

fs.writeFileSync("examples/packages/orders/webapp/manifest.json", manifestV4Data, "utf8");
fs.writeFileSync("examples/packages/ordersv2/webapp/manifest.json", manifestV2Data, "utf8");
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ The module focuses on making integration into existing Fiori element apps as eas
- Upload with or without draft
- Check for mandatory fields
- Extension Points for uploading to App or sending to backend
- Multiversion support in Fiori Launchpad (no central deployment necessary anymore)


### Install
Expand Down
12 changes: 6 additions & 6 deletions docs/pages/GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ npm install ui5-cc-excelupload
```

2\. Add to your `package.json`:
> :information_source: This step is not necessary from UI5 Tooling V3
:information_source: This step is not necessary from UI5 Tooling V3

````json
"ui5": {
Expand All @@ -26,11 +26,11 @@ npm install ui5-cc-excelupload

3\. Add `resourceRoots` to you `manifest.json`

⚠️ You must always keep your ui5-cc-excelUpload version up to date here when updating the module.

````json
"resourceRoots": {
"thirdparty.customControl.excelUpload": "./thirdparty/customControl/excelUpload/",
"xlsx": "./thirdparty/customControl/excelUpload/resources/xlsx",
"cc.excelUpload": "./thirdparty/customControl/excelUpload/"
"cc.excelUpload": "./thirdparty/customControl/excelUpload/v0/3/5"
},
````

Expand Down Expand Up @@ -98,7 +98,7 @@ openExcelUploadDialog: async function (oEvent) {
this._view.setBusy(true)
if (!this.excelUpload) {
this.excelUpload = await sap.ui.getCore().createComponent({
name: "thirdparty.customControl.excelUpload",
name: "cc.excelUpload",
async: false,
componentData: {
context: this
Expand Down Expand Up @@ -154,7 +154,7 @@ openExcelUploadDialog: async function (oEvent) {
this.getView().setBusy(true)
if (!this.excelUpload) {
this.excelUpload = await sap.ui.getCore().createComponent({
name: "thirdparty.customControl.excelUpload",
name: "cc.excelUpload",
async: false,
componentData: {
context: this
Expand Down
22 changes: 22 additions & 0 deletions examples/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org

root = true

[*]
# We recommend you to keep these unchanged
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

# Change these settings to your own preference
indent_style = tab

[*.{yaml,yml,md,json,xml,properties}]
indent_size = 2
indent_style = space

[*.md]
trim_trailing_whitespace = false
22 changes: 22 additions & 0 deletions examples/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# node_modules
node_modules

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# build results

dist
src-gen
test-gen

# server db
server/db.json

# Mac files
.DS_Store

2 changes: 2 additions & 0 deletions examples/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Enable Pre/Post Scripts for PNPM
enable-pre-post-scripts=false
1 change: 1 addition & 0 deletions examples/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lts/gallium
14 changes: 14 additions & 0 deletions examples/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Ignore files
pnpm-lock.yaml
package-lock.json
.yo-rc.json

# Ignore build output folders
/packages/*/dist/**
/packages/*/webapp/**
/packages/*/*-gen/**

# Ignore files by extension
/**/*.svg
/**/*.png
/**/*.md
28 changes: 28 additions & 0 deletions examples/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module.exports = {
// Make Prettier work with PNPM using JS config and require plugins
// https://github.com/pnpm/pnpm/issues/3641
plugins: Object.keys(require("./package").devDependencies)
.filter((packageName) => {
return packageName != "prettier" && packageName.includes("prettier");
})
.flatMap((packageName) => {
return [require(packageName)];
}),
singleQuote: false,
printWidth: 200,
endOfLine: "lf",
trailingComma: "none",
tabWidth: 4,
useTabs: true,
overrides: [
{
files: ["*.yaml", "*.yml", "*.md", "*.json", "*.xml", "*.properties"],
options: {
useTabs: false,
tabWidth: 2,
keySeparator: "=",
xmlWhitespaceSensitivity: "ignore"
}
}
]
};
40 changes: 40 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Sample Setup for `ui5-cc-excelupload`

## Description

This setup is a sample the ui5 module `ui5-cc-excelupload`.
Template was is the [ui5-community/hacking-away-sampleapp](https://github.com/ui5-community/hacking-away-sampleapp).

## Project setup

Currently there is one CAP App to serve the ODataV2 and ODataV4 Service at `/packages/server`.
The template for this Service was the sample at the [SAP-samples/cloud-cap-samples](https://github.com/SAP-samples/cloud-cap-samples/tree/main/orders) repo.

Two Fiori Element App consuming the services: `/packages/orders` (OData V4) and `/packages/ordersV2` (OData V2).
These Apps are generated with Fiori Tools.

## Requirements

[pnpm](https://pnpm.io/) for dependency management.

## Preparation

Use `pnpm` to install the dependencies:

```sh
pnpm i
```

## Run the App


Execute the following command to run the app locally for development in watch mode (the browser reloads the app automatically when there are changes in the source code):

```sh
npm start
```


## License

This project is licensed under the Apache Software License, version 2.0 except as noted otherwise in the [LICENSE](LICENSE) file.
Loading

0 comments on commit 68aa9ca

Please sign in to comment.