Skip to content

Commit

Permalink
bump deps and update a few exception types as required for ts update
Browse files Browse the repository at this point in the history
  • Loading branch information
icecream-monster authored and tavisrudd committed Sep 22, 2021
1 parent db225b8 commit abd19a9
Show file tree
Hide file tree
Showing 8 changed files with 13,213 additions and 2,674 deletions.
15,738 changes: 13,137 additions & 2,601 deletions package-lock.json

Large diffs are not rendered by default.

91 changes: 46 additions & 45 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,69 +24,70 @@
"npm": ">=6.0.0"
},
"dependencies": {
"auto-changelog": "1.16.1",
"auto-changelog": "2.3.0",
"aws-sdk": "github:unbounce/aws-sdk-js#e3528b1490257ec60ea2c2bc9eb0129d42f17263",
"bluebird": "3.7.1",
"bluebird": "3.7.2",
"cli-color": "^2.0.0",
"dateformat": "^3.0.3",
"didyoumean2": "3.1.2",
"glob": "7.1.6",
"handlebars": "4.5.3",
"dateformat": "4.5.1",
"didyoumean2": "5.0.0",
"esm": "3.2.25",
"glob": "7.1.7",
"handlebars": "^4.7.7",
"handlebars-helpers": "^0.10.0",
"inquirer": "7.0.0",
"inquirer": "8.1.5",
"jmespath": "0.15.0",
"js-yaml": "^3.13.1",
"laundry-cfn": "1.6.0",
"lodash": "4.17.19",
"js-yaml": "3.14.1",
"laundry-cfn": "^1.6.2",
"lodash": "^4.17.21",
"ntp-client": "^0.5.3",
"ora": "4.0.2",
"project-name-generator": "2.1.7",
"request": "^2.88.0",
"request-promise-native": "^1.0.7",
"tmp": "^0.1.0",
"ts-md5": "1.2.7",
"ora": "5.4.1",
"project-name-generator": "2.1.9",
"request": "2.88.2",
"request-promise-native": "1.0.9",
"tmp": "0.2.1",
"ts-md5": "1.2.9",
"tv4": "^1.3.0",
"winston": "github:winstonjs/winston#1a7554486dd71e5656b4fd3cd9168fc3620df9a8",
"wrap-ansi": "^5.1.0",
"wrap-ansi": "7.0.0",
"yargs": "14.2.0"
},
"devDependencies": {
"@octokit/rest": "16.35.2",
"@types/bluebird": "3.5.28",
"@types/bluebird-global": "3.5.12",
"@types/chai": "4.2.4",
"@types/cli-color": "^0.3.29",
"@octokit/rest": "18.10.0",
"@types/bluebird": "3.5.36",
"@types/bluebird-global": "3.5.13",
"@types/chai": "4.2.22",
"@types/cli-color": "2.0.1",
"@types/dateformat": "3.0.1",
"@types/glob": "7.1.1",
"@types/handlebars-helpers": "^0.5.2",
"@types/inquirer": "6.5.0",
"@types/glob": "7.1.4",
"@types/handlebars-helpers": "0.5.3",
"@types/inquirer": "8.1.2",
"@types/jmespath": "^0.15.0",
"@types/js-yaml": "^3.12.1",
"@types/lodash": "4.14.144",
"@types/mocha": "5.2.7",
"@types/node": "10.17.0",
"@types/pad": "^1.0.2",
"@types/request": "2.48.3",
"@types/request-promise": "4.1.44",
"@types/js-yaml": "3.12.7",
"@types/lodash": "4.14.173",
"@types/mocha": "8.2.3",
"@types/node": "12.12.6",
"@types/pad": "2.1.0",
"@types/request": "2.48.7",
"@types/request-promise": "4.1.48",
"@types/request-promise-native": "1.0.16",
"@types/sprintf-js": "^1.1.2",
"@types/tmp": "^0.1.0",
"@types/tv4": "^1.2.29",
"@types/tmp": "0.2.1",
"@types/tv4": "1.2.31",
"@types/wrap-ansi": "^3.0.0",
"@types/yargs": "12.0.1",
"chai": "^4.2.0",
"chai-exclude": "2.0.2",
"chai": "4.3.4",
"chai-exclude": "2.0.3",
"intercept-stdout": "^0.1.2",
"mocha": "6.2.2",
"mocha": "8.4.0",
"mocha-typescript": "^1.1.17",
"nyc": "^14.0.0",
"patch-package": "6.2.0",
"pkg": "4.4.0",
"source-map-support": "0.5.13",
"ts-mocha": "^6.0.0",
"ts-node": "8.4.1",
"tslint": "5.20.0",
"typescript": "3.6.4"
"nyc": "15.1.0",
"patch-package": "6.4.7",
"pkg": "5.3.2",
"source-map-support": "0.5.20",
"ts-mocha": "8.0.0",
"ts-node": "10.2.1",
"tslint": "6.1.3",
"typescript": "4.4.3"
},
"mocha": {
"require": [
Expand Down
11 changes: 4 additions & 7 deletions patches/pkg+4.4.0.patch → patches/pkg+5.3.2.patch
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@ diff --git a/node_modules/pkg/prelude/bootstrap.js.bak b/node_modules/pkg/prelud
index 35b5989..677d270 100644
--- a/node_modules/pkg/prelude/bootstrap.js.bak
+++ b/node_modules/pkg/prelude/bootstrap.js
@@ -1333,6 +1333,9 @@ function payloadFileSync (pointer) {
var opts = args[pos];
if (!opts.env) opts.env = require('util')._extend({}, process.env);
@@ -1828,5 +1828,6 @@
const opts = args[pos];
if (!opts.env) opts.env = _extend({}, process.env);
if (opts.env.PKG_EXECPATH === 'PKG_INVOKE_NODEJS') return;
+ if (opts.env.PKG_SKIP_EXECPATH_PATCH) {
+ return;
+ }
+ if (opts.env.PKG_SKIP_EXECPATH_PATCH) return;
opts.env.PKG_EXECPATH = EXECPATH;
}

6 changes: 3 additions & 3 deletions src/cfn/AbstractCloudFormationStackCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export abstract class AbstractCloudFormationStackCommand {
await this._updateStackTerminationPolicy();
return this._watchAndSummarize(createStackOutput.StackId as string);
} catch (e) {
if (e.message === 'CreateStack cannot be used with templates containing Transforms.') {
if (e instanceof Error && e.message === 'CreateStack cannot be used with templates containing Transforms.') {
logger.error(`Your stack template contains an AWS:: Transform so you need to use 'iidy create-or-update ${cli.red('--changeset')}'`);
return INTERRUPT;
} else {
Expand Down Expand Up @@ -198,10 +198,10 @@ export abstract class AbstractCloudFormationStackCommand {
const updateStackOutput = await this.cfn.updateStack(updateStackInput).promise();
return this._watchAndSummarize(updateStackOutput.StackId as string);
} catch (e) {
if (e.message === 'No updates are to be performed.') {
if (e instanceof Error && e.message === 'No updates are to be performed.') {
logger.info('No changes detected so no stack update needed.');
return SUCCESS;
} else if (e.message === 'UpdateStack cannot be used with templates containing Transforms.') {
} else if (e instanceof Error && e.message === 'UpdateStack cannot be used with templates containing Transforms.') {
const command = this.normalizeIidyCLICommand(`update-stack ${cli.red('--changeset')}'`);
logger.error(`Your stack template contains an AWS:: Transform so you need to use '${command}'`);
return INTERRUPT;
Expand Down
10 changes: 5 additions & 5 deletions src/cfn/approval/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {S3} from 'aws-sdk';
import {S3, AWSError} from 'aws-sdk';
import * as cli from 'cli-color';
import * as _ from 'lodash';
import * as path from 'path';
Expand Down Expand Up @@ -35,7 +35,7 @@ export async function request(argv: RequestArguments): Promise<number> {
await s3.headObject(s3Args).promise();
logSuccess(`👍 Your template has already been approved`);
} catch (e) {
if (e.code === "NotFound") {
if (e instanceof AWSError && e.code === "NotFound") {
s3Args.Key = `${s3Args.Key}.pending`
const cfnTemplate = await loadCFNTemplate(stackArgs.Template, argv.argsfile, argv.environment, {omitMetadata: true}, S3_TEMPLATE_MAX_BYTES);
if (argv.lintTemplate && cfnTemplate.TemplateBody) {
Expand All @@ -57,7 +57,7 @@ export async function request(argv: RequestArguments): Promise<number> {
logSuccess(`Successfully uploaded the cloudformation template to ${stackArgs.ApprovedTemplateLocation}`);
logSuccess(`Approve template with:\n iidy template-approval review s3://${s3Args.Bucket}/${s3Args.Key}`);
} else {
throw new Error(e);
throw e;
}
}

Expand Down Expand Up @@ -91,7 +91,7 @@ export async function review(argv: ReviewArguments): Promise<number> {

logSuccess(`👍 The template has already been approved`);
} catch (e) {
if (e.code === 'NotFound') {
if (e instanceof AWSError && e.code === 'NotFound') {

const pendingTemplate = await s3.getObject({
Bucket: s3Bucket,
Expand Down Expand Up @@ -150,7 +150,7 @@ export async function review(argv: ReviewArguments): Promise<number> {
}

} else {
throw new Error(e);
throw e;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/params/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ async function maybeFetchParam(ssm: aws.SSM, req: aws.SSM.GetParameterRequest):
const res = await ssm.getParameter(req).promise();
return res && res.Parameter;
} catch (e) {
if (e.code && e.code === 'ParameterNotFound') {
if (e instanceof aws.AWSError && e.code && e.code === 'ParameterNotFound') {
return undefined;
} else {
throw e;
Expand Down
27 changes: 16 additions & 11 deletions src/preprocess/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,17 @@ handlebars.registerHelper('base64', (context: any) => Buffer.from(context).toStr
handlebars.registerHelper('toLowerCase', (str: string) => str.toLowerCase());
handlebars.registerHelper('toUpperCase', (str: string) => str.toUpperCase());

handlebarsHelpers(['string'], { handlebars });
handlebarsHelpers(['string'], {handlebars});

export function interpolateHandlebarsString(templateString: string, env: object, errorContext: string) {
try {
const template = handlebars.compile(templateString, {noEscape: true, strict: true});
return template(env);
} catch (e) {
logger.debug(e);
const errMessage = e instanceof Error ? e.message : `${e}`;
logger.debug(errMessage);
throw new Error(
`Error in string template at ${errorContext}:\n ${e.message}\n Template: ${templateString}`)
`Error in string template at ${errorContext}:\n ${errMessage}\n Template: ${templateString}`)
}
}

Expand Down Expand Up @@ -426,9 +427,9 @@ export const importLoaders: {[key in ImportType]: ImportLoader} = {
const param = await ssm.getParameter({Name: resolvedLocation, WithDecryption: true}).promise();
if (param.Parameter && param.Parameter.Value) {
const data = parseDataFromParamStore(param.Parameter.Value, format);
return {resolvedLocation, data, doc: data};
} else {
throw new Error(
return {resolvedLocation, data, doc: data};
} else {
throw new Error(
`Invalid ssm parameter ${resolvedLocation} import at ${baseLocation}`);
}
},
Expand All @@ -451,16 +452,20 @@ export const importLoaders: {[key in ImportType]: ImportLoader} = {
export async function readFromImportLocation(location: ImportLocation, baseLocation: ImportLocation)
: Promise<ImportData> {
// TODO handle relative paths and non-file types
const importType = parseImportType(location, baseLocation);
try {
const importData: ImportData = await importLoaders[importType](location, baseLocation);
return _.merge({importType}, importData);
} catch (error) {
const importType = parseImportType(location, baseLocation);
try {
const importData: ImportData = await importLoaders[importType](location, baseLocation);
return _.merge({importType}, importData);
} catch (error) {
if (error instanceof Error) {
throw new ImportError(
error.message || `Invalid import ${location} import at ${baseLocation}`,
location, baseLocation, error
);
} else {
throw error;
}
}
}

export async function loadImports(
Expand Down
2 changes: 1 addition & 1 deletion src/tests/test-yaml-preprocessing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ aref: !$ nested.aref`, mockLoader)).to.deep.equal({aref: 'mock'});
}))
.excludingEvery(['visited'])
.to.deep.equal({out: new ctor('abc')});
} catch (err) {
} catch (err: any) {
err.message = `${tag_name}: ${err.message}`;
throw err;
}
Expand Down

0 comments on commit abd19a9

Please sign in to comment.