@@ -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
0 commit comments