@causa/workspace-terraform 0.7.2 → 0.8.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.
Files changed (29) hide show
  1. package/dist/configurations/generated.d.ts +28 -0
  2. package/dist/configurations/generated.js +56 -0
  3. package/dist/configurations/index.d.ts +1 -1
  4. package/dist/configurations/index.js +1 -1
  5. package/dist/configurations/schemas/terraform.yaml +23 -0
  6. package/dist/functions/causa/index.d.ts +1 -0
  7. package/dist/functions/causa/index.js +1 -0
  8. package/dist/functions/causa/list-schemas.d.ts +9 -0
  9. package/dist/functions/causa/list-schemas.js +23 -0
  10. package/dist/functions/index.js +4 -6
  11. package/dist/functions/{infrastructure-deploy-terraform.js → infrastructure/deploy-terraform.js} +1 -1
  12. package/dist/functions/infrastructure/index.d.ts +2 -0
  13. package/dist/functions/infrastructure/index.js +2 -0
  14. package/dist/functions/{infrastructure-prepare-terraform.js → infrastructure/prepare-terraform.js} +1 -1
  15. package/dist/functions/{project-dependencies-update-terraform.js → project/dependencies-update-terraform.js} +1 -1
  16. package/dist/functions/project/index.d.ts +3 -0
  17. package/dist/functions/project/index.js +3 -0
  18. package/dist/functions/{project-init-terraform.js → project/init-terraform.js} +3 -2
  19. package/dist/functions/{project-lint-terraform.js → project/lint-terraform.js} +3 -2
  20. package/dist/services/terraform.d.ts +1 -1
  21. package/dist/services/terraform.js +1 -1
  22. package/package.json +10 -6
  23. package/dist/configurations/terraform.d.ts +0 -21
  24. package/dist/configurations/terraform.js +0 -1
  25. /package/dist/functions/{infrastructure-deploy-terraform.d.ts → infrastructure/deploy-terraform.d.ts} +0 -0
  26. /package/dist/functions/{infrastructure-prepare-terraform.d.ts → infrastructure/prepare-terraform.d.ts} +0 -0
  27. /package/dist/functions/{project-dependencies-update-terraform.d.ts → project/dependencies-update-terraform.d.ts} +0 -0
  28. /package/dist/functions/{project-init-terraform.d.ts → project/init-terraform.d.ts} +0 -0
  29. /package/dist/functions/{project-lint-terraform.d.ts → project/lint-terraform.d.ts} +0 -0
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Configuration for Terraform.
3
+ */
4
+ export declare class Terraform {
5
+ constructor(init: Terraform);
6
+ /**
7
+ * The version of Terraform to use.
8
+ * Can be a semver version, or `latest`.
9
+ * The installed version is considered compatible if it is greater than or equal to the configured version, within the same major version.
10
+ */
11
+ readonly version?: string;
12
+ /**
13
+ * The Terraform workspace that should be selected prior to performing `plan` and `apply` operations.
14
+ */
15
+ readonly workspace?: string;
16
+ [property: string]: any;
17
+ }
18
+ /**
19
+ * The schema for the Terraform configuration.
20
+ */
21
+ export declare class TerraformConfiguration {
22
+ constructor(init: TerraformConfiguration);
23
+ /**
24
+ * Configuration for Terraform.
25
+ */
26
+ readonly terraform?: Terraform;
27
+ [property: string]: any;
28
+ }
@@ -0,0 +1,56 @@
1
+ // This file was generated by the Causa command line. Do not edit it manually.
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ import { AllowMissing } from '@causa/workspace/validation';
12
+ import { IsString } from 'class-validator';
13
+ /**
14
+ * Configuration for Terraform.
15
+ */
16
+ export class Terraform {
17
+ constructor(init) {
18
+ Object.assign(this, init);
19
+ }
20
+ /**
21
+ * The version of Terraform to use.
22
+ * Can be a semver version, or `latest`.
23
+ * The installed version is considered compatible if it is greater than or equal to the configured version, within the same major version.
24
+ */
25
+ version;
26
+ /**
27
+ * The Terraform workspace that should be selected prior to performing `plan` and `apply` operations.
28
+ */
29
+ workspace;
30
+ }
31
+ __decorate([
32
+ AllowMissing(),
33
+ IsString(),
34
+ __metadata("design:type", String)
35
+ ], Terraform.prototype, "version", void 0);
36
+ __decorate([
37
+ AllowMissing(),
38
+ IsString(),
39
+ __metadata("design:type", String)
40
+ ], Terraform.prototype, "workspace", void 0);
41
+ /**
42
+ * The schema for the Terraform configuration.
43
+ */
44
+ export class TerraformConfiguration {
45
+ constructor(init) {
46
+ Object.assign(this, init);
47
+ }
48
+ /**
49
+ * Configuration for Terraform.
50
+ */
51
+ terraform;
52
+ }
53
+ __decorate([
54
+ AllowMissing(),
55
+ __metadata("design:type", Terraform)
56
+ ], TerraformConfiguration.prototype, "terraform", void 0);
@@ -1 +1 @@
1
- export type { TerraformConfiguration } from './terraform.js';
1
+ export { TerraformConfiguration } from './generated.js';
@@ -1 +1 @@
1
- export {};
1
+ export { TerraformConfiguration } from './generated.js';
@@ -0,0 +1,23 @@
1
+ title: TerraformConfiguration
2
+ type: object
3
+ description: The schema for the Terraform configuration.
4
+ properties:
5
+ terraform:
6
+ title: Terraform
7
+ type: object
8
+ description: Configuration for Terraform.
9
+ properties:
10
+ workspace:
11
+ type: string
12
+ description: >-
13
+ The Terraform workspace that should be selected prior to performing
14
+ `plan` and `apply` operations.
15
+ version:
16
+ type: string
17
+ description: >-
18
+ The version of Terraform to use.
19
+
20
+ Can be a semver version, or `latest`.
21
+
22
+ The installed version is considered compatible if it is greater than
23
+ or equal to the configured version, within the same major version.
@@ -0,0 +1 @@
1
+ export { CausaListConfigurationSchemasForTerraform } from './list-schemas.js';
@@ -0,0 +1 @@
1
+ export { CausaListConfigurationSchemasForTerraform } from './list-schemas.js';
@@ -0,0 +1,9 @@
1
+ import { CausaListConfigurationSchemas } from '@causa/workspace-core';
2
+ /**
3
+ * Implements {@link CausaListConfigurationSchemas} for the Terraform module.
4
+ * Returns the paths to the configuration schemas bundled with this package.
5
+ */
6
+ export declare class CausaListConfigurationSchemasForTerraform extends CausaListConfigurationSchemas {
7
+ _call(): Promise<string[]>;
8
+ _supports(): boolean;
9
+ }
@@ -0,0 +1,23 @@
1
+ import { CausaListConfigurationSchemas } from '@causa/workspace-core';
2
+ import { globby } from 'globby';
3
+ import { dirname, resolve } from 'path';
4
+ import { fileURLToPath } from 'url';
5
+ /**
6
+ * The directory containing the configuration schemas provided by this module.
7
+ */
8
+ const SCHEMAS_DIRECTORY = resolve(dirname(fileURLToPath(import.meta.url)), '../../configurations/schemas');
9
+ /**
10
+ * Implements {@link CausaListConfigurationSchemas} for the Terraform module.
11
+ * Returns the paths to the configuration schemas bundled with this package.
12
+ */
13
+ export class CausaListConfigurationSchemasForTerraform extends CausaListConfigurationSchemas {
14
+ async _call() {
15
+ return await globby('*.yaml', {
16
+ cwd: SCHEMAS_DIRECTORY,
17
+ absolute: true,
18
+ });
19
+ }
20
+ _supports() {
21
+ return true;
22
+ }
23
+ }
@@ -1,8 +1,6 @@
1
- import { InfrastructureDeployForTerraform } from './infrastructure-deploy-terraform.js';
2
- import { InfrastructurePrepareForTerraform } from './infrastructure-prepare-terraform.js';
3
- import { ProjectDependenciesUpdateForTerraform } from './project-dependencies-update-terraform.js';
4
- import { ProjectInitForTerraform } from './project-init-terraform.js';
5
- import { ProjectLintForTerraform } from './project-lint-terraform.js';
1
+ import { CausaListConfigurationSchemasForTerraform } from './causa/index.js';
2
+ import { InfrastructureDeployForTerraform, InfrastructurePrepareForTerraform, } from './infrastructure/index.js';
3
+ import { ProjectDependenciesUpdateForTerraform, ProjectInitForTerraform, ProjectLintForTerraform, } from './project/index.js';
6
4
  export function registerFunctions(context) {
7
- context.registerFunctionImplementations(InfrastructureDeployForTerraform, InfrastructurePrepareForTerraform, ProjectDependenciesUpdateForTerraform, ProjectInitForTerraform, ProjectLintForTerraform);
5
+ context.registerFunctionImplementations(CausaListConfigurationSchemasForTerraform, InfrastructureDeployForTerraform, InfrastructurePrepareForTerraform, ProjectDependenciesUpdateForTerraform, ProjectInitForTerraform, ProjectLintForTerraform);
8
6
  }
