Skip to content

Commit bcdef16

Browse files
committed
Dev changes merged
2 parents 3f6c02a + 9ce116f commit bcdef16

File tree

8 files changed

+143
-38
lines changed

8 files changed

+143
-38
lines changed

.github/workflows/repo-sync.yml

Lines changed: 114 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -97,30 +97,81 @@ jobs:
9797
git clean -fdX # Remove untracked files and directories
9898
git gc --prune=now # Garbage collect and prune unreachable objects
9999
100-
if [ ! -f "eslint.config.js" ]; then
101-
echo "Creating default ESLint config..."
102-
echo "import js from '@eslint/js';" > eslint.config.js
103-
echo "export default [js.configs.recommended];" >> eslint.config.js
104-
fi
100+
# echo "Installing ESLint dependencies..."
101+
# npm install --save-dev eslint @eslint/js globals
105102
106-
# Remove unused imports and missing file references
107-
echo "Running ESLint to remove unused imports..."
108-
npm install eslint -g
109-
eslint . --fix
103+
# if [ ! -f "eslint.config.cjs" ]; then
104+
# echo "Creating default ESLint config..."
105+
# cat <<EOL > eslint.config.cjs
106+
# const js = require("@eslint/js");
107+
# const globals = require("globals");
110108
111-
echo "Running autoflake to remove unused imports..."
112-
pip install autoflake
113-
autoflake --remove-all-unused-imports --recursive --in-place .
109+
# module.exports = [
110+
# js.configs.recommended,
111+
# {
112+
# languageOptions: {
113+
# ecmaVersion: "latest",
114+
# sourceType: "module",
115+
# globals: globals.node,
116+
# },
117+
# rules: {
118+
# "no-unused-vars": "warn",
119+
# "no-console": "off"
120+
# }
121+
# }
122+
# ];
123+
# EOL
124+
# fi
114125
115-
echo "Running ts-prune to remove unused file references..."
116-
npm install -g ts-prune
117-
ts-prune | awk '{print $1}' | xargs rm -f
126+
# # Remove unused imports and missing file references
127+
# echo "Running ESLint to remove unused imports..."
128+
# npm install eslint -g
129+
# eslint . --fix
130+
131+
# echo "Running autoflake to remove unused imports..."
132+
# pip install autoflake
133+
# autoflake --remove-all-unused-imports --recursive --in-place .
134+
135+
# echo "Running ts-prune to remove unused file references..."
136+
# npm install -g ts-prune
137+
# ts-prune | awk '{print $1}' | xargs rm -f
118138
119139
rsync -av --delete ${{ env.RSYNC_SITECORE_API_SRC_SERVICES_EXCLUDES }} ../api/ ./api/
120140
rsync -av --delete ../cli/ ./cli/
121141
rsync -av --delete ../ui/ ./ui/
122142
rsync -av --delete ${{ env.RSYNC_SITECORE_UPLOAD_API_SRC_EXCLUDES }} ../upload-api/src/ ./upload-api/src/
123143
rsync -av --delete ../upload-api/migration-sitecore/ ./upload-api/migration-sitecore/
144+
145+
# Ensure tsconfig.json exists, create a default one if missing
146+
if [ ! -f "tsconfig.json" ]; then
147+
echo "Creating default tsconfig.json..."
148+
cat <<EOL > tsconfig.json
149+
{
150+
"compilerOptions": {
151+
"target": "ES6",
152+
"module": "CommonJS",
153+
"strict": true,
154+
"esModuleInterop": true,
155+
"skipLibCheck": true,
156+
"forceConsistentCasingInFileNames": true
157+
},
158+
"include": ["src/**/*"],
159+
"exclude": ["node_modules", "dist"]
160+
}
161+
EOL
162+
fi
163+
164+
# Remove unused imports
165+
npx ts-remove-unused-imports api/
166+
npx ts-remove-unused-imports ui/
167+
npx ts-remove-unused-imports upload-api/
168+
169+
# Remove missing imports
170+
npx ts-prune | grep -E '^(api/|ui/|upload-api/)/' | awk '{print $1}' | xargs -I {} sed -i '/import/d' {}
171+
172+
# Format code
173+
npx prettier --write .
174+
124175
git add .
125176
git commit -m "Sync changes from migration-v2 PR #${{ github.event.pull_request.number }}"
126177
git push origin sync-from-migration-v2-${{ github.event.pull_request.number }}
@@ -169,12 +220,33 @@ jobs:
169220
git clean -fdX # Remove untracked files and directories
170221
git gc --prune=now # Garbage collect and prune unreachable objects
171222
172-
if [ ! -f "eslint.config.js" ]; then
223+
echo "Installing ESLint dependencies..."
224+
npm install --save-dev eslint @eslint/js globals
225+
226+
if [ ! -f "eslint.config.cjs" ]; then
173227
echo "Creating default ESLint config..."
174-
echo "import js from '@eslint/js';" > eslint.config.js
175-
echo "export default [js.configs.recommended];" >> eslint.config.js
228+
cat <<EOL > eslint.config.cjs
229+
const js = require("@eslint/js");
230+
const globals = require("globals");
231+
232+
module.exports = [
233+
js.configs.recommended,
234+
{
235+
languageOptions: {
236+
ecmaVersion: "latest",
237+
sourceType: "module",
238+
globals: globals.node,
239+
},
240+
rules: {
241+
"no-unused-vars": "warn",
242+
"no-console": "off"
243+
}
244+
}
245+
];
246+
EOL
176247
fi
177248
249+
178250
# Remove unused imports and missing file references
179251
echo "Running ESLint to remove unused imports..."
180252
npm install eslint -g
@@ -241,12 +313,33 @@ jobs:
241313
git clean -fdX # Remove untracked files and directories
242314
git gc --prune=now # Garbage collect and prune unreachable objects
243315
244-
if [ ! -f "eslint.config.js" ]; then
316+
echo "Installing ESLint dependencies..."
317+
npm install --save-dev eslint @eslint/js globals
318+
319+
if [ ! -f "eslint.config.cjs" ]; then
245320
echo "Creating default ESLint config..."
246-
echo "import js from '@eslint/js';" > eslint.config.js
247-
echo "export default [js.configs.recommended];" >> eslint.config.js
321+
cat <<EOL > eslint.config.cjs
322+
const js = require("@eslint/js");
323+
const globals = require("globals");
324+
325+
module.exports = [
326+
js.configs.recommended,
327+
{
328+
languageOptions: {
329+
ecmaVersion: "latest",
330+
sourceType: "module",
331+
globals: globals.node,
332+
},
333+
rules: {
334+
"no-unused-vars": "warn",
335+
"no-console": "off"
336+
}
337+
}
338+
];
339+
EOL
248340
fi
249341
342+
250343
# Remove unused imports and missing file references
251344
echo "Running ESLint to remove unused imports..."
252345
npm install eslint -g

