@gershy/lilac 0.0.11 → 0.0.12

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/cmp/cjs/main.js CHANGED
@@ -30,6 +30,7 @@ const terraform_ts_1 = require("./petal/terraform/terraform.js");
30
30
  const aws_ts_1 = require("./util/aws.js");
31
31
  const clearing_1 = require("@gershy/clearing");
32
32
  const procTerraform_ts_1 = __importDefault(require("./util/procTerraform.js"));
33
+ const util_try_with_healing_1 = __importDefault(require("@gershy/util-try-with-healing"));
33
34
  const { File, Provider, Terraform } = terraform_ts_1.PetalTerraform;
34
35
  class Flower {
35
36
  constructor() { }
@@ -261,26 +262,17 @@ class Garden {
261
262
  if (mode === 'test')
262
263
  throw Error('test mode not implemented yet');
263
264
  const { bootFact, mainFact } = await this.prepare();
264
- const tryWithHealing = async (args) => {
265
- const { fn, heal, canHeal } = args;
266
- return fn().catch(async (err) => {
267
- if (!canHeal(err))
268
- throw err;
269
- await heal();
270
- return fn();
271
- });
272
- };
273
265
  const logicalApply = (args) => {
274
- return tryWithHealing({
266
+ return (0, util_try_with_healing_1.default)({
275
267
  fn: () => this.terraformApply(args.mainFact),
276
268
  canHeal: err => (err.output ?? '')[has]('please run "terraform init"'),
277
- heal: () => tryWithHealing({
269
+ heal: () => (0, util_try_with_healing_1.default)({
278
270
  fn: async () => {
279
271
  await this.terraformInit(args.mainFact);
280
272
  await this.ctx.patioFact.kid(['main', '.terraform.lock.hcl']).setData(await args.mainFact.kid(['.terraform.lock.hcl']).getData('str'));
281
273
  },
282
274
  canHeal: err => true,
283
- heal: () => tryWithHealing({
275
+ heal: () => (0, util_try_with_healing_1.default)({
284
276
  fn: () => this.terraformApply(args.bootFact),
285
277
  canHeal: err => (err.output ?? '')[has]('please run "terraform init"'),
286
278
  heal: () => this.terraformInit(args.bootFact)
package/cmp/mjs/main.js CHANGED
@@ -10,6 +10,7 @@ import { PetalTerraform } from "./petal/terraform/terraform.js";
10
10
  import { regions as awsRegions } from "./util/aws.js";
11
11
  import { isCls, skip } from '@gershy/clearing';
12
12
  import procTerraform from "./util/procTerraform.js";
13
+ import tryWithHealing from '@gershy/util-try-with-healing';
13
14
  const { File, Provider, Terraform } = PetalTerraform;
14
15
  export class Flower {
15
16
  constructor() { }
@@ -239,15 +240,6 @@ export class Garden {
239
240
  if (mode === 'test')
240
241
  throw Error('test mode not implemented yet');
241
242
  const { bootFact, mainFact } = await this.prepare();
242
- const tryWithHealing = async (args) => {
243
- const { fn, heal, canHeal } = args;
244
- return fn().catch(async (err) => {
245
- if (!canHeal(err))
246
- throw err;
247
- await heal();
248
- return fn();
249
- });
250
- };
251
243
  const logicalApply = (args) => {
252
244
  return tryWithHealing({
253
245
  fn: () => this.terraformApply(args.mainFact),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gershy/lilac",
3
- "version": "0.0.11",
3
+ "version": "0.0.12",
4
4
  "description": "Luscious infrastructure Living as Code - an opinionated approach to IAC",
5
5
  "keywords": [
6
6
  "lilac",
@@ -31,7 +31,8 @@
31
31
  "@gershy/logger": "^0.0.3",
32
32
  "@gershy/util-http": "^0.0.4",
33
33
  "@gershy/util-nodejs-proc": "^0.0.10",
34
- "@gershy/util-phrasing": "^0.0.4"
34
+ "@gershy/util-phrasing": "^0.0.4",
35
+ "@gershy/util-try-with-healing": "^0.0.2"
35
36
  },
36
37
  "type": "module",
37
38
  "files": [