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

🚧Move dev tool settings #28

Merged
merged 8 commits into from
Jun 23, 2024
1 change: 1 addition & 0 deletions create-pr.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
& "dev-tools/bin/kd-admin" create-pr;
3 changes: 3 additions & 0 deletions dev-tools/bin/kd-admin
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
# generated by deno install
deno "run" "--allow-read" "--allow-write" "--allow-net" "--allow-env" "--no-config" "https://raw.githubusercontent.com/KinsonDigital/kd-admin/v1.0.0-preview.2/src/main.ts" "$@"
2 changes: 2 additions & 0 deletions dev-tools/bin/kd-admin.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
% generated by deno install %
@deno "run" "--allow-read" "--allow-write" "--allow-net" "--allow-env" "--no-config" "https://raw.githubusercontent.com/KinsonDigital/kd-admin/v1.0.0-preview.2/src/main.ts" %*
6 changes: 6 additions & 0 deletions dev-tools/create-pr-settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"ownerName": "",
"repoName": "",
"githubTokenEnvVarName": "",
"baseBranches": []
}
23 changes: 23 additions & 0 deletions dev-tools/gen-release-notes-settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"ownerName": "",
"repoName": "",
"githubTokenEnvVarName": "",
"milestoneName": "",
"headerText": "",
"version": "",
"environment": "",
"extraInfo": {
"title": "",
"text": ""
},
"emojisToRemoveFromTitle": [],
"issueCategoryLabelMappings": {},
"prCategoryLabelMappings": {},
"ignoreLabels": [],
"wordReplacements": {},
"firstWordReplacements": {},
"styleWordsList": {},
"boldedVersions": true,
"italicVersions": true,
"otherCategoryName": ""
}
21 changes: 21 additions & 0 deletions dev-tools/prepare-release-settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"ownerName": "",
"repoName": "",
"orgProjectName": "",
"releaseTypes": [
{
"name": "",
"reviewer": "",
"assignee": "",
"headBranch": "",
"baseBranch": "",
"genReleaseSettingsFilePath": "",
"releaseNotesDirPath": "",
"releasePrTemplateFilePath": "",
"releaseLabels": [],
"prTitle": ""
}
],
"githubTokenEnvVarName": "",
"versionFilePath": ""
}
27 changes: 15 additions & 12 deletions installation/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { CreatePrSettings } from "../src/create-pr-settings.ts";
import { PrepareReleaseSettings } from "../src/prepare-release-settings.ts";
import { existsSync } from "../deps.ts";
import { GeneratorSettings } from "../src/generator-settings.ts";
import { ensureDirSync } from "https://deno.land/[email protected]/fs/ensure_dir.ts";

const scriptArgs = Deno.args.map((arg) => arg.trim());

Expand All @@ -25,7 +26,9 @@ const createPrSettingsFileName = "create-pr-settings.json";
const prepareReleaseSettingsFileName = "prepare-release-settings.json";
const generateReleaseSettingsFileName = "gen-release-notes-settings.json";

