Skip to content

Commit 7f835a2

Browse files
committed
Merge branch 'dev' of github.com:contentstack/migration-v2-node-server into feature/dropdown-field-choices
2 parents f462868 + 99aae28 commit 7f835a2

File tree

102 files changed

+3034
-2871
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+3034
-2871
lines changed

.github/workflows/repo-sync.yml

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -101,28 +101,29 @@ jobs:
101101
npm install --save-dev eslint @eslint/js globals
102102
103103
104-
# if [ ! -f "eslint.config.cjs" ]; then
105-
# echo "Creating default ESLint config..."
106-
# cat <<EOL > eslint.config.cjs
107-
# const js = require("@eslint/js");
108-
# const globals = require("globals");
109-
110-
# module.exports = [
111-
# js.configs.recommended,
112-
# {
113-
# languageOptions: {
114-
# ecmaVersion: "latest",
115-
# sourceType: "module",
116-
# globals: globals.node,
117-
# },
118-
# rules: {
119-
# "no-unused-vars": "warn",
120-
# "no-console": "off"
121-
# }
122-
# }
123-
# ];
124-
# EOL
125-
# fi
104+
if [ ! -f "eslint.config.cjs" ]; then
105+
echo "Creating default ESLint config..."
106+
cat <<EOL > eslint.config.cjs
107+
const js = require("@eslint/js");
108+
const globals = require("globals");
109+
110+
module.exports = [
111+
js.configs.recommended,
112+
{
113+
languageOptions: {
114+
ecmaVersion: "latest",
115+
sourceType: "module",
116+
globals: globals.node,
117+
},
118+
rules: {
119+
"no-unused-vars": "warn",
120+
"no-console": "off",
121+
"@typescript-eslint/no-var-requires": 'off'
122+
}
123+
}
124+
];
125+
EOL
126+
fi
126127
127128
# # Remove unused imports and missing file references
128129
echo "Running ESLint to remove unused imports..."

.github/workflows/sast-scan.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ jobs:
88
steps:
99
- uses: actions/checkout@v2
1010
- name: Semgrep Scan
11-
run: docker run -v /var/run/docker.sock:/var/run/docker.sock -v "${PWD}:/src" returntocorp/semgrep semgrep scan --config auto
11+
run: docker run -v /var/run/docker.sock:/var/run/docker.sock -v "${PWD}:/src" returntocorp/semgrep semgrep scan --config auto

README.md

Lines changed: 51 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
# Migration v2
2+
23
## Overview
4+
35
The migration-v2 project is designed to facilitate the migration of assets and related functionalities. This project includes multiple components such as API, UI, and upload API.
46

