hereya-cli 0.14.0 → 0.15.0

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/README.md CHANGED
@@ -20,7 +20,7 @@ $ npm install -g hereya-cli
20
20
  $ hereya COMMAND
21
21
  running command...
22
22
  $ hereya (--version)
23
- hereya-cli/0.14.0 linux-x64 node-v22.13.0
23
+ hereya-cli/0.15.0 linux-x64 node-v22.13.0
24
24
  $ hereya --help [COMMAND]
25
25
  USAGE
26
26
  $ hereya COMMAND
@@ -73,7 +73,7 @@ EXAMPLES
73
73
  $ hereya add cloudy/docker_postgres
74
74
  ```
75
75
 
76
- _See code: [src/commands/add/index.ts](https://github.com/hereya/hereya-cli/blob/v0.14.0/src/commands/add/index.ts)_
76
+ _See code: [src/commands/add/index.ts](https://github.com/hereya/hereya-cli/blob/v0.15.0/src/commands/add/index.ts)_
77
77
 
78
78
  ## `hereya bootstrap INFRASTRUCTURETYPE`
79
79
 
@@ -98,7 +98,7 @@ EXAMPLES
98
98
  $ hereya bootstrap local
99
99
  ```
100
100
 
101
- _See code: [src/commands/bootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.14.0/src/commands/bootstrap/index.ts)_
101
+ _See code: [src/commands/bootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.15.0/src/commands/bootstrap/index.ts)_
102
102
 
103
103
  ## `hereya deploy`
104
104
 
@@ -120,7 +120,7 @@ EXAMPLES
120
120
  $ hereya deploy
121
121
  ```
122
122
 
123
- _See code: [src/commands/deploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.14.0/src/commands/deploy/index.ts)_
123
+ _See code: [src/commands/deploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.15.0/src/commands/deploy/index.ts)_
124
124
 
125
125
  ## `hereya down`
126
126
 
@@ -143,7 +143,7 @@ EXAMPLES
143
143
  $ hereya down
144
144
  ```
145
145
 