if (existsSync(`./${createPrShellFileName}`)) {
ensureDirSync("./dev-tools");

if (existsSync(`./${createPrShellFileName}`, { isFile: true })) {
console.log(`%c'${createPrShellFileName}' file already exists. Skipping creation.`, "color: khaki");
} else {
const confirmCreatePRShellScript = await Confirm.prompt({
Expand All @@ -34,12 +37,12 @@ if (existsSync(`./${createPrShellFileName}`)) {
});

if (confirmCreatePRShellScript) {
Deno.writeTextFileSync(`./${createPrShellFileName}`, "& \"dev-tools/bin/kd-admin\" create-pr;");
Deno.writeTextFileSync(`./${createPrShellFileName}`, "& \"dev-tools/bin/kd-admin\" create-pr;\n");
console.log(`%c\tCreated '${createPrShellFileName}' file.`, "color: gray");
}
}

if (existsSync(`./${prepareReleaseShellFileName}`)) {
if (existsSync(`./${prepareReleaseShellFileName}`, { isFile: true })) {
console.log(`%c'${prepareReleaseShellFileName}' file already exists. Skipping creation.`, "color: khaki");
} else {
const confirmCreatePrepareReleaseShellScript = await Confirm.prompt({
Expand All @@ -48,12 +51,12 @@ if (existsSync(`./${prepareReleaseShellFileName}`)) {
});

if (confirmCreatePrepareReleaseShellScript) {
Deno.writeTextFileSync(`./${prepareReleaseShellFileName}`, "& \"dev-tools/bin/kd-admin\" prepare-for-release;");
Deno.writeTextFileSync(`./${prepareReleaseShellFileName}`, "& \"dev-tools/bin/kd-admin\" prepare-for-release;\n");
console.log(`%c\tCreated '${prepareReleaseShellFileName}' file.`, "color: gray");
}
}

if (existsSync(`./${createPrSettingsFileName}`)) {
if (existsSync(`./dev-tools/${createPrSettingsFileName}`, { isFile: true })) {
console.log(`%c'${createPrSettingsFileName}' file already exists. Skipping creation.`, "color: khaki");
} else {
const confirmCreatePRSettingsFile = await Confirm.prompt({
Expand All @@ -68,13 +71,13 @@ if (existsSync(`./${createPrSettingsFileName}`)) {
githubTokenEnvVarName: "",
baseBranches: []
};
Deno.writeTextFileSync(`./${createPrSettingsFileName}`, `${JSON.stringify(prSettings, null, 2)}\n`);

Deno.writeTextFileSync(`./dev-tools/${createPrSettingsFileName}`, `${JSON.stringify(prSettings, null, 2)}\n`);
console.log(`%c\tCreated '${createPrSettingsFileName}' file.`, "color: gray");
}
}

if (existsSync(`./${prepareReleaseSettingsFileName}`)) {
if (existsSync(`./dev-tools/${prepareReleaseSettingsFileName}`, { isFile: true })) {
console.log(`%c'${prepareReleaseSettingsFileName}' file already exists. Skipping creation.`, "color: khaki");
} else {
const confirmCreatePrepareReleaseSettingFiles = await Confirm.prompt({
Expand Down Expand Up @@ -105,19 +108,19 @@ if (existsSync(`./${prepareReleaseSettingsFileName}`)) {
versionFilePath: "",
};

Deno.writeTextFileSync(`./${prepareReleaseSettingsFileName}`, `${JSON.stringify(prepareReleaseSettings, null, 2)}\n`);
Deno.writeTextFileSync(`./dev-tools/${prepareReleaseSettingsFileName}`, `${JSON.stringify(prepareReleaseSettings, null, 2)}\n`);
console.log(`%c\tCreated '${prepareReleaseSettingsFileName}' file.`, "color: gray");
}
}

if (existsSync(`./${generateReleaseSettingsFileName}`)) {
if (existsSync(`./dev-tools/${generateReleaseSettingsFileName}`, { isFile: true })) {
console.log(`%c'${generateReleaseSettingsFileName}' file already exists. Skipping creation.`, "color: khaki");
} else {
const confirmGenReleaseSettingsFile = await Confirm.prompt({
message: "Do you want to add a the generate release settings file?",
default: true,
});

if (confirmGenReleaseSettingsFile) {
const genReleaseSettings: GeneratorSettings = {
ownerName: "",
Expand All @@ -140,7 +143,7 @@ if (existsSync(`./${generateReleaseSettingsFileName}`)) {
otherCategoryName: "",
};

Deno.writeTextFileSync(`./${generateReleaseSettingsFileName}`, `${JSON.stringify(genReleaseSettings, null, 2)}\n`);
Deno.writeTextFileSync(`./dev-tools/${generateReleaseSettingsFileName}`, `${JSON.stringify(genReleaseSettings, null, 2)}\n`);
console.log(`%c\tCreated '${generateReleaseSettingsFileName}' file.`, "color: gray");
}
}
Expand Down
1 change: 1 addition & 0 deletions prepare-for-release.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
& "dev-tools/bin/kd-admin" prepare-for-release;
5 changes: 4 additions & 1 deletion src/pr-creator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ export class PrCreator {
constructor() {
}

/**
* Creates a pull request using collected information from the user and settings.
*/
public async createPr(): Promise<void> {
const settings = this.getSettings();

Expand Down Expand Up @@ -130,7 +133,7 @@ export class PrCreator {
*/
private getSettings(): CreatePrSettings {
const settingsFileName = "create-pr-settings.json";
const settingsFilePath = `./${settingsFileName}`;
const settingsFilePath = `./dev-tools/${settingsFileName}`;

if (!existsSync(settingsFilePath, { isFile: true })) {
const errorMsg = `The settings file '${settingsFileName}' does not exist in the current working directory.`;
Expand Down
2 changes: 1 addition & 1 deletion src/release-prepper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export class ReleasePrepper {
*/
private getSettings(): PrepareReleaseSettings {
const settingsFileName = "prepare-release-settings.json";
const settingsFilePath = `./${settingsFileName}`;
const settingsFilePath = `./dev-tools/${settingsFileName}`;

if (!existsSync(settingsFilePath, { isFile: true })) {
const errorMsg = `The settings file '${settingsFileName}' does not exist in the current working directory.`;
Expand Down
Loading