57
## Installation
8+
69
Clone the repository:
10+
711
```
812
git clone https://github.com/contentstack/migration-v2.git
913
cd migration-v2
@@ -16,6 +20,7 @@ Check for readme.md files and install dependencies for folders
1620
This is the migration V2's node server.
1721

1822
### Environment Variables
23+
1924
The following environment variables are used in this project:
2025

2126
- `APP_TOKEN_KEY`: The token key for the application. Default is `MIGRATION_V2`.
@@ -27,14 +32,15 @@ Make sure to set these variables in a `.env` file at the root of your project.
2732
2. To run the production server, create a `./production.env` file and add environment variables as per `./example.env`
2833

2934
### To start the server
30-
Run `npm run dev`
3135

36+
Run `npm run dev`
3237

3338
## Migration UI
3439

3540
Migration UI is a web application designed to facilitate the migration of content. It provides a user-friendly interface for managing and migrating content efficiently.
3641

3742
### Features
43+
3844
- User-friendly interface for content migration
3945
- Integration with Contentstack
4046
- State management with Redux Toolkit
@@ -43,14 +49,15 @@ Migration UI is a web application designed to facilitate the migration of conten
4349
### Installation
4450

4551
1. Navigate to the project directory:
46-
```sh
47-
cd ui
48-
```
52+
53+
```sh
54+
cd ui
55+
```
4956

5057
2. Install the dependencies:
51-
```sh
52-
npm install
53-
```
58+
```sh
59+
npm install
60+
```
5461

5562
### Environment Variables
5663

@@ -66,14 +73,17 @@ The following environment variables are used in this project:
6673
Make sure to set these variables in a `.env` file at the root of your ui project.
6774

6875
### Usage
76+
6977
Start the development server:
78+
7079
```sh
7180
npm start
7281
```
7382

7483
Open your browser and navigate to http://localhost:3000.
7584

7685
### Dependencies
86+
7787
- @contentstack/json-rte-serializer: ^2.0.5
7888
- @contentstack/venus-components: ^2.2.4
7989
- @reduxjs/toolkit: ^2.2.5
@@ -85,15 +95,21 @@ Open your browser and navigate to http://localhost:3000.
8595
- @types/react-redux: ^7.1.33
8696

8797
## Migration v2 upload-api
98+
8899
### Overview
100+
89101
The migration-v2 upload-api project is designed to facilitate the migration of different CMS to Contentstack functionalities.
90102

91103
### Installation
104+
92105
Navigate to the project directory:
106+
93107
```
94108
cd migration-v2/upload-api
95109
```
110+
96111
Install dependencies:
112+
97113
```
98114
npm install
99115
```
@@ -108,6 +124,7 @@ The following environment variables are used in this project:
108124
Make sure to set these variables in a `.env` file at the root of your project.
109125

110126
### Configuration
127+
111128
Please refer sample.config.json and provide this config in index.ts of config folder of upload-api/src
112129
The following configuration is used in this project:
113130

@@ -116,6 +133,7 @@ The following configuration is used in this project:
116133
- `isLocalPath`: A flag to indicate if the path is local. Default is `true`.
117134

118135
#### AWS Data
136+
119137
- `awsRegion`: The AWS region. Default is `us-east-2`.
120138
- `awsAccessKeyId`: The AWS access key ID.
121139
- `awsSecretAccessKey`: The AWS secret access key.
@@ -124,22 +142,29 @@ The following configuration is used in this project:
124142
- `buketKey`: The key for the AWS S3 bucket. Default is `project/package 45.zip`.
125143

126144
#### Local Path
145+
127146
- `localPath`: The local path to the extracted files. for example `/upload-api/extracted_files/package 45.zip`.
128147

129148
## Cli
149+
130150
Navigate to the project directory
131-
1. Install pnpm
132-
Since pnpm is required, you need to install it globally if it's not already installed:
133-
```
134-
npm install -g pnpm
135-
```
136-
2. Run the Setup Script
137-
Now, run the main setup script specified in the package.json:
138-
```
139-
npm run setup-repo
140-
```
151+
152+
1. Install pnpm
153+
Since pnpm is required, you need to install it globally if it's not already installed:
154+
155+
```
156+
npm install -g pnpm
157+
```
158+
159+
2. Run the Setup Script
160+
Now, run the main setup script specified in the package.json:
161+
162+
```
163+
npm run setup-repo
164+
```
141165

142166
## Scripts
167+
143168
- `npm start`: Starts the main server by running index.js.
144169
- `npm run api`: Navigates to the api directory and runs the development server.
145170
- `npm run upload`: Navigates to the upload-api directory and starts the upload API server.
@@ -149,29 +174,35 @@ Navigate to the project directory
149174
- `npm test`: Displays an error message indicating that no tests are specified.
150175

151176
## Repository
177+
152178
- Type: git
153179
- URL: https://github.com/contentstack/migration-v2.git
154180

155181
## Bugs and Issues
182+
156183
- URL: https://github.com/contentstack/migration-v2/issues
157184

158185
## Homepage
186+
159187
- URL: https://github.com/contentstack/migration-v2#readme
160188

161189
## DevDependencies
190+
162191
- husky: ^4.3.8
163192
- prettier: ^2.4.1
164193
- rimraf: ^3.0.2
165194
- validate-branch-name: ^1.3.0
166195

167196
## Husky Configuration
197+
168198
```
169199
"husky": {
170200
"hooks": {}
171201
}
172202
```
173203

174204
- Branch Name Validation
205+
175206
```
176207
"validate-branch-name": {
177208
"pattern": "^(feature|bugfix|hotfix)/[a-z0-9-]{5,30}$",
@@ -180,10 +211,13 @@ Navigate to the project directory
180211
```
181212

182213
## License
214+
183215
This project is licensed under the ISC License.
184216

185217
## Author
218+
186219
The author information is not specified.
187220

188221
## Contact
222+
189223
For further assistance, please contact the project maintainer through the issues page on GitHub.

api/src/constants/app/index.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3665,4 +3665,4 @@
36653665
}
36663666
],
36673667
"count": 11
3668-
}
3668+
}

api/src/constants/index.ts

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
export const CS_REGIONS = ["NA", "EU", "AZURE_NA", "AZURE_EU", "GCP_NA"];
22
export const DEVURLS: any = {
3-
'NA': 'developerhub-api.contentstack.com',
4-
'EU': 'eu-developerhub-api.contentstack.com',
5-
'AZURE_NA': 'azure-na-developerhub-api.contentstack.com',
6-
'AZURE_EU': 'azure-eu-developerhub-api.contentstack.com',
7-
'GCP_NA': 'gcp-na-developerhub-api.contentstack.com',
8-
}
3+
NA: "developerhub-api.contentstack.com",
4+
EU: "eu-developerhub-api.contentstack.com",
5+
AZURE_NA: "azure-na-developerhub-api.contentstack.com",
6+
AZURE_EU: "azure-eu-developerhub-api.contentstack.com",
7+
GCP_NA: "gcp-na-developerhub-api.contentstack.com",
8+
};
99
export const CMS = {
1010
CONTENTFUL: "contentful",
1111
SITECORE_V8: "sitecore v8",
1212
SITECORE_V9: "sitecore v9",
1313
SITECORE_V10: "sitecore v10",
1414
WORDPRESS: "wordpress",
1515
AEM: "aem",
16-
}
16+
};
1717
export const MODULES = [
1818
"Project",
1919
"Migration",
@@ -58,7 +58,8 @@ export const HTTP_TEXTS = {
5858
"Project's Fileformat confirmation updated successfully",
5959
CMS_UPDATED: "Project's migration cms updated successfully",
6060
STACK_UPDATED: "Project's migration stack details updated successfully",
61-
CONTENT_MAPPER_UPDATED: "Project's migration content mapping updated successfully",
61+
CONTENT_MAPPER_UPDATED:
62+
"Project's migration content mapping updated successfully",
6263
FILE_FORMAT_UPDATED: "Project's migration file format updated successfully",
6364
DESTINATION_STACK_UPDATED:
6465
"Project's migration destination stack updated successfully",
@@ -95,14 +96,11 @@ export const HTTP_TEXTS = {
9596
"Sorry, the requested content mapper id does not exists.",
9697
ADMIN_LOGIN_ERROR:
9798
"Sorry, You Don't have admin access in any of the Organisation",
98-
PROJECT_DELETE:
99-
"Project Deleted Successfully",
100-
PROJECT_REVERT:
101-
"Project Reverted Successfully",
102-
LOGS_NOT_FOUND:
103-
"Sorry, no logs found for requested stack migration.",
99+
PROJECT_DELETE: "Project Deleted Successfully",
100+
PROJECT_REVERT: "Project Reverted Successfully",
101+
LOGS_NOT_FOUND: "Sorry, no logs found for requested stack migration.",
104102
MIGRATION_EXECUTION_KEY_UPDATED:
105-
"Project's migration execution key updated successfully"
103+
"Project's migration execution key updated successfully",
106104
};
107105

108106
export const HTTP_RESPONSE_HEADERS = {
@@ -177,18 +175,28 @@ export const CONTENT_TYPE_STATUS = {
177175
export const LOCALE_MAPPER: any = {
178176
//not more than one locale mapping in master locale
179177
masterLocale: {
180-
'en-us': 'en'
178+
"en-us": "en",
181179
},
182-
'fr': 'fr-fr'
183-
}
180+
fr: "fr-fr",
181+
};
184182
export const CHUNK_SIZE = 1048576;
185183

186-
export const LIST_EXTENSION_UID = 'bltc44e51cc9f4b0d80';
184+
export const LIST_EXTENSION_UID = "bltc44e51cc9f4b0d80";
187185

188186
export const KEYTOREMOVE = [
189-
"update", "fetch", "delete", "oauth", "hosting", "install", "reinstall",
190-
"upgrade", "getRequests", "authorize", "authorization", "listInstallations"
191-
]
187+
"update",
188+
"fetch",
189+
"delete",
190+
"oauth",
191+
"hosting",
192+
"install",
193+
"reinstall",
194+
"upgrade",
195+
"getRequests",
196+
"authorize",
197+
"authorization",
198+
"listInstallations",
199+
];
192200

193201
export const MIGRATION_DATA_CONFIG = {
194202
DATA: "./cmsMigrationData",
@@ -262,5 +270,5 @@ export const MIGRATION_DATA_CONFIG = {
262270
GLOBAL_FIELDS_DIR_NAME: "global_fields",
263271
GLOBAL_FIELDS_FILE_NAME: "globalfields.json",
264272

265-
EXPORT_INFO_FILE: "export-info.json"
266-
}
273+
EXPORT_INFO_FILE: "export-info.json",
274+
};

api/src/services/contentful.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ const createEntry = async (packagePath: any, destination_stack_id: string, proje
757757
content.map((item: any) => {
758758
displayField[item?.sys?.id] =
759759
{
760-
displayField: item.displayField || "untitled",
760+
displayField: item?.displayField || "untitled",
761761
};
762762
}
763763
);
@@ -785,7 +785,7 @@ const createEntry = async (packagePath: any, destination_stack_id: string, proje
785785
entryData[name][lang] ??= {};
786786
entryData[name][lang][id] ??= {};
787787
locales.push(lang);
788-
const fieldData = currentCT?.fieldMapping?.find((item: any) => key === item?.uid);
788+
const fieldData = currentCT?.fieldMapping?.find?.((item: any) => (key === item?.uid) && (!["text", "url"]?.includes?.(item?.backupFieldType)));
789789
const newId = fieldData?.contentstackFieldUid ?? `${key}`?.replace?.(/[^a-zA-Z0-9]+/g, "_");
790790
entryData[name][lang][id][newId] = processField(
791791
langValue,

0 commit comments

Comments
 (0)