Skip to content

Commit

Permalink
Merge pull request #2435 from graphcommerce-org/feature/adobe-commerce
Browse files Browse the repository at this point in the history
Adobe commerce compat
  • Loading branch information
paales authored Nov 28, 2024
2 parents 1bd7d2e + ea4eb8d commit 8de315a
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 20,345 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,4 @@ build
!.yarn/releases
!.yarn/sdks
!.yarn/versions
yarn.lock
2 changes: 1 addition & 1 deletion packages/google-datalayer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@graphcommerce/react-hook-form": "^9.0.0-canary.107",
"@graphcommerce/typescript-config-pwa": "^9.0.0-canary.107",
"@mui/material": "^5.14.20",
"next": "^14",
"next": "*",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/graphql-mesh/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@graphql-tools/utils": "^10.6.0",
"@whatwg-node/fetch": "^0.10.1",
"fetch-retry": "^5.0.6",
"graphql": "^16.7.1",
"graphql": "^16.9.0",
"long": "^5.2.3",
"tslib": "^2.7.0",
"uglify-es": "3.3.10"
Expand Down
2 changes: 1 addition & 1 deletion packages/graphql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"@graphql-codegen/typescript-document-nodes": "4.0.12",
"@graphql-codegen/typescript-operations": "4.4.0",
"apollo3-cache-persist": "^0.15.0",
"graphql": "^16.7.1"
"graphql": "^16.9.0"
},
"peerDependencies": {
"@graphcommerce/eslint-config-pwa": "^9.0.0-canary.107",
Expand Down
2 changes: 1 addition & 1 deletion packages/hygraph-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"dependencies": {
"@hygraph/management-sdk": "1.2.5",
"@whatwg-node/fetch": "^0.10.1",
"graphql": "^16.7.1",
"graphql": "^16.9.0",
"graphql-tag": "^2.12.6",
"prompts": "^2.4.2"
},
Expand Down
78 changes: 48 additions & 30 deletions packagesDev/next-config/dist/commands/copyFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.copyFiles = copyFiles;
/* eslint-disable no-await-in-loop */
const promises_1 = __importDefault(require("fs/promises"));
const path_1 = __importDefault(require("path"));
const fast_glob_1 = __importDefault(require("fast-glob"));
Expand Down Expand Up @@ -191,8 +192,7 @@ Found in packages:
Source: ${sourcePath}`);
process.exit(1);
}
console.log(`Creating new file: ${file}
Source: ${sourcePath}`);
console.log(`Creating new file: ${file}`);
debug('File does not exist yet');
}
// Skip if content is identical (including magic comment)
Expand Down Expand Up @@ -220,47 +220,66 @@ Source: ${sourcePath}`);
}
}));
debug(`Copied ${managedFiles.size} files in ${(performance.now() - copyStart).toFixed(0)}ms`);
// Handle removal of files that are no longer provided by any package
// Remove files that are no longer provided
const removeStart = performance.now();
const filesToRemove = Array.from(existingManagedFiles).filter((file) => !fileMap.has(file));
const filesToRemove = Array.from(existingManagedFiles).filter((file) => !managedFiles.has(file));
debug(`Files to remove: ${filesToRemove.length}`);
// Helper function to remove empty directories
async function removeEmptyDirs(startPath) {
const dirs = [];
let dirPath = path_1.default.dirname(startPath);
while (dirPath !== cwd) {
dirs.push(dirPath);
dirPath = path_1.default.dirname(dirPath);
}
// Process directories in parallel
await Promise.all(dirs.map(async (dir) => {
// Helper function to recursively clean up empty directories
async function cleanupEmptyDirs(startPath) {
let currentDir = startPath;
while (currentDir !== cwd) {
try {
const files = await promises_1.default.readdir(dir);
if (files.length === 0) {
await promises_1.default.rmdir(dir);
debug(`Removed empty directory: ${dir}`);
const dirContents = await promises_1.default.readdir(currentDir);
if (dirContents.length === 0) {
await promises_1.default.rmdir(currentDir);
debug(`Removed empty directory: ${currentDir}`);
currentDir = path_1.default.dirname(currentDir);
}
else {
break; // Stop if directory is not empty
}
}
catch {
// Ignore errors for directories we can't access
catch (err) {
if (err.code === 'EACCES') {
console.error(`Error cleaning up directory ${currentDir}: ${err.message}`);
process.exit(1);
}
break; // Stop on other errors (like ENOENT)
}
}));
}
}
// Remove files in parallel
// Process file removals in parallel
await Promise.all(filesToRemove.map(async (file) => {
const filePath = path_1.default.join(cwd, file);
const dirPath = path_1.default.dirname(filePath);
try {
await promises_1.default.unlink(filePath);
console.log(`Removed managed file that is no longer provided: ${file}`);
debug(`Removed file: ${file}`);
// Clean up empty directories after file removal
await removeEmptyDirs(filePath);
// First check if the directory exists and is accessible
await promises_1.default.readdir(dirPath);
// Then try to remove the file
try {
await promises_1.default.unlink(filePath);
console.log(`Removed managed file: ${file}`);
debug(`Removed file: ${file}`);
}
catch (err) {
if (err.code !== 'ENOENT') {
console.error(`Error removing file ${file}: ${err.message}`);
process.exit(1);
}
}
// Finally, try to clean up empty directories
await cleanupEmptyDirs(dirPath);
}
catch (err) {
console.error(`Error removing file ${file}: ${err.message}`);
if (err.code === 'EACCES') {
console.error(`Error accessing directory ${dirPath}: ${err.message}`);
process.exit(1);
}
// Ignore ENOENT errors for directories that don't exist
}
}));
// Update .gitignore with the current list of managed files
debug(`Removed files in ${(performance.now() - removeStart).toFixed(0)}ms`);
// Update .gitignore with current list of managed files
if (managedFiles.size > 0) {
debug('Found managed files:', Array.from(managedFiles));
await updateGitignore(Array.from(managedFiles));
Expand All @@ -269,6 +288,5 @@ Source: ${sourcePath}`);
debug('No managed files found, cleaning up .gitignore section');
await updateGitignore([]);
}
debug(`Handled removals in ${(performance.now() - removeStart).toFixed(0)}ms`);
debug(`Total execution time: ${(performance.now() - startTime).toFixed(0)}ms`);
}
3 changes: 1 addition & 2 deletions packagesDev/next-config/src/commands/copyFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,7 @@ Found in packages:
Source: ${sourcePath}`)
process.exit(1)
}
console.log(`Creating new file: ${file}
Source: ${sourcePath}`)
console.log(`Creating new file: ${file}`)
debug('File does not exist yet')
}

Expand Down
3 changes: 3 additions & 0 deletions vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"installCommand": "yarn install"
}
Loading

0 comments on commit 8de315a

Please sign in to comment.