How to migrate your UI Configurations to YAML ?

411 views
Skip to first unread message

Chris Clawson

unread,
Feb 8, 2022, 10:44:46 AM2/8/22
to DSpace Technical Support

Upgrading DSpace 7.x (7.1 to 7.2), upgrading the Front-end, step 'C' says I should use yarn to convert the earlier installation's .ts files to .yml. I am not able to get past this step. Perhaps I only need some assistance in the specific grammar in using the conversion script.

The path to my my old DSpace 7.1 angular 'environments' directory

/opt/dspace-angular-old/src/environments

My unzipped DSpace 7.2 angular is at:

/opt/dspace-angular-dspace

My command prompt is located at /opt/dspace-angular-dspace/config

Given these conditions, would someone please provide me with a specific example of how to produce a working command for the this documentation example to convert environment.prod.ts

yarn env:yaml src/environments/environment.prod.ts config/config.prod.yml

Tim Donohue

unread,
Feb 8, 2022, 12:55:19 PM2/8/22
to DSpace Technical Support
Hi Chris,

That "yarn env:yaml" command only requires one input, whish is your old "environment.*.ts" file.  So, that second input is *optional*.  If you only give it one input, it'll write the output YAML file into that same directory.  That's perfectly ok...you'd just want to eventually ensure that YAML file gets moved over into /opt/dspace-angular-dspace/config/config.prod.yml , which is where the UI will look for your configs in 7.2 (and above).

So, I would recommend trying the script with a single input, if the multiple inputs is getting confusing.

If somehow the script is erroring out or not working at all, send the error message to this list and we'll take a closer look at it.   

If worst came to worst, you also can just recreate your configs in YAML (based on the examples in config.example.yml) ... but, I completely understand that it's a ton easier to just migrate the settings over.

Tim

Chris Clawson

unread,
Feb 8, 2022, 1:26:12 PM2/8/22
to DSpace Technical Support
Thanks, Tim, but still frustrated!
I understand you are saying to go to my old /src/environments directory, and run this command:
yarn env:yaml environment.prod.ts
Here is the response I get:
root@melo4:/opt/dspace-angular-old/src/environments# yarn env:yaml environment.prod.ts
yarn run v1.22.17
error Command "env:yaml" not found.

-- embarrassing, did I break something?

Tim Donohue

unread,
Feb 8, 2022, 3:54:58 PM2/8/22
to DSpace Technical Support
Hi Chris,

It sounds like our the docs need clarifying here.  You need to run `yarn env:yaml` from the *NEW 7.2 codebase directory*.  Since you are trying to run it from your old 7.1 code, it is throwing an error as that command didn't exist in the 7.1 codebase.

So, the docs were written assuming you were going to essentially install 7.2 "on top of" 7.1.  In that situation, you'd have the 7.2 code...but your old 7.1 "environment.prod.ts" would still be around (as the update to 7.2 doesn't delete that file).

For your purposes, it sounds like your 7.2 code is in a separate directory from 7.1 code.  So, for your purposes, do this:
1. Copy the "src/environment/environment.prod.ts" from your 7.1 (old) directory, over into the 7.2 (new) directory.  Where you choose to copy it into doesn't really matter, but you could put it under "[src-7.2]/config", where the configs eventually need to be.
2. Now, go to [src-7.2] (root 7.2 directory) and run:  "yarn env:yaml config/environment.prod.ts config/config.prod.yml".   

That should be it.  You can then look at that config/config.prod.yml to double check it looks correct (the same settings exist in both the YAML and TS config files, they just have a different syntax).  Once you are satisfied, you can delete the "environment.prod.ts" from your [src-7.2]/config/ folder.  It's not used in 7.2 at all.

Tim

Chris Clawson

unread,
Feb 8, 2022, 5:18:19 PM2/8/22
to DSpace Technical Support
Still doesn't work and I think I know why. The environment.prod.ts file declares 4 files to import, so the script is unable to find them if  environment.prod.ts is placed in some arbitrary location under the DSpace 7.2 angular root directory. Shall I presume that these import paths  need to point to the earlier, DSpace 7.1 files? I guess I may eventually figure it out. Unless I hear different, I suppose I need to modify environment.prod.ts to correctly point to these other 4 files:
../config/global-config.interface
../app/shared/notifications/models/notification-animations-type
../app/browse-by/browse-by-switcher/browse-by-decorator
../app/core/data/rest-request-method
Message has been deleted

Chris Clawson

unread,
Feb 8, 2022, 5:50:57 PM2/8/22
to DSpace Technical Support

