Skip to content
Merged
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
39 changes: 34 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,45 @@
const {runConsole} = require('./plugin/run-console');
const {runLocal} = require('./plugin/local');
const {warnIfUsingSecretsWithoutTheBrefDependency} = require('./plugin/secrets');
const fs = require('fs');

Check failure on line 7 in index.js

View workflow job for this annotation

GitHub Actions / JS type validation and linting

Cannot find name 'fs'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node` and then add 'node' to the types field in your tsconfig.
const path = require('path');

Check failure on line 8 in index.js

View workflow job for this annotation

GitHub Actions / JS type validation and linting

Cannot find name 'path'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node` and then add 'node' to the types field in your tsconfig.

const ciEnvironmentVariables = [
'BUILD_ID', // Jenkins, Cloudbees
'BUILD_NUMBER', // Jenkins, TeamCity
'CI', // Travis CI, CircleCI, GitLab CI, etc.
'CI_APP_ID', // Appflow
'CI_BUILD_ID', // Appflow
'CI_BUILD_NUMBER', // Appflow
'CI_NAME', // Codeship and others
'CONTINUOUS_INTEGRATION', // Travis CI, Cirrus CI
'RUN_ID', // TaskCluster, dsari
'GITHUB_ACTIONS',
'GITLAB_CI',
'CIRCLECI',
'TRAVIS',
'APPVEYOR',
'BUILDKITE',
'CODEBUILD_BUILD_ARN',
'TF_BUILD', // Azure Pipelines
'TEAMCITY_VERSION',
'JENKINS_URL',
'BITBUCKET_COMMIT',
'DRONE',
'NETLIFY',
'VERCEL',
'CF_PAGES', // Cloudflare Pages
'RENDER',
'BITRISE_IO',
];

function isCiEnvironment(env) {

Check failure on line 39 in index.js

View workflow job for this annotation

GitHub Actions / JS type validation and linting

Parameter 'env' implicitly has an 'any' type.
return env.CI !== 'false' && ciEnvironmentVariables.some((name) => Boolean(env[name]));
}

// Disable `sls` promoting the Serverless Console because it's not compatible with PHP, it's tripping users up
if (!process.env.SLS_NOTIFICATIONS_MODE) {

Check failure on line 44 in index.js

View workflow job for this annotation

GitHub Actions / JS type validation and linting

Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node` and then add 'node' to the types field in your tsconfig.
process.env.SLS_NOTIFICATIONS_MODE = 'upgrades-only';

Check failure on line 45 in index.js

View workflow job for this annotation

GitHub Actions / JS type validation and linting

Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node` and then add 'node' to the types field in your tsconfig.
}

/**
Expand Down Expand Up @@ -39,7 +72,7 @@
serverless.service.provider.deploymentMethod = 'direct';
}

const filename = path.resolve(__dirname, 'layers.json');

Check failure on line 75 in index.js

View workflow job for this annotation

GitHub Actions / JS type validation and linting

Cannot find name '__dirname'.
/** @type {Record<string, Record<string, string>>} */
this.layers = JSON.parse(fs.readFileSync(filename).toString());

Expand Down Expand Up @@ -159,7 +192,7 @@
},
};

process.on('beforeExit', (code) => {

Check failure on line 195 in index.js

View workflow job for this annotation

GitHub Actions / JS type validation and linting

Parameter 'code' implicitly has an 'any' type.

Check failure on line 195 in index.js

View workflow job for this annotation

GitHub Actions / JS type validation and linting

Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node` and then add 'node' to the types field in your tsconfig.
const command = serverless.processedInput.commands[0] || '';
// On successful deploy
if (command.startsWith('deploy') && code === 0) {
Expand All @@ -173,7 +206,7 @@
* Process the `php-xx` runtimes to turn them into `provided.al2` runtimes + Bref layers.
*/
processPhpRuntimes() {
const includeBrefLayers = (runtime, existingLayers, isArm) => {

Check failure on line 209 in index.js

View workflow job for this annotation

GitHub Actions / JS type validation and linting

Parameter 'existingLayers' implicitly has an 'any' type.

Check failure on line 209 in index.js

View workflow job for this annotation

GitHub Actions / JS type validation and linting

Parameter 'runtime' implicitly has an 'any' type.
let layerName = runtime;
// Automatically use ARM layers if the function is deployed to an ARM architecture
if (isArm) {
Expand Down Expand Up @@ -281,10 +314,6 @@
/** @type {{ get: (string) => string }} */
// @ts-ignore
const userConfig = require.main.require('@serverless/utils/config');
/** @type {typeof import('ci-info')} */
// @ts-ignore
const ci = require.main.require('ci-info');

let command = 'unknown';
if (this.serverless.processedInput && this.serverless.processedInput.commands) {
command = this.serverless.processedInput.commands.join(' ');
Expand All @@ -301,7 +330,7 @@
cli: 'sls',
v: 2, // Bref version
c: command,
ci: ci.isCI,
ci: isCiEnvironment(process.env),
install: userConfig.get('meta.created_at'),
uid: userConfig.get('frameworkId'), // anonymous user ID created by the Serverless Framework
tz: timezone,
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
},
"devDependencies": {
"@serverless/typescript": "^3.30.1",
"@types/ci-info": "^3.1.0",
"@types/node": "^20.3.1",
"@typescript-eslint/eslint-plugin": "^5.59.11",
"@typescript-eslint/parser": "^5.59.11",
Expand Down