@@ -2,7 +2,7 @@ import { WorkspaceContext } from '@causa/workspace';
2
2
  import { InfrastructureDeploy } from '@causa/workspace-core';
3
3
  import { rm } from 'fs/promises';
4
4
  import { resolve } from 'path';
5
- import { TerraformService } from '../services/index.js';
5
+ import { TerraformService } from '../../services/index.js';
6
6
  /**
7
7
  * Implements the {@link InfrastructureDeploy} function for Infrastructure as Code defined using Terraform.
8
8
  * This calls the `terraform apply` command for the given project.
@@ -0,0 +1,2 @@
1
+ export { InfrastructureDeployForTerraform } from './deploy-terraform.js';
2
+ export { InfrastructurePrepareForTerraform } from './prepare-terraform.js';
@@ -0,0 +1,2 @@
1
+ export { InfrastructureDeployForTerraform } from './deploy-terraform.js';
2
+ export { InfrastructurePrepareForTerraform } from './prepare-terraform.js';
@@ -2,7 +2,7 @@ import { WorkspaceContext } from '@causa/workspace';
2
2
  import { InfrastructurePrepare, } from '@causa/workspace-core';
3
3
  import { rm } from 'fs/promises';
4
4
  import { resolve } from 'path';
5
- import { TerraformService } from '../services/index.js';
5
+ import { TerraformService } from '../../services/index.js';
6
6
  /**
7
7
  * The default name of the output Terraform plan file.
8
8
  */
