Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: don't cross package boundaries for templates #3029

Merged
merged 1 commit into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/@cdktf/cli-core/src/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export { TerraformCli } from "./models/terraform-cli";
export { CdktfConfig } from "./cdktf-config";
export { initializErrorReporting } from "./error-reporting";
export { CdktfStack } from "./cdktf-stack";
export { init, Project, InitArgs } from "./init";
export { init, Project, InitArgs, templates, templatesDir } from "./init";
export { get, GetStatus, runGetInDir } from "./get";
export { SynthesizedStack } from "./synth-stack";
export { CdktfProject, ProjectUpdate } from "./cdktf-project";
Expand Down
10 changes: 10 additions & 0 deletions packages/@cdktf/cli-core/src/lib/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ export type InitArgs = {
silent?: boolean;
};

export const templatesDir = path.join(__dirname, "..", "..", "templates");

const availableTemplates = fs
.readdirSync(templatesDir)
.filter((x) => !x.startsWith("."));
export const templates: string[] = [];
for (const template of availableTemplates) {
templates.push(template);
}
DanielMSchmidt marked this conversation as resolved.
Show resolved Hide resolved

export async function init({
cdktfVersion,
destination,
Expand Down
1 change: 1 addition & 0 deletions packages/cdktf-cli/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,5 @@ const nativeNodeModulesPlugin = {
}

fs.copySync("src/bin/cdktf", "./bundle/bin/cdktf");
fs.copySync("../@cdktf/cli-core/templates", "./bundle/templates");
})();
21 changes: 0 additions & 21 deletions packages/cdktf-cli/src/bin/cmds/helper/init-templates.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/cdktf-cli/src/bin/cmds/helper/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import {
Errors,
sendTelemetry,
} from "@cdktf/commons";
import { templates, templatesDir } from "./init-templates";
import { templates, templatesDir } from "@cdktf/cli-core";
import ciDetect from "@npmcli/ci-detect";
import { isInteractiveTerminal } from "./check-environment";
import { getTerraformVersion } from "./terraform-check";
Expand Down
5 changes: 1 addition & 4 deletions packages/cdktf-cli/src/bin/cmds/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// SPDX-License-Identifier: MPL-2.0
import yargs from "yargs";

import { templates } from "./helper/init-templates";
import { readPackageJson, requireHandlers } from "./helper/utilities";
import { Errors } from "@cdktf/commons";
import { BaseCommand } from "./helper/base-command";
Expand All @@ -17,9 +16,7 @@ class Command extends BaseCommand {
.showHelpOnFail(true)
.option("template", {
type: "string",
desc: `The template to be used to create a new project. Either URL to zip file or one of the built-in templates: [${templates
.map((t) => `"${t}"`)
.join(", ")}]`,
desc: `The template to be used to create a new project. Either URL to zip file or one of the built-in templates.`,
})
.option("project-name", {
type: "string",
Expand Down