diff --git a/README.md b/README.md index e7b7de2..0f9e569 100644 --- a/README.md +++ b/README.md @@ -259,7 +259,7 @@ jobs: ${{ runner.os }}-node- - name: Install dependencies - run: yarn install --frozen-lockfile + run: yarn install --frozen-lockfile # or `yarn install --immutable` for Yarn >= 2 - name: Build and deploy to AWS run: node_modules/.bin/cdk-nuxt-deploy-server diff --git a/lib/cli/deploy-server.js b/lib/cli/deploy-server.js index 80f3e19..7762d23 100755 --- a/lib/cli/deploy-server.js +++ b/lib/cli/deploy-server.js @@ -9,6 +9,11 @@ shell.echo(`${logPrefix}: Starting deployment for dynamic Nuxt app...`); const rootFolder = process.cwd(); const deploymentSourceFolder = '.output/server'; +const yarnVersion = shell.exec('yarn -v', {silent:true}).stdout +const isYarn1 = yarnVersion && yarnVersion.startsWith('1.'); +const yarnInstallCommand = isYarn1 ? 'yarn install --frozen-lockfile' : 'yarn install --immutable'; +const yarnFunctionsInstallCommand = `${yarnInstallCommand} && ${isYarn1 ? 'yarn install-layer' : 'yarn install-layer-berry'}`; + // Refresh the cdk output folder to have a clean state and prevent persisting outdated outputs shell.echo(`${logPrefix}: Deleting outdated CDK files...`); shell.rm('-rf', 'cdk.out'); @@ -16,7 +21,7 @@ shell.rm('-rf', 'cdk.out'); // Preparing the assets cleanup Lambda function shell.echo(`${logPrefix}: Installing the assets cleanup Lambda function...`); shell.cd(path.join(__dirname, '../functions/assets-cleanup')); -if (shell.exec('yarn install --frozen-lockfile && yarn install-layer').code !== 0) { +if (shell.exec(yarnFunctionsInstallCommand).code !== 0) { shell.echo(`${logPrefix} Error: Installation of assets cleanup Lambda function failed.`); shell.exit(1); } @@ -30,7 +35,7 @@ shell.cd(rootFolder); // Preparing the access logs analysis group-by-date Lambda function shell.echo(`${logPrefix}: Installing the access logs analysis group-by-date Lambda function...`); shell.cd(path.join(__dirname, '../functions/access-logs-analysis/group-by-date')); -if (shell.exec('yarn install --frozen-lockfile && yarn install-layer').code !== 0) { +if (shell.exec(yarnFunctionsInstallCommand).code !== 0) { shell.echo(`${logPrefix} Error: Installation of access logs analysis group-by-date Lambda function failed.`); shell.exit(1); } @@ -44,7 +49,7 @@ shell.cd(rootFolder); // Preparing the access logs analysis partitioning Lambda function shell.echo(`${logPrefix}: Installing the access logs analysis partitioning Lambda function...`); shell.cd(path.join(__dirname, '../functions/access-logs-analysis/partitioning')); -if (shell.exec('yarn install --frozen-lockfile && yarn install-layer').code !== 0) { +if (shell.exec(yarnFunctionsInstallCommand).code !== 0) { shell.echo(`${logPrefix} Error: Installation of access logs analysis partitioning Lambda function failed.`); shell.exit(1); } @@ -57,7 +62,7 @@ shell.cd(rootFolder); // Install the Nuxt app dependencies shell.echo(`${logPrefix}: Installing app dependencies...`); -if (shell.exec('yarn install --frozen-lockfile').code !== 0) { +if (shell.exec(yarnInstallCommand).code !== 0) { shell.echo(`${logPrefix} Error: Installation of app dependencies failed.`); shell.exit(1); } diff --git a/lib/functions/access-logs-analysis/group-by-date/package.json b/lib/functions/access-logs-analysis/group-by-date/package.json index ef03d04..152c32e 100644 --- a/lib/functions/access-logs-analysis/group-by-date/package.json +++ b/lib/functions/access-logs-analysis/group-by-date/package.json @@ -6,6 +6,7 @@ "private": true, "scripts": { "install-layer": "yarn install --frozen-lockfile --production --modules-folder build/layer/nodejs/node_modules", + "install-layer-berry": "yarn install --immutable && cp -r node_modules build/layer/nodejs/node_modules", "build": "tsc --project ./tsconfig.json" }, "devDependencies": { diff --git a/lib/functions/access-logs-analysis/partitioning/package.json b/lib/functions/access-logs-analysis/partitioning/package.json index 8a686be..0852f13 100644 --- a/lib/functions/access-logs-analysis/partitioning/package.json +++ b/lib/functions/access-logs-analysis/partitioning/package.json @@ -6,6 +6,7 @@ "private": true, "scripts": { "install-layer": "yarn install --frozen-lockfile --production --modules-folder build/layer/nodejs/node_modules", + "install-layer-berry": "yarn install --immutable && cp -r node_modules build/layer/nodejs/node_modules", "build": "tsc --project ./tsconfig.json" }, "devDependencies": { diff --git a/lib/functions/assets-cleanup/package.json b/lib/functions/assets-cleanup/package.json index 120b3ff..5923435 100644 --- a/lib/functions/assets-cleanup/package.json +++ b/lib/functions/assets-cleanup/package.json @@ -6,6 +6,7 @@ "private": true, "scripts": { "install-layer": "yarn install --frozen-lockfile --production --modules-folder build/layer/nodejs/node_modules", + "install-layer-berry": "yarn install --immutable && cp -r node_modules build/layer/nodejs/node_modules", "build": "tsc --project ./tsconfig.json" }, "devDependencies": {