api/src/services/contentful.service.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import jsonRTE from "./contentful/jsonRTE.js";
1414
import { getAllLocales, getLogMessage } from "../utils/index.js";
1515
import customLogger from "../utils/custom-logger.utils.js";
1616

17-
1817
const {
1918
DATA,
2019
// DIR

api/src/services/sitecore.service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { orgService } from './org.service.js';
99
import { getLogMessage } from '../utils/index.js';
1010
import customLogger from '../utils/custom-logger.utils.js';
1111

12+
1213
const append = "a";
1314
const baseDirName = MIGRATION_DATA_CONFIG.DATA
1415
const {

api/src/services/wordpress.service.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import customLogger from "../utils/custom-logger.utils.js";
1010
import { getLogMessage } from "../utils/index.js";
1111
import { Advanced } from "../models/FieldMapper.js";
1212

13-
1413
const { JSDOM } = jsdom;
1514
const virtualConsole = new jsdom.VirtualConsole();
1615
// Get the current file's path

ui/src/components/ContentMapper/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ const Fields: MappingFields = {
191191
options: {
192192
Select: 'checkbox'
193193
},
194-
type: 'display_type'
194+
type:'checkbox'
195195
},
196196
global_field: {
197197
label: 'Global',

ui/src/components/DestinationStack/Actions/LoadLanguageMapper.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ const Mapper = ({
117117
type: 'csLocale' | 'sourceLocale'
118118
) => {
119119
const selectedLocaleKey = selectedValue?.value;
120-
if (!selectedLocaleKey) return;
120+
121121

122122
setExistingField((prevOptions: ExistingFieldType) => {
123123
const updatedOptions = {
@@ -146,7 +146,11 @@ const Mapper = ({
146146
setSelectedMappings((prev) => {
147147
const updatedMappings = { ...prev };
148148

149-
if (type === 'csLocale') {
149+
150+
if (!selectedValue) {
151+
delete updatedMappings[existingField[index]?.value];
152+
}
153+
else if (type === 'csLocale' && selectedLocaleKey) {
150154
updatedMappings[selectedLocaleKey] = existingLocale[index]?.label
151155
? existingLocale[index]?.label
152156
: '';

ui/src/components/DestinationStack/Actions/LoadStacks.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { Stack } from '../../../components/Common/AddStack/addStack.interface';
2323
import { isEmptyString, validateArray } from '../../../utilities/functions';
2424

2525
// Services
26-
import { createStacksInOrg, getAllStacksInOrg } from '../../../services/api/stacks.service';
26+
import { createStacksInOrg, getAllStacksInOrg, getStackLocales } from '../../../services/api/stacks.service';
2727

2828
// Components
2929
import AddStack from '../../../components/Common/AddStack/addStack';
@@ -191,7 +191,7 @@ const LoadStacks = (props: LoadFileFormatProps) => {
191191
if (allStack?.length <= 0) {
192192
setAllStack(loadingOption);
193193
const stackData = await getAllStacksInOrg(selectedOrganisation?.value, ''); // org id will always be there
194-
194+
const csLocales = await getStackLocales(selectedOrganisation?.value);
195195
const stackArray = validateArray(stackData?.data?.stacks)
196196
? stackData?.data?.stacks?.map((stack: StackResponse) => ({
197197
label: stack?.name,
@@ -239,6 +239,16 @@ const LoadStacks = (props: LoadFileFormatProps) => {
239239
// Dispatch the updated migration data to Redux
240240
dispatch(updateNewMigrationData(newMigrationDataObj));
241241
}
242+
const newMigrationDataObj: INewMigration = {
243+
// ...newMigrationDataRef?.current,
244+
...newMigrationData,
245+
destination_stack: {
246+
...newMigrationData?.destination_stack,
247+
csLocale: csLocales?.data?.locales
248+
}
249+
};
250+
// Dispatch the updated migration data to Redux
251+
dispatch(updateNewMigrationData(newMigrationDataObj));
242252
}
243253
} catch (error) {
244254
return error;

ui/src/pages/Migration/index.tsx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -188,15 +188,15 @@ const Migration = () => {
188188
const fetchProjectData = async () => {
189189
if (isEmptyString(selectedOrganisation?.value) || isEmptyString(params?.projectId)) return;
190190

191-
const data = await getMigrationData(selectedOrganisation?.value, params?.projectId ?? '');
192-
const migratedstacks = await getMigratedStacks(selectedOrganisation?.value, projectId);
193-
const csLocales = await getStackLocales(selectedOrganisation?.value);
194-
if (data) {
195-
setIsLoading(false);
196-
setProjectData(data?.data);
197-
}
198-
setIsProjectMapper(true);
199-
const projectData = data?.data;
191+
const data = await getMigrationData(selectedOrganisation?.value, params?.projectId ?? '');
192+
const migratedstacks = await getMigratedStacks(selectedOrganisation?.value, projectId );
193+
194+
if (data) {
195+
setIsLoading(false);
196+
setProjectData(data?.data);
197+
}
198+
setIsProjectMapper(true);
199+
const projectData = data?.data;
200200

201201
const legacyCmsData: ILegacyCMSComponent = await getCMSDataFromFile(CS_ENTRIES.LEGACY_CMS);
202202

@@ -280,7 +280,6 @@ const Migration = () => {
280280
stackArray: [],
281281
migratedStacks: migratedstacks?.data?.destinationStacks,
282282
sourceLocale: projectData?.source_locales,
283-
csLocale: csLocales?.data?.locales,
284283
localeMapping: locales
285284
},
286285
content_mapping: {

0 commit comments

Comments
 (0)