Skip to content

Commit

Permalink
Stabilize deployment for yarn berry
Browse files Browse the repository at this point in the history
See #9
  • Loading branch information
ferdinandfrank committed Feb 17, 2024
1 parent c0fb059 commit 1ebd45c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 9 additions & 4 deletions lib/cli/deploy-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,19 @@ 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');

// 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);
}
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
1 change: 1 addition & 0 deletions lib/functions/assets-cleanup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down

0 comments on commit 1ebd45c

Please sign in to comment.