aws-architect 6.7.57 → 6.7.59

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,8 @@ This is the changelog for [AWS Architect](readme.md).
5
5
  * Fix handlers for /route and /route/ so that the index.html is always duplicated.
6
6
  * Add support for organizational stack set deployment
7
7
  * Remove invalid regions from organizational deployment [eu-central-2, ap-south-2, eu-south-2, me-central-1, ap-southeast-4]
8
+ * Support pnpm lock files
9
+ * Support the new version of openapi-factory 5.4.
8
10
 
9
11
  ## 6.6 ##
10
12
  * Add support to `deleteWebsiteVersion(version)`
package/index.js CHANGED
@@ -81,9 +81,10 @@ AwsArchitect.prototype.publishLambdaArtifactPromise = AwsArchitect.prototype.Pub
81
81
 
82
82
  // (default: true) If set to true, will attempt to copy and install packages related to deployment (i.e. package.json for node)
83
83
  if (options.autoHandleCompileOfSourceDirectory !== false) {
84
- await new LockFinder().findLockFile(this.SourceDirectory).then(lockFile => {
85
- return lockFile ? fs.copy(lockFile.file, path.join(tmpDir, path.basename(lockFile.file))) : Promise.resolve();
86
- });
84
+ const lockFile = await new LockFinder().findLockFile(this.SourceDirectory);
85
+ if (lockFile.file) {
86
+ await fs.copy(lockFile.file, path.join(tmpDir, path.basename(lockFile.file)));
87
+ }
87
88
 
88
89
  try {
89
90
  await fs.writeJson(path.join(tmpDir, 'package.json'), this.PackageMetadata);
@@ -91,8 +92,7 @@ AwsArchitect.prototype.publishLambdaArtifactPromise = AwsArchitect.prototype.Pub
91
92
  throw { Error: 'Failed writing production package.json file.', Details: error };
92
93
  }
93
94
 
94
- const exists = await fs.pathExists(path.join(tmpDir, 'yarn.lock')).catch(() => false);
95
- let cmd = exists ? 'yarn --prod --frozen-lockfile' : 'npm install --production';
95
+ let cmd = lockFile.command;
96
96
  await new Promise((resolve, reject) => {
97
97
  /* eslint-disable-next-line no-unused-vars */
98
98
  exec(cmd, { cwd: tmpDir }, (error, stdout, stderr) => {
package/lib/lockFinder.js CHANGED
@@ -3,19 +3,27 @@ let path = require('path');
3
3
  let fs = require('fs-extra');
4
4
 
5
5
  module.exports = function LockFinder() {
6
- let findLockFile = directory => {
6
+ let findLockFile = async directory => {
7
7
  if (!directory || directory === '/' || directory === '' || directory.match(/^[a-zA-Z]:\\$/)) { return null; }
8
-
8
+
9
9
  let yarnLockFile = path.join(directory, 'yarn.lock');
10
10
  let packageLockFile = path.join(directory, 'package-lock.json');
11
- return fs.pathExists(yarnLockFile)
12
- .then(exists => {
13
- return exists ? { type: 'yarn', file: yarnLockFile } : fs.pathExists(packageLockFile)
14
- .then(npmExists => {
15
- return npmExists ? { type: 'npm', file: packageLockFile } : findLockFile(path.join(directory, '..'));
16
- });
17
- })
18
- .catch(() => null);
11
+ let pnpmLockFile = path.join(directory, 'pnpm-lock.yaml');
12
+ try {
13
+ if (await fs.pathExists(yarnLockFile)) {
14
+ return { type: 'yarn', file: yarnLockFile, command: 'yarn --prod --frozen-lockfile' };
15
+ }
16
+ if (await fs.pathExists(packageLockFile)) {
17
+ return { type: 'npm', file: packageLockFile, command: 'npm install --production' };
18
+ }
19
+ if (await fs.pathExists(pnpmLockFile)) {
20
+ return { type: 'pnpm', file: pnpmLockFile, command: 'pnpm --prod --frozen-lockfile' };
21
+ }
22
+
23
+ return await findLockFile(path.join(directory, '..'));
24
+ } catch (error) {
25
+ return { command: 'npm install --production' };
26
+ }
19
27
  };
20
28
 
21
29
  this.findLockFile = findLockFile;
package/lib/server.js CHANGED
@@ -104,8 +104,23 @@ function Server(contentDirectory, lambdaApi, logger) {
104
104
  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' });
105
105
  });
106
106
 
107
- Object.keys(lambdaApi.Routes || []).map(method => {
108
- const sortedPathKeys = Object.keys(lambdaApi.Routes[method]).sort((a, b) => a.split('/').length - b.split('/').length || a.split('{').length - b.split('{').length);
107
+ let routes = lambdaApi.Routes || {};
108
+ const usingPathFirstImplementation = Object.keys(routes)[0].match('/');
109
+ if (usingPathFirstImplementation) {
110
+ const newRoutes = {};
111
+ Object.keys(routes).map(route => {
112
+ Object.keys(routes[route]).map(method => {
113
+ if (!newRoutes[method]) {
114
+ newRoutes[method] = {};
115
+ }
116
+ newRoutes[method][route] = routes[route][method];
117
+ });
118
+ });
119
+ routes = newRoutes;
120
+ }
121
+
122
+ Object.keys(routes).map(method => {
123
+ const sortedPathKeys = Object.keys(routes[method]).sort((a, b) => a.split('/').length - b.split('/').length || a.split('{').length - b.split('{').length);
109
124
  sortedPathKeys.map(resource => {
110
125
  let isProxy = resource.match(/{proxy\+}/);
111
126
  let expressResource = resource.replace(/{proxy\+}/, '*').replace(/{([^{}]+)}/g, ':$1');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aws-architect",
3
- "version": "6.7.57",
3
+ "version": "6.7.59",
4
4
  "description": "AWS Architect is a node based tool to configure and deploy AWS-based microservices.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",