@@ -1,6 +1,6 @@
1
1
  import { WorkspaceContext } from '@causa/workspace';
2
2
  import { ProjectDependenciesUpdate } from '@causa/workspace-core';
3
- import { TerraformService } from '../services/index.js';
3
+ import { TerraformService } from '../../services/index.js';
4
4
  /**
5
5
  * Implements the {@link ProjectDependenciesUpdate} function for Terraform projects, by running `terraform init`.
6
6
  * This uses the `-upgrade` option to fetch the latest versions of the providers allowed by configured constraints, and
@@ -0,0 +1,3 @@
1
+ export { ProjectDependenciesUpdateForTerraform } from './dependencies-update-terraform.js';
2
+ export { ProjectInitForTerraform } from './init-terraform.js';
3
+ export { ProjectLintForTerraform } from './lint-terraform.js';
@@ -0,0 +1,3 @@
1
+ export { ProjectDependenciesUpdateForTerraform } from './dependencies-update-terraform.js';
2
+ export { ProjectInitForTerraform } from './init-terraform.js';
3
+ export { ProjectLintForTerraform } from './lint-terraform.js';
@@ -2,7 +2,7 @@ import { WorkspaceContext } from '@causa/workspace';
2
2
  import { ProjectInit } from '@causa/workspace-core';
3
3
  import { rm } from 'fs/promises';
4
4
  import { join } from 'path';
5
- import { TerraformService } from '../services/index.js';
5
+ import { TerraformService } from '../../services/index.js';
6
6
  /**
7
7
  * The name of the folder automatically created by Terraform during initialization.
8
8
  */
@@ -23,7 +23,8 @@ export class ProjectInitForTerraform extends ProjectInit {
23
23
  context.logger.info(`️✅ Successfully initialized Terraform.`);
24
24
  }
25
25
  _supports(context) {
26
- return (context.get('project.language') === 'terraform' &&
26
+ return (!this.workspace &&
27
+ context.get('project.language') === 'terraform' &&
27
28
  context.get('project.type') === 'infrastructure');
28
29
  }
29
30
  }
