Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanblock committed Apr 29, 2024
1 parent 576d541 commit 80b3ae5
Show file tree
Hide file tree
Showing 35 changed files with 69 additions and 74 deletions.
6 changes: 1 addition & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ let direct = require('./src/direct')
let sam = require('./src/sam')
let _static = require('./src/static')

// eslint-disable-next-line
try { require('aws-sdk/lib/maintenance_mode_message').suppress = true }
catch { /* Noop */ }

function run (mod) {
return function (options, callback) {
let promise
Expand Down Expand Up @@ -72,5 +68,5 @@ function run (mod) {
module.exports = {
direct: run(direct),
sam: run(sam),
static: run(_static)
static: run(_static),
}
2 changes: 1 addition & 1 deletion src/cli/flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ function getSrcDirs (list) {
}
return acc
}
catch (e) { return acc }
catch { return acc }
}, [])
}
2 changes: 1 addition & 1 deletion src/direct/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,6 @@ module.exports = function deploySAM (params, callback) {
if (err) console.log(err)
callback()
})
}
},
], callback)
}
4 changes: 2 additions & 2 deletions src/direct/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ module.exports = function directDeploy (options, callback) {
update.warn('Direct deployments should be considered temporary, and will be overwritten')
update.status(
'Initializing direct deployment',
`Stack ... ${stackname}`
`Stack ... ${stackname}`,
)
pretty.warn(update)

Expand All @@ -76,7 +76,7 @@ module.exports = function directDeploy (options, callback) {
specificLambdasToDeploy,
stackname,
ts,
update
update,
}, callback)
}
}
2 changes: 1 addition & 1 deletion src/direct/pretty.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ module.exports = {
let msg = chalk.grey('Success!')
let time = chalk.green(`Deployed in ${(Date.now() - ts) / 1000} seconds`)
console.log(check, msg, time)
}
},
}
8 changes: 4 additions & 4 deletions src/direct/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ module.exports = function updateLambda (params, callback) {
})
.then(() => callback())
.catch(callback)
}
},
],
function done (err) {
update.done('Published code to Lambda')
Expand Down Expand Up @@ -102,7 +102,7 @@ module.exports = function updateLambda (params, callback) {
aws.lambda.GetFunctionConfiguration({ FunctionName })
.then(config => {
args.Environment = {
Variables: { ...config.Environment.Variables, ...env }
Variables: { ...config.Environment.Variables, ...env },
}
update.done('Updated Lambda env vars')
callback()
Expand Down Expand Up @@ -140,9 +140,9 @@ module.exports = function updateLambda (params, callback) {
.catch(callback)
})
}
}
},
], callback)
}
},
],
function done (err) {
if (err) callback(err)
Expand Down
4 changes: 2 additions & 2 deletions src/sam/02-after/00-get-app-apex/cloudfront-create.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = function createCloudFrontDistribution (params, callback) {
},
OriginReadTimeout: 30,
OriginKeepaliveTimeout: 5,
}
},
}

// Add origin path for REST APIs
Expand Down Expand Up @@ -88,7 +88,7 @@ module.exports = function createCloudFrontDistribution (params, callback) {
Items: [],
},
},
}
},
}

