Skip to content

Commit 403a23b

Browse files
committed
Upgrade archiver.
1 parent 6791130 commit 403a23b

9 files changed

Lines changed: 1297 additions & 1345 deletions

File tree

.eslintrc

Lines changed: 0 additions & 33 deletions
This file was deleted.

bin/aws-architect.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
#!/usr/bin/env node
22

3-
let commander = require('commander');
3+
const { program } = require('commander');
44
let fs = require('fs-extra');
55
let path = require('path');
66

77
let version = require(path.join(__dirname, '../package.json')).version;
8-
commander.version(version);
8+
program.version(version);
99

1010
let displayHeader = () => {
1111
console.log('AWS Architect (%s)', version);
1212
console.log('---------------------------');
1313
};
1414

15-
commander
15+
program
1616
.command('init')
1717
.description('Setup microservice package from template.')
1818
.action(() => {
@@ -29,12 +29,14 @@ commander
2929
.catch(result => console.log(`failure: ${JSON.stringify(result, null, 2)}`));
3030
});
3131

32-
commander.on('*', () => {
33-
if (commander.args.join(' ') === 'tests/**/*.js') { return; }
32+
program.on('command:*', () => {
33+
if (program.args.join(' ') === 'tests/**/*.js') { return; }
3434
displayHeader();
35-
console.log(`Unknown Command: ${commander.args.join(' ')}`);
36-
commander.help();
35+
console.log(`Unknown Command: ${program.args.join(' ')}`);
36+
program.help();
3737
process.exit(0);
3838
});
3939

40-
commander.parse(process.argv[2] ? process.argv : process.argv.concat(['init']));
40+
if (require.main === module) {
41+
program.parse(process.argv[2] ? process.argv : process.argv.concat(['init']));
42+
}

bin/template/make.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require('error-object-polyfill');
22
const path = require('path');
3-
const commander = require('commander');
3+
const { program } = require('commander');
44
const aws = require('aws-sdk');
55
const AwsArchitect = require('aws-architect');
66

@@ -23,7 +23,7 @@ function getVersion() {
2323
return `${release_version}.${(build_number || '0')}.0.0.0.0`.split('.').slice(0, 3).join('.');
2424
}
2525
const version = getVersion();
26-
commander.version(version);
26+
program.version(version);
2727

2828
let packageMetadataFile = path.join(__dirname, 'package.json');
2929
let packageMetadata = require(packageMetadataFile);
@@ -39,7 +39,7 @@ let contentOptions = {
3939
contentDirectory: path.join(__dirname, 'content')
4040
};
4141

42-
commander
42+
program
4343
.command('run')
4444
.description('Run lambda web service locally.')
4545
.action(async () => {
@@ -60,7 +60,7 @@ commander
6060
}
6161
});
6262

63-
commander
63+
program
6464
.command('deploy')
6565
.description('Deploy to AWS.')
6666
.action(async () => {
@@ -110,7 +110,7 @@ commander
110110
}
111111
});
112112

113-
commander
113+
program
114114
.command('deploy-website')
115115
.description('Depling website to AWS.')
116116
.action(async () => {
@@ -162,7 +162,7 @@ commander
162162
}
163163
});
164164

165-
commander
165+
program
166166
.command('deploy-hosted-zone')
167167
.description('Deploy hosted zone to AWS.')
168168
.action(async () => {
@@ -190,7 +190,7 @@ commander
190190
}
191191
});
192192

193-
commander
193+
program
194194
.command('delete')
195195
.description('Delete Stage from AWS.')
196196
.action(async () => {
@@ -210,7 +210,7 @@ commander
210210
}
211211
});
212212

213-
commander
213+
program
214214
.command('delete-website')
215215
.description('Delete a website version from AWS.')
216216
.action(async () => {
@@ -230,10 +230,10 @@ commander
230230
}
231231
});
232232