@@ -1,6 +1,7 @@
1
1
  import { WorkspaceContext } from '@causa/workspace';
2
- import { ProcessServiceExitCodeError, ProjectLint, } from '@causa/workspace-core';
3
- import { TerraformService } from '../services/index.js';
2
+ import { ProjectLint } from '@causa/workspace-core';
3
+ import { ProcessServiceExitCodeError } from '@causa/workspace-core/services';
4
+ import { TerraformService } from '../../services/index.js';
4
5
  /**
5
6
  * The list of file extensions that `terraform fmt` supports.
6
7
  */
@@ -1,5 +1,5 @@
1
1
  import { WorkspaceContext } from '@causa/workspace';
2
- import { type SpawnOptions, type SpawnedProcessResult } from '@causa/workspace-core';
2
+ import { type SpawnOptions, type SpawnedProcessResult } from '@causa/workspace-core/services';
3
3
  /**
4
4
  * Options for the {@link TerraformService.wrapWorkspaceOperation} method.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  import { WorkspaceContext } from '@causa/workspace';
2
- import { ProcessService, ProcessServiceExitCodeError, } from '@causa/workspace-core';
2
+ import { ProcessService, ProcessServiceExitCodeError, } from '@causa/workspace-core/services';
3
3
  import { satisfies } from 'semver';
4
4
  import { IncompatibleTerraformVersionError } from './terraform.errors.js';
5
5
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@causa/workspace-terraform",
3
- "version": "0.7.2",
3
+ "version": "0.8.0",
4
4
  "description": "The Causa workspace module providing functionalities for infrastructure projects coded in Terraform.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -25,15 +25,19 @@
25
25
  "scripts": {
26
26
  "prebuild": "rimraf ./dist",
27
27
  "build": "tsc -p tsconfig.build.json",
28
+ "postbuild": "node transform-schemas.mjs",
28
29
  "format": "prettier --write \"src/**/*.ts\"",
29
30
  "lint": "eslint \"src/**/*.ts\"",
30
31
  "test": "NODE_OPTIONS=\"--experimental-vm-modules --no-warnings=ExperimentalWarning\" jest",
31
- "test:cov": "npm run test -- --coverage"
32
+ "test:cov": "npm run test -- --coverage",
33
+ "typecheck": "tsc --noEmit",
34
+ "generateConfigurationSchemas": "cs model genCode && perl -pi -e 's|\\@causa/runtime|\\@causa/workspace/validation|g' src/configurations/generated.ts"
32
35
  },
33
36
  "dependencies": {
34
- "@causa/workspace": ">= 0.19.2 < 1.0.0",
35
- "@causa/workspace-core": ">= 0.26.0 < 1.0.0",
36
- "pino": "^10.3.0",
37
+ "@causa/workspace": ">= 0.22.1 < 1.0.0",
38
+ "@causa/workspace-core": ">= 0.27.0 < 1.0.0",
39
+ "globby": "^16.1.0",
40
+ "pino": "^10.3.1",
37
41
  "semver": "^7.7.4"
38
42
  },
39
43
  "devDependencies": {
@@ -50,6 +54,6 @@
50
54
  "jest-extended": "^7.0.0",
51
55
  "rimraf": "^6.1.2",
52
56
  "typescript": "^5.9.3",
53
- "typescript-eslint": "^8.54.0"
57
+ "typescript-eslint": "^8.55.0"
54
58
  }
55
59
  }
@@ -1,21 +0,0 @@
1
- /**
2
- * The schema for the Terraform configuration.
3
- */
4
- export type TerraformConfiguration = {
5
- /**
6
- * Configuration for Terraform.
7
- */
8
- terraform?: {
9
- /**
10
- * The Terraform workspace that should be selected prior to performing `plan` and `apply` operations.
11
- */
12
- workspace?: string;
13
- /**
14
- * The version of Terraform to use.
15
- * Can be a semver version, or `latest`.
16
- * The installed version is considered compatible if it is greater than or equal to the configured version, within
17
- * the same major version.
18
- */
19
- version?: string;
20
- };
21
- };
@@ -1 +0,0 @@
1
- export {};