146
- _See code: [src/commands/down/index.ts](https://github.com/hereya/hereya-cli/blob/v0.14.0/src/commands/down/index.ts)_
146
+ _See code: [src/commands/down/index.ts](https://github.com/hereya/hereya-cli/blob/v0.15.0/src/commands/down/index.ts)_
147
147
 
148
148
  ## `hereya env [NAME]`
149
149
 
@@ -174,7 +174,7 @@ EXAMPLES
174
174
  $ hereya env -w dev -l
175
175
  ```
176
176
 
177
- _See code: [src/commands/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.14.0/src/commands/env/index.ts)_
177
+ _See code: [src/commands/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.15.0/src/commands/env/index.ts)_
178
178
 
179
179
  ## `hereya help [COMMAND]`
180
180
 
@@ -220,7 +220,7 @@ EXAMPLES
220
220
  $ hereya init myProject -w=defaultWorkspace --chdir=./myProject
221
221
  ```
222
222
 
223
- _See code: [src/commands/init/index.ts](https://github.com/hereya/hereya-cli/blob/v0.14.0/src/commands/init/index.ts)_
223
+ _See code: [src/commands/init/index.ts](https://github.com/hereya/hereya-cli/blob/v0.15.0/src/commands/init/index.ts)_
224
224
 
225
225
  ## `hereya remove PACKAGE`
226
226
 
@@ -244,7 +244,7 @@ EXAMPLES
244
244
  $ hereya remove cloudy/docker_postgres
245
245
  ```
246
246
 
247
- _See code: [src/commands/remove/index.ts](https://github.com/hereya/hereya-cli/blob/v0.14.0/src/commands/remove/index.ts)_
247
+ _See code: [src/commands/remove/index.ts](https://github.com/hereya/hereya-cli/blob/v0.15.0/src/commands/remove/index.ts)_
248
248
 
249
249
  ## `hereya run CMD`
250
250
 
@@ -270,7 +270,7 @@ EXAMPLES
270
270
  $ hereya run -w uat -- node index.js
271
271
  ```
272
272
 
273
- _See code: [src/commands/run/index.ts](https://github.com/hereya/hereya-cli/blob/v0.14.0/src/commands/run/index.ts)_
273
+ _See code: [src/commands/run/index.ts](https://github.com/hereya/hereya-cli/blob/v0.15.0/src/commands/run/index.ts)_
274
274
 
275
275
  ## `hereya unbootstrap INFRASTRUCTURETYPE`
276
276
 
@@ -295,7 +295,7 @@ EXAMPLES
295
295
  $ hereya unbootstrap local
296
296
  ```
297
297
 
298
- _See code: [src/commands/unbootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.14.0/src/commands/unbootstrap/index.ts)_
298
+ _See code: [src/commands/unbootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.15.0/src/commands/unbootstrap/index.ts)_
299
299
 
300
300
  ## `hereya undeploy`
301
301
 
@@ -317,7 +317,7 @@ EXAMPLES
317
317
  $ hereya undeploy
318
318
  ```
319
319
 
320
- _See code: [src/commands/undeploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.14.0/src/commands/undeploy/index.ts)_
320
+ _See code: [src/commands/undeploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.15.0/src/commands/undeploy/index.ts)_
321
321
 
322
322
  ## `hereya up`
323
323
 
@@ -340,7 +340,7 @@ EXAMPLES
340
340
  $ hereya up
341
341
  ```
342
342
 
343
- _See code: [src/commands/up/index.ts](https://github.com/hereya/hereya-cli/blob/v0.14.0/src/commands/up/index.ts)_
343
+ _See code: [src/commands/up/index.ts](https://github.com/hereya/hereya-cli/blob/v0.15.0/src/commands/up/index.ts)_
344
344
 
345
345
  ## `hereya workspace create NAME`
346
346
 
@@ -360,7 +360,7 @@ EXAMPLES
360
360
  $ hereya workspace create dev
361
361
  ```
362
362
 
363
- _See code: [src/commands/workspace/create/index.ts](https://github.com/hereya/hereya-cli/blob/v0.14.0/src/commands/workspace/create/index.ts)_
363
+ _See code: [src/commands/workspace/create/index.ts](https://github.com/hereya/hereya-cli/blob/v0.15.0/src/commands/workspace/create/index.ts)_
364
364
 
365
365
  ## `hereya workspace delete NAME`
366
366
 
@@ -380,7 +380,7 @@ EXAMPLES
380
380
  $ hereya workspace delete dev
381
381
  ```
382
382
 
383
- _See code: [src/commands/workspace/delete/index.ts](https://github.com/hereya/hereya-cli/blob/v0.14.0/src/commands/workspace/delete/index.ts)_
383
+ _See code: [src/commands/workspace/delete/index.ts](https://github.com/hereya/hereya-cli/blob/v0.15.0/src/commands/workspace/delete/index.ts)_
384
384
 
385
385
  ## `hereya workspace env [NAME]`
386
386
 
@@ -406,7 +406,7 @@ EXAMPLES
406
406
  $ hereya workspace env myEnv -w dev
407
407
  ```
408
408
 
409
- _See code: [src/commands/workspace/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.14.0/src/commands/workspace/env/index.ts)_
409
+ _See code: [src/commands/workspace/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.15.0/src/commands/workspace/env/index.ts)_
410
410
 
411
411
  ## `hereya workspace env set`
412
412
 
@@ -430,7 +430,7 @@ EXAMPLES
430
430
  $ hereya workspace env set -w my-workspace -n myVar -v my-value -i aws -s
431
431
  ```
432
432
 
433
- _See code: [src/commands/workspace/env/set/index.ts](https://github.com/hereya/hereya-cli/blob/v0.14.0/src/commands/workspace/env/set/index.ts)_
433
+ _See code: [src/commands/workspace/env/set/index.ts](https://github.com/hereya/hereya-cli/blob/v0.15.0/src/commands/workspace/env/set/index.ts)_
434
434
 
435
435
  ## `hereya workspace env unset`
436
436
 
@@ -451,7 +451,7 @@ EXAMPLES
451
451
  $ hereya workspace env unset -w my-workspace -n myVar
452
452
  ```
453
453
 
454
- _See code: [src/commands/workspace/env/unset/index.ts](https://github.com/hereya/hereya-cli/blob/v0.14.0/src/commands/workspace/env/unset/index.ts)_
454
+ _See code: [src/commands/workspace/env/unset/index.ts](https://github.com/hereya/hereya-cli/blob/v0.15.0/src/commands/workspace/env/unset/index.ts)_
455
455
 
456
456
  ## `hereya workspace install PACKAGE`
457
457
 
@@ -477,7 +477,7 @@ EXAMPLES
477
477
  $ hereya workspace install hereya/aws-cognito
478
478
  ```
479
479
 
480
- _See code: [src/commands/workspace/install/index.ts](https://github.com/hereya/hereya-cli/blob/v0.14.0/src/commands/workspace/install/index.ts)_
480
+ _See code: [src/commands/workspace/install/index.ts](https://github.com/hereya/hereya-cli/blob/v0.15.0/src/commands/workspace/install/index.ts)_
481
481
 
482
482
  ## `hereya workspace uninstall PACKAGE`
483
483
 
@@ -503,5 +503,5 @@ EXAMPLES
503
503
  $ hereya workspace uninstall hereya/aws-cognito
504
504
  ```
505
505
 
506
- _See code: [src/commands/workspace/uninstall/index.ts](https://github.com/hereya/hereya-cli/blob/v0.14.0/src/commands/workspace/uninstall/index.ts)_
506
+ _See code: [src/commands/workspace/uninstall/index.ts](https://github.com/hereya/hereya-cli/blob/v0.15.0/src/commands/workspace/uninstall/index.ts)_
507
507
  <!-- commandsstop -->
@@ -10,7 +10,7 @@ export interface Backend {
10
10
  getWorkspaceEnv(input: GetWorkspaceEnvInput): Promise<GetWorkspaceEnvOutput>;
11
11
  init(options: InitProjectInput): Promise<InitProjectOutput>;
12
12
  removePackageFromWorkspace(input: RemovePackageFromWorkspaceInput): Promise<RemovePackageFromWorkspaceOutput>;
13
- saveState(config: Omit<Config, 'workspace'>): Promise<void>;
13
+ saveState(config: Config, workspace?: string): Promise<void>;
14
14
  setEnvVar(input: SetEnvVarInput): Promise<SetEnvVarOutput>;
15
15
  unsetEnvVar(input: UnsetEnvVarInput): Promise<UnsetEnvVarOutput>;
16
16
  }
@@ -110,9 +110,10 @@ export type GetWorkspaceOutput = {
110
110
  });
111
111
  export type GetStateInput = {
112
112
  project: string;
113
+ workspace: string;
113
114
  };
114
115
  export type GetStateOutput = {
115
- config: Omit<Config, 'workspace'>;
116
+ config: Config;
116
117
  found: true;
117
118
  } | {
118
119
  found: false;
@@ -10,10 +10,12 @@ export declare class LocalBackend implements Backend {
10
10
  getWorkspaceEnv(input: GetWorkspaceEnvInput): Promise<GetWorkspaceEnvOutput>;
11
11
  init(options: InitProjectInput): Promise<InitProjectOutput>;
12
12
  removePackageFromWorkspace(input: RemovePackageFromWorkspaceInput): Promise<RemovePackageFromWorkspaceOutput>;
13
- saveState(config: Omit<Config, 'workspace'>): Promise<void>;
13
+ saveState(config: Config, workspace?: string): Promise<void>;
14
14
  setEnvVar(input: SetEnvVarInput): Promise<SetEnvVarOutput>;
15
15
  unsetEnvVar(input: UnsetEnvVarInput): Promise<UnsetEnvVarOutput>;
16
+ private getOldProjectStatePath;
16
17
  private getProjectStatePath;
17
18
  private getWorkspacePath;
19
+ private migrateProjectState;
18
20
  private saveWorkspace;
19
21
  }
@@ -132,7 +132,8 @@ export class LocalBackend {
132
132
  };
133
133
  }
134
134
  async getState(input) {
135
- const projectStatePath = await this.getProjectStatePath(input.project);
135
+ await this.migrateProjectState(input);
136
+ const projectStatePath = await this.getProjectStatePath(input);
136
137
  const { data, found } = await load(projectStatePath);
137
138
  if (found) {
138
139
  return {
@@ -228,9 +229,16 @@ export class LocalBackend {
228
229
  };
229
230
  }
230
231
  }
231
- async saveState(config) {
232
- const projectStatePath = await this.getProjectStatePath(config.project);
233
- await save(config, projectStatePath);
232
+ async saveState(config, workspace) {
233
+ await this.migrateProjectState({
234
+ project: config.project,
235
+ workspace: workspace ?? config.workspace,
236
+ });
237
+ const projectStatePath = await this.getProjectStatePath({
238
+ project: config.project,
239
+ workspace: workspace ?? config.workspace,
240
+ });
241
+ await save({ ...config, workspace: workspace ?? config.workspace }, projectStatePath);
234
242
  }
235
243
  async setEnvVar(input) {
236
244
  const workspace$ = await this.getWorkspace(input.workspace);
@@ -321,12 +329,30 @@ export class LocalBackend {
321
329
  success: true,
322
330
  };
323
331
  }
324
- async getProjectStatePath(project) {
325
- return getAnyPath(path.join(os.homedir(), '.hereya', 'state', 'projects', `${project}.yaml`), path.join(os.homedir(), '.hereya', 'state', 'projects', `${project}.yml`));
332
+ async getOldProjectStatePath(input) {
333
+ return getAnyPath(path.join(os.homedir(), '.hereya', 'state', 'projects', `${input.project}.yaml`), path.join(os.homedir(), '.hereya', 'state', 'projects', `${input.project}.yml`));
334
+ }
335
+ async getProjectStatePath(input) {
336
+ return getAnyPath(path.join(os.homedir(), '.hereya', 'state', 'projects', input.workspace, `${input.project}.yaml`), path.join(os.homedir(), '.hereya', 'state', 'projects', input.workspace, `${input.project}.yml`));
326
337
  }
327
338
  async getWorkspacePath(name) {
328
339
  return getAnyPath(path.join(os.homedir(), '.hereya', 'state', 'workspaces', `${name}.yaml`), path.join(os.homedir(), '.hereya', 'state', 'workspaces', `${name}.yml`));
329
340
  }
341
+ async migrateProjectState(input) {
342
+ const oldProjectStatePath = await this.getOldProjectStatePath(input);
343
+ const newProjectStatePath = await this.getProjectStatePath(input);
344
+ const newProjectStateDir = path.dirname(newProjectStatePath);
345
+ await fs.mkdir(newProjectStateDir, { recursive: true });
346
+ try {
347
+ await fs.access(oldProjectStatePath);
348
+ await fs.rename(oldProjectStatePath, newProjectStatePath);
349
+ }
350
+ catch (error) {
351
+ if (error.code !== 'ENOENT') {
352
+ throw error;
353
+ }
354
+ }
355
+ }
330
356
  async saveWorkspace(data, name) {
331
357
  const workspacePath = await this.getWorkspacePath(name);
332
358
  await save(data, workspacePath);
@@ -80,6 +80,7 @@ export default class Deploy extends Command {
80
80
  const backend = await getBackend();
81
81
  const savedStateOutput = await backend.getState({
82
82
  project: ctx.configOutput.config.project,
83
+ workspace: ctx.workspace,
83
84
  });
84
85
  if (savedStateOutput.found) {
85
86
  ctx.savedStateOutput = savedStateOutput;
@@ -238,11 +239,11 @@ export default class Deploy extends Command {
238
239
  title: 'Adding env vars from added packages',
239
240
  },
240
241
  {
241
- async task() {
242
+ async task(ctx) {
242
243
  const backend = await getBackend();
243
244
  const configManager = getConfigManager();
244
245
  const { config: newConfig } = await configManager.loadConfig({ projectRootDir });
245
- await backend.saveState(newConfig);
246
+ await backend.saveState(newConfig, ctx.workspace);
246
247
  await delay(500);
247
248
  },
248
249
  title: 'Saving state',
@@ -72,6 +72,7 @@ export default class Down extends Command {
72
72
  const backend = await getBackend();
73
73
  const savedStateOutput = await backend.getState({
74
74
  project: ctx.configOutput.config.project,
75
+ workspace: ctx.workspace,
75
76
  });
76
77
  let removedPackages = [];
77
78
  if (savedStateOutput.found) {
@@ -141,11 +142,11 @@ export default class Down extends Command {
141
142
  title: 'Removing env vars from destroyed packages',
142
143
  },
143
144
  {
144
- async task() {
145
+ async task(ctx) {
145
146
  const backend = await getBackend();
146
147
  const configManager = getConfigManager();
147
148
  const { config: newConfig } = await configManager.loadConfig({ projectRootDir });
148
- await backend.saveState(newConfig);
149
+ await backend.saveState(newConfig, ctx.workspace);
149
150
  await delay(500);
150
151
  },
151
152
  title: 'Saving state',
@@ -81,6 +81,7 @@ export default class Undeploy extends Command {
81
81
  const backend = await getBackend();
82
82
  const savedStateOutput = await backend.getState({
83
83
  project: ctx.configOutput.config.project,
84
+ workspace: ctx.workspace,
84
85
  });
85
86
  if (savedStateOutput.found) {
86
87
  ctx.savedStateOutput = savedStateOutput;
@@ -187,11 +188,11 @@ export default class Undeploy extends Command {
187
188
  title: 'Removing env vars from destroyed packages',
188
189
  },
189
190
  {
190
- async task() {
191
+ async task(ctx) {
191
192
  const backend = await getBackend();
192
193
  const configManager = getConfigManager();
193
194
  const { config: newConfig } = await configManager.loadConfig({ projectRootDir });
194
- await backend.saveState(newConfig);
195
+ await backend.saveState(newConfig, ctx.workspace);
195
196
  await delay(500);
196
197
  },
197
198
  title: 'Saving state',
@@ -71,6 +71,7 @@ export default class Up extends Command {
71
71
  const backend = await getBackend();
72
72
  const savedStateOutput = await backend.getState({
73
73
  project: ctx.configOutput.config.project,
74
+ workspace: ctx.workspace,
74
75
  });
75
76
  if (savedStateOutput.found) {
76
77
  ctx.savedStateOutput = savedStateOutput;
@@ -205,11 +206,11 @@ export default class Up extends Command {
205
206
  title: 'Adding env vars from added packages',
206
207
  },
207
208
  {
208
- async task() {
209
+ async task(ctx) {
209
210
  const backend = await getBackend();
210
211
  const configManager = getConfigManager();
211
212
  const { config: newConfig } = await configManager.loadConfig({ projectRootDir });
212
- await backend.saveState(newConfig);
213
+ await backend.saveState(newConfig, ctx.workspace);
213
214
  await delay(500);
214
215
  },
215
216
  title: 'Saving state',
@@ -884,5 +884,5 @@
884
884
  ]
885
885
  }
886
886
  },
887
- "version": "0.14.0"
887
+ "version": "0.15.0"
888
888
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "hereya-cli",
3
3
  "description": "Infrastructure as Package",
4
- "version": "0.14.0",
4
+ "version": "0.15.0",
5
5
  "author": "Hereya Developers",
6
6
  "bin": {
7
7
  "hereya": "./bin/run.js"