233-
commander.on('*', () => {
234-
if (commander.args.join(' ') === 'tests/**/*.js') { return; }
235-
console.log(`Unknown Command: ${commander.args.join(' ')}`);
236-
commander.help();
233+
program.on('command:*', () => {
234+
if (program.args.join(' ') === 'tests/**/*.js') { return; }
235+
console.log(`Unknown Command: ${program.args.join(' ')}`);
236+
program.help();
237237
process.exit(0);
238238
});
239-
commander.parse(process.argv[2] ? process.argv : process.argv.concat(['build']));
239+
program.parse(process.argv[2] ? process.argv : process.argv.concat(['build']));

eslint.config.js

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
const nodePlugin = require('eslint-plugin-node');
2+
const importPlugin = require('eslint-plugin-import');
3+
const promisePlugin = require('eslint-plugin-promise');
4+
5+
module.exports = [
6+
{
7+
ignores: ['node_modules/**', 'dist/**', '.git/**']
8+
},
9+
{
10+
files: ['**/*.js'],
11+
languageOptions: {
12+
ecmaVersion: 2020,
13+
sourceType: 'module',
14+
globals: {
15+
console: 'readonly',
16+
process: 'readonly',
17+
Buffer: 'readonly',
18+
__dirname: 'readonly',
19+
__filename: 'readonly',
20+
module: 'readonly',
21+
require: 'readonly',
22+
global: 'readonly'
23+
}
24+
},
25+
plugins: {
26+
node: nodePlugin,
27+
import: importPlugin,
28+
promise: promisePlugin
29+
},
30+
rules: {
31+
'arrow-parens': ['error', 'as-needed'],
32+
'indent': ['error', 2, { 'SwitchCase': 1, 'MemberExpression': 0 }],
33+
'node/no-unsupported-features/es-syntax': ['off'],
34+
'no-throw-literal': 'off',
35+
'spaced-comment': 'off',
36+
'no-continue': 'off',
37+
'require-atomic-updates': 'off'
38+
}
39+
},
40+
{
41+
files: ['tests/**/*.js'],
42+
languageOptions: {
43+
globals: {
44+
describe: 'readonly',
45+
it: 'readonly',
46+
expect: 'readonly',
47+
beforeEach: 'readonly',
48+
afterEach: 'readonly',
49+
beforeAll: 'readonly',
50+
afterAll: 'readonly',
51+
vi: 'readonly'
52+
}
53+
}
54+
}
55+
];

index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class AwsArchitect {
6060
let zipStream = fs.createWriteStream(zipArchivePath);
6161
zipStream.on('close', () => resolve());
6262

63-
let archive = archiver.create('zip', {});
63+
let archive = archiver('zip', {});
6464
archive.on('error', e => reject({ Error: e }));
6565
archive.pipe(zipStream);
6666
archive.glob('**', { dot: true, cwd: tmpDir, ignore: options.zipFileName });
@@ -99,7 +99,6 @@ class AwsArchitect {
9999

100100
let cmd = lockFile.command;
101101
await new Promise((resolve, reject) => {
102-
/* eslint-disable-next-line no-unused-vars */
103102
exec(cmd, { cwd: tmpDir }, (error, stdout, stderr) => {
104103
if (error) { return reject({ Error: 'Failed installing production npm modules.', Details: error }); }
105104
return resolve(tmpDir);
@@ -112,7 +111,7 @@ class AwsArchitect {
112111
let zipStream = fs.createWriteStream(zipArchivePath);
113112
zipStream.on('close', () => resolve({ Archive: zipArchivePath }));
114113

115-
let archive = archiver.create('zip', {});
114+
let archive = archiver('zip', {});
116115
archive.on('error', e => reject({ Error: e }));
117116
archive.pipe(zipStream);
118117
archive.glob('**', { dot: true, cwd: tmpDir, ignore: lambdaZip });

lib/server.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ function Server(contentDirectory, lambdaApi, logger) {
9898
api.use(bodyParser.text({ type: ['application/x-www-form-urlencoded', 'text/css', 'text/csv', 'text/html', 'text/plain', 'text/html'] }));
9999
api.use(bodyParser.raw({ type: ['application/octet-stream', 'application/binary', 'image/*', 'audio/*', 'video/*', 'application/pdf', 'application/x-tar', 'application/zip'], limit: '6mb' }));
100100
api.use(bodyParser.json({ type: '*/*', limit: '6mb' }));
101-
/* eslint-disable-next-line no-unused-vars */
102101
api.use((error, req, res, next) => {
103102
this.logger(stringify({ title: 'Failed to parse the body', error }));
104103
res.status(400).send({ title: 'Invalid body parsing, it can be due to the default parsing types that are set up in AWS Architect Server configuration' });
@@ -246,15 +245,13 @@ function Server(contentDirectory, lambdaApi, logger) {
246245
});
247246
});
248247

249-
/* eslint-disable-next-line no-unused-vars */
250248
api.all(/.*/, (req, res, next) => {
251249
res.status(404).json({
252250
statusCode: 404,
253251
title: `Resource not found at ${req.originalUrl}`
254252
});
255253
});
256254

257-
/* eslint-disable-next-line no-unused-vars */
258255
api.use((error, req, res, next) => {
259256
console.error(`Catch-all Error: ${error.stack || error} - ${stringify(error, null, 2)}`);
260257
res.status(500).json({

make.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Module dependencies
33
*/
4-
const commander = require('commander');
4+
const { program } = require('commander');
55
const fs = require('fs-extra');
66

77
function getVersion() {
@@ -23,12 +23,12 @@ function getVersion() {
2323
return `${release_version}.${(build_number)}.0.0.0.0`.split('.').slice(0, 3).join('.');
2424
}
2525
const version = getVersion();
26-
commander.version(version);
26+
program.version(version);
2727

2828
/**
2929
* Build
3030
*/
31-
commander
31+
program
3232
.command('build')
3333
.description('Setup require build files for npm package.')
3434
.action(async () => {
@@ -43,7 +43,7 @@ commander
4343
/**
4444
* After Build
4545
*/
46-
commander
46+
program
4747
.command('after_build')
4848
.description('Publishes git tags and reports failures.')
4949
.action(() => {
@@ -52,10 +52,10 @@ commander
5252
console.log('');
5353
});
5454

55-
commander.on('*', () => {
56-
if (commander.args.join(' ') === 'tests/**/*.js') { return; }
57-
console.log(`Unknown Command: ${commander.args.join(' ')}`);
58-
commander.help();
55+
program.on('command:*', () => {
56+
if (program.args.join(' ') === 'tests/**/*.js') { return; }
57+
console.log(`Unknown Command: ${program.args.join(' ')}`);
58+
program.help();
5959
process.exit(0);
6060
});
61-
commander.parse(process.argv[2] ? process.argv : process.argv.concat(['build']));
61+
program.parse(process.argv[2] ? process.argv : process.argv.concat(['build']));

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
"@aws-sdk/client-cloudformation": "^3.1000.0",
2222
"@aws-sdk/client-s3": "^3.1000",
2323
"@aws-sdk/client-sts": "^3.1000",
24-
"archiver": "^5.3.0",
24+
"archiver": "^7.0.0",
2525
"body-parser": "^1.18.2",
26-
"commander": "^2.5.0",
26+
"commander": "^14.0.0",
2727
"cookie-parser": "^1.4.7",
2828
"express": "^5",
2929
"fs-extra": "^6.0.1",
@@ -43,7 +43,7 @@
4343
"@authress/eslint-config": "^1.0.2",
4444
"aws-sdk": "*",
4545
"error-object-polyfill": "^1.1.14",
46-
"eslint": "~8.35.0",
46+
"eslint": "^10.2.0",
4747
"eslint-config-cimpress-atsquad": "^1.0.67",
4848
"eslint-plugin-import": "^2.22.1",
4949
"eslint-plugin-node": "^11.1.0",

0 commit comments

Comments
 (0)