Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use serverless version installed by package.json #12022

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ Before starting the project we're going to install some tools. We recommend havi

- Install nvm: `curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash`
- Install specified version of node. We enforce using a specific version of node, specified in the file `.nvmrc`. This version matches the Lambda runtime. We recommend managing node versions using [NVM](https://github.com/nvm-sh/nvm#installing-and-updating): `nvm install`, then `nvm use`
- Install [Serverless](https://www.serverless.com/framework/docs/providers/aws/guide/installation/): `npm install -g serverless`
- Install [yarn](https://classic.yarnpkg.com/en/docs/install/): `brew install yarn`
- Install pre-commit on your machine with either: `pip install pre-commit` or `brew install pre-commit`

Expand Down
6 changes: 0 additions & 6 deletions run
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ if ! which yarn > /dev/null ; then
exit 1
fi

# check serverless is installed globally.
if ! which serverless > /dev/null ; then
echo "installing serverless globally"
yarn global add [email protected]
fi

# have to ensure that yarn install is up to date.
# we use .yarn_install as a marker for the last time `yarn install` was run. Rerun the command when yarn.lock is updated
if [ "yarn.lock" -nt ".yarn_install" ]; then
Expand Down
23 changes: 15 additions & 8 deletions src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as dotenv from "dotenv";
import LabeledProcessRunner from "./runner.js";
import { ServerlessStageDestroyer } from "@stratiformdigital/serverless-stage-destroyer";
import { execSync } from "child_process";
import path from "path";

// load .env
dotenv.config();
Expand All @@ -17,6 +18,12 @@ const deployedServices = [
"ui-src",
];

const serverlessBin = path.join(
process.cwd(),
"node_modules/.bin",
"serverless"
);

// run_db_locally runs the local db
async function run_db_locally(runner: LabeledProcessRunner) {
await runner.run_command_and_output(
Expand All @@ -26,18 +33,18 @@ async function run_db_locally(runner: LabeledProcessRunner) {
);
await runner.run_command_and_output(
"db svls doc",
["serverless", "doctor"],
[serverlessBin, "doctor"],
"services/database"
);
await runner.run_command_and_output(
"db svls",
["serverless", "dynamodb", "install", "--stage", "local"],
[serverlessBin, "dynamodb", "install", "--stage", "local"],
"services/database"
);
runner.run_command_and_output(
"db",
[
"serverless",
serverlessBin,
"offline",
"start",
"--stage",
Expand All @@ -58,13 +65,13 @@ async function run_api_locally(runner: LabeledProcessRunner) {
);
runner.run_command_and_output(
"api svls doc",
["serverless", "doctor"],
[serverlessBin, "doctor"],
"services/app-api"
);
runner.run_command_and_output(
"api",
[
"serverless",
serverlessBin,
"offline",
"start",
"--stage",
Expand All @@ -87,12 +94,12 @@ async function run_s3_locally(runner: LabeledProcessRunner) {
);
runner.run_command_and_output(
"s3 svls doc",
["serverless", "doctor"],
[serverlessBin, "doctor"],
"services/uploads"
);
runner.run_command_and_output(
"s3",
["serverless", "s3", "start", "--stage", "local"],
[serverlessBin, "s3", "start", "--stage", "local"],
"services/uploads"
);
}
Expand All @@ -106,7 +113,7 @@ async function run_fe_locally(runner: LabeledProcessRunner) {
);
runner.run_command_and_output(
"ui svls doc",
["serverless", "doctor"],
[serverlessBin, "doctor"],
"services/ui-src"
);
await runner.run_command_and_output(
Expand Down
Loading
Loading