diff --git a/packages/amplify-e2e-core/src/index.ts b/packages/amplify-e2e-core/src/index.ts index 604b074ac0..50543c67e1 100644 --- a/packages/amplify-e2e-core/src/index.ts +++ b/packages/amplify-e2e-core/src/index.ts @@ -35,7 +35,49 @@ export function getCLIPath(testingWithLatestCodebase = false) { console.log('Resolving CLI path to present executable:', process.platform === 'win32' ? 'amplify.exe' : 'amplify'); return process.platform === 'win32' ? 'amplify.exe' : 'amplify'; } + + console.log('\n[DEBUG] Inspecting directory structure from root:'); + + // Get the absolute path const amplifyScriptPath = path.join(__dirname, '..', '..', '..', 'node_modules', 'amplify-cli-internal', 'bin', 'amplify'); + const absolutePath = path.resolve(amplifyScriptPath); + + // Split the path into components + const pathParts = absolutePath.split(path.sep).filter(Boolean); + + // Build up the path piece by piece from root and inspect each level + let currentPath = process.platform === 'win32' ? 'C:\\' : '/'; // Start at root + console.log(`[DEBUG] Root (${currentPath}):`); + try { + const rootContents = fs.readdirSync(currentPath); + console.log('[DEBUG] Contents:', rootContents); + } catch (err) { + console.log('[DEBUG] ⚠️ Cannot read root directory:', err.message); + } + + // Inspect each level of the path + for (const part of pathParts) { + currentPath = path.join(currentPath, part); + console.log(`\n[DEBUG] ${part} (${currentPath}):`); + + try { + if (fs.existsSync(currentPath)) { + const contents = fs.readdirSync(currentPath); + console.log('[DEBUG] ✓ Directory exists'); + console.log('[DEBUG] Contents:', contents); + } else { + console.log('[DEBUG] ✗ Directory does not exist'); + } + } catch (err) { + console.log('[DEBUG] ⚠️ Cannot read directory:', err.message); + } + } + + console.log('\n[DEBUG] Final path check:'); + console.log('[DEBUG] Expected path:', amplifyScriptPath); + console.log('[DEBUG] Absolute path:', absolutePath); + console.log('[DEBUG] Path exists:', fs.existsSync(absolutePath) ? '✓' : '✗'); + console.log('Resolving CLI Path to source code:', amplifyScriptPath); return amplifyScriptPath; } diff --git a/packages/amplify-e2e-core/src/init/initProjectHelper.ts b/packages/amplify-e2e-core/src/init/initProjectHelper.ts index 89cd6af05d..7767e9b880 100644 --- a/packages/amplify-e2e-core/src/init/initProjectHelper.ts +++ b/packages/amplify-e2e-core/src/init/initProjectHelper.ts @@ -49,7 +49,7 @@ export function initJSProjectWithProfile(cwd: string, settings?: Partial 20) console.warn('Project names should not be longer than 20 characters. This may cause tests to break.'); return new Promise((resolve, reject) => { - const chain = spawn(getCLIPath(), cliArgs, { + const chain = spawn(getCLIPath(true), cliArgs, { cwd, stripColors: true, env, diff --git a/shared-scripts.sh b/shared-scripts.sh index 14f0005ede..06a4cbc5ed 100755 --- a/shared-scripts.sh +++ b/shared-scripts.sh @@ -208,7 +208,19 @@ function _installCLIFromLocalRegistry { npm config set fetch-retry-mintimeout 30000 npm config set fetch-retry-maxtimeout 180000 npm config set maxsockets 1 - npm install -g @aws-amplify/cli-internal + # Global installation commented out in favor of local installation + # npm install -g @aws-amplify/cli-internal + + # Local installation in CODEBUILD_SRC_DIR + echo "Debug: CODEBUILD_SRC_DIR value is: $CODEBUILD_SRC_DIR" + echo "Debug: Checking if directory exists:" + ls -la $CODEBUILD_SRC_DIR || echo "Directory does not exist!" + + cd $CODEBUILD_SRC_DIR + # Initialize package.json if it doesn't exist + [ ! -f "package.json" ] && npm init -y + npm install @aws-amplify/cli-internal --save + echo "using Amplify CLI version: "$(amplify --version) npm list -g --depth=1 | grep -e '@aws-amplify/amplify-category-api' -e 'amplify-codegen' unsetNpmRegistryUrl