Ouch!
These 4 imports in environment.prod.ts, in turn refer to all sorts of other .ts files from the old installation. It is not as simple as copying four files over, in addition to environment.prod.ts and place under the DSpace 7.2 angular code root.

Okay - From the DSpace 7.2 angular root directory this following command produced a config.prod.ts file in the same root directory:
yarn env:yaml ..//dspace-angular-old/src/environments/environment.prod.ts config.prod.yml

So, all I need is to move this to the [angular-root]/config directory and then :
yarn run build:prod
?

Tim Donohue

unread,
Feb 8, 2022, 5:58:07 PM2/8/22
to DSpace Technical Support
Hi Chris,

You are 100% correct.  It looks like during 7.2 development, after we created the "yarn env:yaml" script, we then moved some code around, and broke those imports at the top of the old "environment.prod.ts".   So, if you copy it over into the 7.2 directory structure, it won't work because those imports are broken.

Currently, it appears there are two options:
1) If your 7.1 folder is separate for the 7.2 folder, you could keep "environment.prod.ts" in the 7.1 directories, and *reference it* from the 7.2 folder.  It'd be a little odd, but look kinda like this. You'd run this from 7.2 root folder.

yarn env:yaml ../../dspace-7.1-old/src/environments/environment.prod.ts config/config.prod.yml

2) Or, if you want to copy your environment.prod.ts into the 7.2 directories first (or don't have the old 7.1 code handy), then do this:

Remove/comment out all 4 existing imports in `environment.prod.ts`.  Replace them with these lines at the top of that file. (With those 4 imports removed, You need 4 objects, all of which are fully defined below)

interface GlobalConfig { }

enum NotificationAnimationsType {
    Fade = 'fade',
    FromTop = 'fromTop',
    FromRight = 'fromRight',
    FromBottom = 'fromBottom',
    FromLeft = 'fromLeft',
    Rotate = 'rotate',
    Scale = 'scale'
  }

enum BrowseByType {
    Title = 'title',
    Metadata = 'metadata',
    Date = 'date'
}

enum RestRequestMethod {
    GET = 'GET',
    POST = 'POST',
    PUT = 'PUT',
    DELETE = 'DELETE',
    OPTIONS = 'OPTIONS',
    HEAD = 'HEAD',
    PATCH = 'PATCH'
}

If you have those imports commented out, and replaced with those lines, then the "environment.prod.ts" can be placed *anywhere* (as it no longer has imports) and the "yarn env:yaml" command can be pointed at it wherever it sits.

I'll get this all moved over into our official docs, as this is obviously more complex then I initially thought...but I'm glad you've helped us discover the issue.

Tim

Chris Clawson

unread,
Feb 8, 2022, 6:47:08 PM2/8/22
to DSpace Technical Support
Thank you. Yes, it is a bit awkward.
I kept and renamed my 7.1 angular directory and properly referenced  "environment.prod.ts" in the yarn command. I moved the new config.prod.yml to it's proper place and ran the " yarn run build:prod" command to build the final production version.
I will later delete my old version directories.

Everything seemed to finish well, although a full system reboot failed to start angular as a service. I guess this is my last barrier to a functional upgrade, but it is the stuff of a new thread if I need help.
Again - I appreciate the support and am happy to help ring out the new version.

Mohammad S. AlMutairi

unread,
Feb 9, 2022, 2:15:00 AM2/9/22
to DSpace Technical Support
On Wednesday, February 9, 2022 at 2:47:08 AM UTC+3 Chris Clawson wrote:
Everything seemed to finish well, although a full system reboot failed to start angular as a service. I guess this is my last barrier to a functional upgrade, but it is the stuff of a new thread if I need help.
 
You need to replace the ExecStart line in the service startup script as you see below and you also need to change the WorkingDirectory path to reflect the new path if it's changed.
vi /lib/systemd/system/dspace-angular.service
ExecStart=/usr/bin/node dist/server/main
WorkingDirectory=/opt/dspace-angular

Chris Clawson

unread,
Feb 9, 2022, 12:21:18 PM2/9/22
to DSpace Technical Support
WARNING - My method of using the relative paths to the earlier DS 7.1 directory did run under the yarn env:yaml  script, but it did not produce a useful config.prod.yml file. Angular insisted on listening at localhost:8080, rather than localhost:4000. I don't know why this didn't work, but Mohammad's suggestion of editing the config.example.yml to define my URLs and ports worked much better and easier.
Reply all
Reply to author
Forward
0 new messages