aws.cloudfront.CreateDistribution(config)
Expand Down
2 changes: 1 addition & 1 deletion src/sam/02-after/00-get-app-apex/cloudfront-destroy.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module.exports = function destroyCloudFrontDistribution (aws, { id: Id }, callba
aws.cloudfront.DeleteDistribution({ Id, IfMatch: ETag })
.then(() => callback())
.catch(callback)
}
},
],
function noop (err) {
// If the CF distro isn't yet fully disabled, that's ok
Expand Down
2 changes: 1 addition & 1 deletion src/sam/02-after/00-get-app-apex/cloudfront-enable.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = function enableCloudFrontDistribution (aws, { id: Id }, callbac
else {
callback()
}
}
},
],
function noop (err) {
if (err) console.log(err)
Expand Down
2 changes: 1 addition & 1 deletion src/sam/02-after/00-get-app-apex/cloudfront-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = function listCloudfrontDistributions (aws, callback) {
domain: distro.DomainName,
status: distro.Status,
origin: distro.Origins.Items[0].DomainName,
enabled: distro.Enabled
enabled: distro.Enabled,
})
callback(null, DistributionList.Items.map(fmt))
})
Expand Down
2 changes: 1 addition & 1 deletion src/sam/02-after/00-get-app-apex/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = function getAppApex (params, callback) {
reads({
aws,
stackname,
stage
stage,
},
function done (err, result) {
if (err) callback(err)
Expand Down
4 changes: 2 additions & 2 deletions src/sam/02-after/00-get-app-apex/reads.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ let list = require('./cloudfront-list')
* @param {String} params.stackname - the name of the currently deployed stack
* @param {Function} callback - node errback (err, {url, s3, apigateway})=>
*/
module.exports = function reads ({ aws, stackname, stage }, callback){
module.exports = function reads ({ aws, stackname, stage }, callback) {

let clean = str => str.replace(`/${stage}`, '').replace('http://', '').replace('https://', '')

Expand All @@ -20,7 +20,7 @@ module.exports = function reads ({ aws, stackname, stage }, callback){
},
cf (callback) {
list(aws, callback)
}
},
},
function done (err, { cfn, cf }) {
if (err) callback(err)
Expand Down
8 changes: 4 additions & 4 deletions src/sam/02-after/01-deploy-ws.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module.exports = function deployOldWebSocketAPI (params, callback) {
ApiId = api.OutputValue.split('.')[0].replace('wss://', '')
callback()
}
catch (err) {
catch {
callback(ReferenceError('Cannot find WebSocket API in CloudFormation stack'))
}
})
Expand All @@ -49,7 +49,7 @@ module.exports = function deployOldWebSocketAPI (params, callback) {
function deploy (callback) {
aws.apigatewayv2.CreateDeployment({
ApiId,
Description: 'arc_apig_cfn_patch'
Description: 'arc_apig_cfn_patch',
})
.then(result => {
if (!result?.DeploymentId) {
Expand All @@ -67,11 +67,11 @@ module.exports = function deployOldWebSocketAPI (params, callback) {
aws.apigatewayv2.UpdateStage({
ApiId,
StageName,
DeploymentId
DeploymentId,
})
.then(() => callback())
.catch(callback)
}
},
], function done (err) {
if (err && err === 'cancel') callback()
else if (err) callback(err)
Expand Down
4 changes: 2 additions & 2 deletions src/sam/bucket/create-bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ module.exports = function createDeployBucket ({ appname, aws, region, update },
Name: `/${appname}/deploy/bucket`,
Value: bucket,
Type: 'SecureString',
Overwrite: true
Overwrite: true,
})
.then(() => callback())
.catch(callback)
}
},
], function done (err) {
if (err) {
update.error('Deployment bucket creation error')
Expand Down
2 changes: 1 addition & 1 deletion src/sam/bucket/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = function getBucket (params, callback) {
// First: see if this app has a deploy bucket specified in SSM already
aws.ssm.GetParametersByPath({
Path: `/${appname}/deploy`,
WithDecryption: true
WithDecryption: true,
})
.then(result => {
let vars = result.Parameters
Expand Down
2 changes: 1 addition & 1 deletion src/sam/compat/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function getResources (aws, LogicalResourceId, StackName, callback, next) {
// (as opposed to paginating & searching)
aws.cloudformation.DescribeStackResources({
StackName,
LogicalResourceId
LogicalResourceId,
})
.then(stack => next(stack.StackResources))
.catch(err => {
Expand Down
4 changes: 2 additions & 2 deletions src/sam/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ module.exports = function samDeploy (params, callback) {
},

// Maybe pre-deploy static assets
function preDeployStatic (_template, callback){
function preDeployStatic (_template, callback) {
template = _template
let params = { aws, compat, eject, inventory, isDryRun, production, prune, region, stackname, verbose, update }
staticDeploy(params, true, callback)
Expand Down Expand Up @@ -225,7 +225,7 @@ module.exports = function samDeploy (params, callback) {
},

// Post-deploy static assets
function postDeployStatic (callback){
function postDeployStatic (callback) {
let params = { aws, compat, eject, inventory, isDryRun, production, prune, region, stackname, verbose, update }
staticDeploy(params, false, callback)
},
Expand Down
3 changes: 1 addition & 2 deletions src/sam/patches/cfn.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* - For clearer identification and to eliminate the possibility of name conflicts
* - Various services' CFN impls had issues, so this corrects them for existing apps
*/
// eslint-disable-next-line
module.exports = async function oldResources (params, callback) {
let { cloudformation: cfn, inventory, compat } = params
let { inv } = inventory
Expand All @@ -15,7 +14,7 @@ module.exports = async function oldResources (params, callback) {
cfn.Resources.WebsocketDeployment.DependsOn = [
'WebsocketConnectRoute',
'WebsocketDefaultRoute',
'WebsocketDisconnectRoute'
'WebsocketDisconnectRoute',
]
Object.entries(cfn.Resources).forEach(([ resource, value ]) => {
if (resource.endsWith('WSRoute')) {
Expand Down
6 changes: 3 additions & 3 deletions src/sam/plugins/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ module.exports = function servicesPlugins (params, callback) {
Type: 'String',
Name: { 'Fn::Sub': [
'/${AWS::StackName}/${pluginName}/${key}',
{ pluginName, key }
{ pluginName, key },
] },
Value
}
Value,
},
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion src/sam/utils/print.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ module.exports = function pretty ({ log, verbose }) {
let msg = chalk.grey('Success!')
let time = chalk.green(`Deployed app in ${(Date.now() - ts) / 1000} seconds\n`)
console.log(check, msg, time)
}
},
}
}
2 changes: 1 addition & 1 deletion src/static/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ module.exports = function deployStatic (params, callback) {
update,
verbose,
}, callback)
}
},
],
function done (err) {
if (err) callback(err)
Expand Down
2 changes: 1 addition & 1 deletion src/static/publish/filter-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = function filterFiles (params, callback) {
'.DS_Store',
'node_modules',
'readme.md',
'static.json'
'static.json',
])

// Find non-ignored files;
Expand Down
4 changes: 2 additions & 2 deletions src/static/publish/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ module.exports = function publishStaticAssets (params, callback) {
ignore: ignored,
inventory,
publishing,
publicDir
publicDir,
}, callback)
},

Expand Down Expand Up @@ -139,7 +139,7 @@ module.exports = function publishStaticAssets (params, callback) {
}, callback)
}
else callback()
}
},
], done)

function done (err) {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/bulk-delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = function bulkDelete (params, callback) {
function deleteItems () {
let deleteParams = {
Bucket,
Delete: { Objects: objects.splice(0, 1000) }
Delete: { Objects: objects.splice(0, 1000) },
}
aws.s3.DeleteObjects(deleteParams)
.then(data => {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/cleanup.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = function cleanup () {
let tmp = join(process.cwd(), '__ARC_TMP__')
rmSync(tmp, { recursive: true, force: true })
}
catch (err) {
catch {
// Don't blow up on errors, we may have to bubble something else
console.error(`Failed to clean up deployment temp directory: ${process.cwd(), '__ARC_TMP__'}`)
}
Expand Down
6 changes: 3 additions & 3 deletions src/utils/pause-sandbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = {
writeFileSync(pauseFile, '\n')
}
}
catch (err) { /* noop */ }
catch { /* noop */ }
},
unpause: () => {
try {
Expand All @@ -20,6 +20,6 @@ module.exports = {
unlinkSync(pauseFile)
}
}
catch (err) { /* noop */ }
}
catch { /* noop */ }
},
}
4 changes: 2 additions & 2 deletions test/integration/static/index-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function publish (params, callback) {

let staticDeployPath = join(process.cwd(), 'src', 'static', 'index.js')
let staticDeployMod = proxyquire(staticDeployPath, {
'./publish': publish
'./publish': publish,
})

let defaultParams = () => ({
Expand All @@ -27,7 +27,7 @@ let defaultParams = () => ({
verbose: undefined,
// `@static` settings
prefix: undefined,
prune: false
prune: false,
})
let params = defaultParams()

Expand Down
4 changes: 2 additions & 2 deletions test/integration/static/publish/index-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function deleteFiles (params, callback) {
let filePath = join(process.cwd(), 'src', 'static', 'publish', 'index.js')
let sut = proxyquire(filePath, {
'./s3/put-files': putFiles,
'./s3/delete-files': deleteFiles
'./s3/delete-files': deleteFiles,
})

let aws
Expand All @@ -34,7 +34,7 @@ let defaultParams = () => ({
inventory,
prune: false,
region: 'us-west-1',
update: updater('Deploy')
update: updater('Deploy'),
})

let arc = '@app\nan-app\n@static'
Expand Down
2 changes: 1 addition & 1 deletion test/slow/cloudfront-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ let destroy = require('../../src/sam/02-after/00-get-app-apex/cloudfront-destroy

let mock = {
api: { domain: 'brian.io', path: '/staging' },
s3: { domain: 'arc.codes' }
s3: { domain: 'arc.codes' },
}

let distros
Expand Down
Loading

0 comments on commit 80b3ae5

Please sign in to comment.