@agilecustoms/envctl 0.37.0 → 0.37.2

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.
@@ -84,24 +84,28 @@ export class EnvService {
84
84
  const createEnv = { key };
85
85
  return await this.envApi.createEphemeral(createEnv);
86
86
  }
87
- async lockTerraform(env, cwd) {
88
- console.log('load local state config');
87
+ async lockTerraform(env, cwd, newEnv = false) {
89
88
  const config = this.localStateService.load(cwd);
90
89
  console.log('validate terraform.tfstate file');
91
90
  const stateFileContent = this.terraformAdapter.getTerraformBackend(cwd).validateAndGetStateFileContent();
92
91
  const stateHash = this.localStateService.hash(stateFileContent);
93
- if (config.stateHash !== stateHash) {
92
+ if (config.stateHash !== stateHash || newEnv) {
94
93
  config.stateHash = stateHash;
95
94
  env.stateFile = stateFileContent;
96
95
  }
97
96
  const linuxArm64 = process.platform === 'linux' && process.arch === 'arm64';
98
- if (!linuxArm64) {
97
+ if (!linuxArm64 || newEnv) {
99
98
  let lockFileContent = this.terraformAdapter.getLockFile(cwd);
100
- const lockFileHash = this.localStateService.hash(lockFileContent);
101
- if (config.lockHash !== lockFileHash) {
102
- await this.terraformAdapter.lockProviders(cwd);
103
- lockFileContent = this.terraformAdapter.getLockFile(cwd);
104
- config.lockHash = this.localStateService.hash(lockFileContent);
99
+ if (!linuxArm64) {
100
+ const lockFileHash = this.localStateService.hash(lockFileContent);
101
+ if (config.lockHash !== lockFileHash) {
102
+ await this.terraformAdapter.lockProviders(cwd);
103
+ lockFileContent = this.terraformAdapter.getLockFile(cwd);
104
+ config.lockHash = this.localStateService.hash(lockFileContent);
105
+ env.lockFile = lockFileContent;
106
+ }
107
+ }
108
+ if (newEnv) {
105
109
  env.lockFile = lockFileContent;
106
110
  }
107
111
  }
@@ -115,7 +119,7 @@ export class EnvService {
115
119
  const kind = this.cliHelper.getKind(cwd);
116
120
  console.log(`Inferred kind from directory name: ${kind}`);
117
121
  const createEnv = { key, kind };
118
- await this.lockTerraform(createEnv, cwd);
122
+ await this.lockTerraform(createEnv, cwd, true);
119
123
  console.log('Creating env metadata');
120
124
  env = await this.envApi.create(createEnv);
121
125
  await this.runDeploy(env, key, tfArgs, cwd);
@@ -125,7 +129,7 @@ export class EnvService {
125
129
  switch (env.status) {
126
130
  case EnvStatus.Init:
127
131
  this.localStateService.init(cwd);
128
- await this.lockTerraform(env, cwd);
132
+ await this.lockTerraform(env, cwd, true);
129
133
  await this.envApi.lockForUpdate(env);
130
134
  break;
131
135
  case EnvStatus.Active:
@@ -37,9 +37,10 @@ export class LocalStateService {
37
37
  load(cwd) {
38
38
  if (this.config)
39
39
  return this.config;
40
+ console.log('load local state config');
40
41
  const filePath = this.filePath(cwd);
41
42
  if (!fs.existsSync(filePath)) {
42
- console.warn('Local state file does not exist, must have been accidentally deleted, re-initializing');
43
+ console.warn('local state file does not exist, must have been accidentally deleted, re-initializing');
43
44
  return this.createEmptyConfig(filePath);
44
45
  }
45
46
  const data = fs.readFileSync(filePath, 'utf-8');
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@agilecustoms/envctl",
3
3
  "description": "node.js CLI client for manage environments",
4
- "version": "0.37.0",
4
+ "version": "0.37.2",
5
5
  "author": "Alex Chekulaev",
6
6
  "type": "module",
7
7
  "engines": {